Update droidstubs to support putting action inputs/outputs into the module-graph.json.
Test: local test
Change-Id: I6ce657f2ad53c261bcbdd317c266cf179a0cc6e9
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 7ad316f..5a84e05 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -19,6 +19,7 @@
"path/filepath"
"strings"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -806,7 +807,8 @@
properties PrebuiltStubsSourcesProperties
- stubsSrcJar android.Path
+ stubsSrcJar android.Path
+ jsonDataActions []blueprint.JSONDataAction
}
func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
@@ -822,6 +824,13 @@
return d.stubsSrcJar
}
+// AddJSONData is a temporary solution for droidstubs module to put action
+// related data into the module json graph.
+func (p *PrebuiltStubsSources) AddJSONData(d *map[string]interface{}) {
+ p.ModuleBase.AddJSONData(d)
+ (*d)["Actions"] = blueprint.FormatJSONDataActions(p.jsonDataActions)
+}
+
func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if len(p.properties.Srcs) != 1 {
ctx.PropertyErrorf("srcs", "must only specify one directory path or srcjar, contains %d paths", len(p.properties.Srcs))
@@ -829,9 +838,12 @@
}
src := p.properties.Srcs[0]
+ var jsonDataAction blueprint.JSONDataAction
if filepath.Ext(src) == ".srcjar" {
// This is a srcjar. We can use it directly.
p.stubsSrcJar = android.PathForModuleSrc(ctx, src)
+ jsonDataAction.Inputs = []string{src}
+ jsonDataAction.Outputs = []string{src}
} else {
outPath := android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
@@ -855,7 +867,10 @@
rule.Restat()
rule.Build("zip src", "Create srcjar from prebuilt source")
p.stubsSrcJar = outPath
+ jsonDataAction.Inputs = srcPaths.Strings()
+ jsonDataAction.Outputs = []string{outPath.String()}
}
+ p.jsonDataActions = []blueprint.JSONDataAction{jsonDataAction}
}
func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt {