summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2020-11-22 20:12:45 -0800
committerColin Cross <ccross@android.com>2020-11-23 18:35:55 +0000
commit1bc63938f00284f4bee3fd6e713816a6e999dbfd (patch)
treed2b9663bf3088ac055430d4f61b5fd7200d91486 /python
parente20113d8ab84d0965d10df00832bac94cbd396f3 (diff)
Add java_data parameter to python modules
csuite has a python module that wants to embed the outputs of java modules. This has caused issues with mismatched variants bewteen the arch-specific python module and the common java modules. Add a java_data property that is similar to the data property but uses the common arch variant. Bug: 173977903 Test: m checkbuild Change-Id: I0f2f0e4159650cd5d42b510d5177678e7ee91b4d
Diffstat (limited to 'python')
-rw-r--r--python/python.go14
-rw-r--r--python/test.go10
2 files changed, 24 insertions, 0 deletions
diff --git a/python/python.go b/python/python.go
index 770ea4d14..d7b1bbad4 100644
--- a/python/python.go
+++ b/python/python.go
@@ -86,6 +86,9 @@ type BaseProperties struct {
// the test. the file extension can be arbitrary except for (.py).
Data []string `android:"path,arch_variant"`
+ // list of java modules that provide data that should be installed alongside the test.
+ Java_data []string
+
// list of the Python libraries compatible both with Python2 and Python3.
Libs []string `android:"arch_variant"`
@@ -216,6 +219,7 @@ type dependencyTag struct {
var (
pythonLibTag = dependencyTag{name: "pythonLib"}
+ javaDataTag = dependencyTag{name: "javaData"}
launcherTag = dependencyTag{name: "launcher"}
launcherSharedLibTag = dependencyTag{name: "launcherSharedLib"}
pyIdentifierRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
@@ -370,6 +374,11 @@ func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
p.properties.Actual_version, ctx.ModuleName()))
}
+
+ // Emulate the data property for java_data but with the arch variation overridden to "common"
+ // so that it can point to java modules.
+ javaDataVariation := []blueprint.Variation{{"arch", android.Common.String()}}
+ ctx.AddVariationDependencies(javaDataVariation, javaDataTag, p.properties.Java_data...)
}
func (p *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -416,6 +425,11 @@ func (p *Module) GeneratePythonBuildActions(ctx android.ModuleContext) {
// expand data files from "data" property.
expandedData := android.PathsForModuleSrc(ctx, p.properties.Data)
+ // Emulate the data property for java_data dependencies.
+ for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) {
+ expandedData = append(expandedData, android.OutputFilesForModule(ctx, javaData, "")...)
+ }
+
// sanitize pkg_path.
pkgPath := String(p.properties.Pkg_path)
if pkgPath != "" {
diff --git a/python/test.go b/python/test.go
index f9baa465c..4df71c11b 100644
--- a/python/test.go
+++ b/python/test.go
@@ -45,6 +45,9 @@ type TestProperties struct {
// the test
Data []string `android:"path,arch_variant"`
+ // list of java modules that provide data that should be installed alongside the test.
+ Java_data []string
+
// Test options.
Test_options TestOptions
}
@@ -80,6 +83,13 @@ func (test *testDecorator) install(ctx android.ModuleContext, file android.Path)
for _, dataSrcPath := range dataSrcPaths {
test.data = append(test.data, android.DataPath{SrcPath: dataSrcPath})
}
+
+ // Emulate the data property for java_data dependencies.
+ for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) {
+ for _, javaDataSrcPath := range android.OutputFilesForModule(ctx, javaData, "") {
+ test.data = append(test.data, android.DataPath{SrcPath: javaDataSrcPath})
+ }
+ }
}
func NewTest(hod android.HostOrDeviceSupported) *Module {