Merge "Update droidstubs to support putting action inputs/outputs into the module-graph.json." am: f4bf09feba
am: 23b9e124ee
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1940894 Change-Id: Ib40b0f4729961992da5a471eb121493c407ad6c8
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -806,7 +807,8 @@ type PrebuiltStubsSources struct {
|
|||||||
|
|
||||||
properties PrebuiltStubsSourcesProperties
|
properties PrebuiltStubsSourcesProperties
|
||||||
|
|
||||||
stubsSrcJar android.Path
|
stubsSrcJar android.Path
|
||||||
|
jsonDataActions []blueprint.JSONDataAction
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
|
func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
|
||||||
@@ -822,6 +824,13 @@ func (d *PrebuiltStubsSources) StubsSrcJar() android.Path {
|
|||||||
return d.stubsSrcJar
|
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) {
|
func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
if len(p.properties.Srcs) != 1 {
|
if len(p.properties.Srcs) != 1 {
|
||||||
ctx.PropertyErrorf("srcs", "must only specify one directory path or srcjar, contains %d paths", len(p.properties.Srcs))
|
ctx.PropertyErrorf("srcs", "must only specify one directory path or srcjar, contains %d paths", len(p.properties.Srcs))
|
||||||
@@ -829,9 +838,12 @@ func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
src := p.properties.Srcs[0]
|
src := p.properties.Srcs[0]
|
||||||
|
var jsonDataAction blueprint.JSONDataAction
|
||||||
if filepath.Ext(src) == ".srcjar" {
|
if filepath.Ext(src) == ".srcjar" {
|
||||||
// This is a srcjar. We can use it directly.
|
// This is a srcjar. We can use it directly.
|
||||||
p.stubsSrcJar = android.PathForModuleSrc(ctx, src)
|
p.stubsSrcJar = android.PathForModuleSrc(ctx, src)
|
||||||
|
jsonDataAction.Inputs = []string{src}
|
||||||
|
jsonDataAction.Outputs = []string{src}
|
||||||
} else {
|
} else {
|
||||||
outPath := android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
outPath := android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
||||||
|
|
||||||
@@ -855,7 +867,10 @@ func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleCon
|
|||||||
rule.Restat()
|
rule.Restat()
|
||||||
rule.Build("zip src", "Create srcjar from prebuilt source")
|
rule.Build("zip src", "Create srcjar from prebuilt source")
|
||||||
p.stubsSrcJar = outPath
|
p.stubsSrcJar = outPath
|
||||||
|
jsonDataAction.Inputs = srcPaths.Strings()
|
||||||
|
jsonDataAction.Outputs = []string{outPath.String()}
|
||||||
}
|
}
|
||||||
|
p.jsonDataActions = []blueprint.JSONDataAction{jsonDataAction}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt {
|
func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt {
|
||||||
|
@@ -21,6 +21,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/blueprint"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -232,6 +234,30 @@ func TestDroidstubsWithSystemModules(t *testing.T) {
|
|||||||
checkSystemModulesUseByDroidstubs(t, ctx, "stubs-prebuilt-system-modules", "prebuilt-jar.jar")
|
checkSystemModulesUseByDroidstubs(t, ctx, "stubs-prebuilt-system-modules", "prebuilt-jar.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAddJSONData(t *testing.T) {
|
||||||
|
prebuiltStubsSources := PrebuiltStubsSources{}
|
||||||
|
prebuiltStubsSources.jsonDataActions = []blueprint.JSONDataAction{
|
||||||
|
blueprint.JSONDataAction{
|
||||||
|
Inputs: []string{},
|
||||||
|
Outputs: []string{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
jsonData := map[string]interface{}{}
|
||||||
|
prebuiltStubsSources.AddJSONData(&jsonData)
|
||||||
|
if fmt.Sprint(jsonData) != fmt.Sprint(
|
||||||
|
map[string]interface{}{
|
||||||
|
"Android": map[string]interface{}{},
|
||||||
|
"Actions": []map[string]interface{}{
|
||||||
|
map[string]interface{}{
|
||||||
|
"Inputs": []string{},
|
||||||
|
"Outputs": []string{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}) {
|
||||||
|
t.Errorf("The JSON data map isn't as expected %s.", jsonData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func checkSystemModulesUseByDroidstubs(t *testing.T, ctx *android.TestContext, moduleName string, systemJar string) {
|
func checkSystemModulesUseByDroidstubs(t *testing.T, ctx *android.TestContext, moduleName string, systemJar string) {
|
||||||
metalavaRule := ctx.ModuleForTests(moduleName, "android_common").Rule("metalava")
|
metalavaRule := ctx.ModuleForTests(moduleName, "android_common").Rule("metalava")
|
||||||
var systemJars []string
|
var systemJars []string
|
||||||
|
Reference in New Issue
Block a user