summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2024-10-21 15:41:42 -0700
committer Cole Faust <colefaust@google.com> 2024-10-21 15:41:42 -0700
commit65cb40a975fb53187cfc5d9edea905b1f7630ab2 (patch)
tree4fdd79e9271e230761e86e6b9e754e5755c078bd
parentbae26fe87f9d05a40accf870fee40d000ad4ed64 (diff)
Add new properties to aid in removing the 1-variant fallback
These new properties are essentially methods to specify "outgoing transitions" in blueprint files. There are lots of host tests that want to include apps built for device in their data, so they need a property that adds dependencies based on the device variants instead of copying the same host variants. After this cl is submitted, I'll do an LSC to update all the usages that are relying on the 1-variant fallback to use these properties instead. Bug: 372091092 Test: m nothing --no-skip-soong-tests Change-Id: I45b8fb024da120ad61606e3a21de86e4392be2a4
-rw-r--r--android/filegroup.go18
-rw-r--r--android/path_properties.go68
-rw-r--r--apex/apex_test.go2
-rw-r--r--bpf/libbpf/libbpf_prog_test.go1
-rw-r--r--cc/cc.go12
-rw-r--r--cc/compiler.go6
-rw-r--r--cc/fuzz.go1
-rw-r--r--cc/test.go15
-rw-r--r--filesystem/bootimg.go2
-rw-r--r--filesystem/vbmeta.go2
-rw-r--r--fuzz/fuzz_common.go5
-rw-r--r--genrule/genrule.go25
-rw-r--r--java/app.go2
-rw-r--r--java/base.go13
-rw-r--r--java/fuzz.go3
-rw-r--r--java/java.go12
-rw-r--r--java/java_resources.go6
-rw-r--r--java/java_test.go4
-rw-r--r--java/robolectric.go12
-rw-r--r--python/python.go6
-rw-r--r--rust/test.go4
-rw-r--r--scripts/hiddenapi/Android.bp12
-rw-r--r--sdk/genrule_test.go11
-rw-r--r--sdk/java_sdk_test.go2
-rw-r--r--sh/sh_binary.go12
-rw-r--r--tradefed_modules/test_module_config_test.go22
26 files changed, 223 insertions, 55 deletions
diff --git a/android/filegroup.go b/android/filegroup.go
index ff0f74e99..0e08c4fa9 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -41,6 +41,14 @@ type fileGroupProperties struct {
Exclude_srcs proptools.Configurable[[]string] `android:"path"`
+ // Sources the will be included in the filegroup, but any module dependencies will be added
+ // using the device os and the device's first architecture's variant.
+ Device_first_srcs proptools.Configurable[[]string] `android:"path_device_first"`
+
+ // Sources the will be included in the filegroup, but any module dependencies will be added
+ // using the device os and the common architecture's variant.
+ Device_common_srcs proptools.Configurable[[]string] `android:"path_device_common"`
+
// The base path to the files. May be used by other modules to determine which portion
// of the path to use. For example, when a filegroup is used as data in a cc_test rule,
// the base path is stripped off the path and the remaining path is used as the
@@ -90,11 +98,13 @@ func (fg *fileGroup) JSONActions() []blueprint.JSONAction {
}
func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
- fg.srcs = PathsForModuleSrcExcludes(ctx, fg.properties.Srcs.GetOrDefault(ctx, nil), fg.properties.Exclude_srcs.GetOrDefault(ctx, nil))
+ srcs := PathsForModuleSrcExcludes(ctx, fg.properties.Srcs.GetOrDefault(ctx, nil), fg.properties.Exclude_srcs.GetOrDefault(ctx, nil))
+ srcs = append(srcs, PathsForModuleSrc(ctx, fg.properties.Device_first_srcs.GetOrDefault(ctx, nil))...)
+ srcs = append(srcs, PathsForModuleSrc(ctx, fg.properties.Device_common_srcs.GetOrDefault(ctx, nil))...)
if fg.properties.Path != nil {
- fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
+ srcs = PathsWithModuleSrcSubDir(ctx, srcs, String(fg.properties.Path))
}
- SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: fg.srcs.Strings()})
+ SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcs.Strings()})
var aconfigDeclarations []string
var intermediateCacheOutputPaths Paths
@@ -108,6 +118,8 @@ func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
maps.Copy(modeInfos, dep.ModeInfos)
}
})
+
+ fg.srcs = srcs
SetProvider(ctx, CodegenInfoProvider, CodegenInfo{
AconfigDeclarations: aconfigDeclarations,
IntermediateCacheOutputPaths: intermediateCacheOutputPaths,
diff --git a/android/path_properties.go b/android/path_properties.go
index d80a8ed13..8ada1330c 100644
--- a/android/path_properties.go
+++ b/android/path_properties.go
@@ -18,6 +18,7 @@ import (
"fmt"
"reflect"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -38,20 +39,32 @@ func pathDepsMutator(ctx BottomUpMutatorContext) {
// squashed into the real modules.
return
}
+ if !ctx.Module().Enabled(ctx) {
+ return
+ }
props := ctx.Module().base().GetProperties()
addPathDepsForProps(ctx, props)
}
func addPathDepsForProps(ctx BottomUpMutatorContext, props []interface{}) {
// Iterate through each property struct of the module extracting the contents of all properties
- // tagged with `android:"path"`.
+ // tagged with `android:"path"` or one of the variant-specifying tags.
var pathProperties []string
+ var pathDeviceFirstProperties []string
+ var pathDeviceCommonProperties []string
+ var pathCommonOsProperties []string
for _, ps := range props {
- pathProperties = append(pathProperties, pathPropertiesForPropertyStruct(ctx, ps)...)
+ pathProperties = append(pathProperties, taggedPropertiesForPropertyStruct(ctx, ps, "path")...)
+ pathDeviceFirstProperties = append(pathDeviceFirstProperties, taggedPropertiesForPropertyStruct(ctx, ps, "path_device_first")...)
+ pathDeviceCommonProperties = append(pathDeviceCommonProperties, taggedPropertiesForPropertyStruct(ctx, ps, "path_device_common")...)
+ pathCommonOsProperties = append(pathCommonOsProperties, taggedPropertiesForPropertyStruct(ctx, ps, "path_common_os")...)
}
// Remove duplicates to avoid multiple dependencies.
pathProperties = FirstUniqueStrings(pathProperties)
+ pathDeviceFirstProperties = FirstUniqueStrings(pathDeviceFirstProperties)
+ pathDeviceCommonProperties = FirstUniqueStrings(pathDeviceCommonProperties)
+ pathCommonOsProperties = FirstUniqueStrings(pathCommonOsProperties)
// Add dependencies to anything that is a module reference.
for _, s := range pathProperties {
@@ -59,12 +72,35 @@ func addPathDepsForProps(ctx BottomUpMutatorContext, props []interface{}) {
ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(m, t), m)
}
}
+ // For properties tagged "path_device_first", use the first arch device variant when adding
+ // dependencies. This allows host modules to have some properties that add dependencies on
+ // device modules.
+ for _, s := range pathDeviceFirstProperties {
+ if m, t := SrcIsModuleWithTag(s); m != "" {
+ ctx.AddVariationDependencies(ctx.Config().AndroidFirstDeviceTarget.Variations(), sourceOrOutputDepTag(m, t), m)
+ }
+ }
+ // properties tagged "path_device_common" get the device common variant
+ for _, s := range pathDeviceCommonProperties {
+ if m, t := SrcIsModuleWithTag(s); m != "" {
+ ctx.AddVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), sourceOrOutputDepTag(m, t), m)
+ }
+ }
+ // properties tagged "path_device_common" get the device common variant
+ for _, s := range pathCommonOsProperties {
+ if m, t := SrcIsModuleWithTag(s); m != "" {
+ ctx.AddVariationDependencies([]blueprint.Variation{
+ {Mutator: "os", Variation: "common_os"},
+ {Mutator: "arch", Variation: ""},
+ }, sourceOrOutputDepTag(m, t), m)
+ }
+ }
}
-// pathPropertiesForPropertyStruct uses the indexes of properties that are tagged with
-// android:"path" to extract all their values from a property struct, returning them as a single
+// taggedPropertiesForPropertyStruct uses the indexes of properties that are tagged with
+// android:"tagValue" to extract all their values from a property struct, returning them as a single
// slice of strings.
-func pathPropertiesForPropertyStruct(ctx BottomUpMutatorContext, ps interface{}) []string {
+func taggedPropertiesForPropertyStruct(ctx BottomUpMutatorContext, ps interface{}, tagValue string) []string {
v := reflect.ValueOf(ps)
if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {
panic(fmt.Errorf("type %s is not a pointer to a struct", v.Type()))
@@ -79,7 +115,7 @@ func pathPropertiesForPropertyStruct(ctx BottomUpMutatorContext, ps interface{})
v = v.Elem()
// Get or create the list of indexes of properties that are tagged with `android:"path"`.
- pathPropertyIndexes := pathPropertyIndexesForPropertyStruct(ps)
+ pathPropertyIndexes := taggedPropertyIndexesForPropertyStruct(ps, tagValue)
var ret []string
@@ -172,12 +208,20 @@ func isSliceOfStruct(v reflect.Value) bool {
var pathPropertyIndexesCache OncePer
-// pathPropertyIndexesForPropertyStruct returns a list of all of the indexes of properties in
-// property struct type that are tagged with `android:"path"`. Each index is a []int suitable for
-// passing to reflect.Value.FieldByIndex. The value is cached in a global cache by type.
-func pathPropertyIndexesForPropertyStruct(ps interface{}) [][]int {
- key := NewCustomOnceKey(reflect.TypeOf(ps))
+// taggedPropertyIndexesForPropertyStruct returns a list of all of the indexes of properties in
+// property struct type that are tagged with `android:"tagValue"`. Each index is a []int suitable
+// for passing to reflect.Value.FieldByIndex. The value is cached in a global cache by type and
+// tagValue.
+func taggedPropertyIndexesForPropertyStruct(ps interface{}, tagValue string) [][]int {
+ type pathPropertyIndexesOnceKey struct {
+ propStructType reflect.Type
+ tagValue string
+ }
+ key := NewCustomOnceKey(pathPropertyIndexesOnceKey{
+ propStructType: reflect.TypeOf(ps),
+ tagValue: tagValue,
+ })
return pathPropertyIndexesCache.Once(key, func() interface{} {
- return proptools.PropertyIndexesWithTag(ps, "android", "path")
+ return proptools.PropertyIndexesWithTag(ps, "android", tagValue)
}).([][]int)
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 68978b2e8..bf4158c42 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -11342,7 +11342,7 @@ func TestAconfifDeclarationsValidation(t *testing.T) {
}
filegroup {
name: "qux-filegroup",
- srcs: [
+ device_common_srcs: [
":qux-lib{.generated_srcjars}",
],
}
diff --git a/bpf/libbpf/libbpf_prog_test.go b/bpf/libbpf/libbpf_prog_test.go
index f4f51672f..7f3653df9 100644
--- a/bpf/libbpf/libbpf_prog_test.go
+++ b/bpf/libbpf/libbpf_prog_test.go
@@ -47,6 +47,7 @@ func TestLibbpfProgDataDependency(t *testing.T) {
cc_test {
name: "vts_test_binary_bpf_module",
+ compile_multilib: "first",
srcs: ["BpfTest.cpp"],
data: [":bpf.o"],
gtest: false,
diff --git a/cc/cc.go b/cc/cc.go
index 9c514eeb7..52bf669fb 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -119,9 +119,10 @@ type Deps struct {
ObjFiles []string
- GeneratedSources []string
- GeneratedHeaders []string
- GeneratedDeps []string
+ GeneratedSources []string
+ GeneratedHeaders []string
+ DeviceFirstGeneratedHeaders []string
+ GeneratedDeps []string
ReexportGeneratedHeaders []string
@@ -2609,6 +2610,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
actx.AddDependency(c, depTag, gen)
}
+ for _, gen := range deps.DeviceFirstGeneratedHeaders {
+ depTag := genHeaderDepTag
+ actx.AddVariationDependencies(ctx.Config().AndroidFirstDeviceTarget.Variations(), depTag, gen)
+ }
+
crtVariations := GetCrtVariations(ctx, c)
actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...)
for _, crt := range deps.CrtBegin {
diff --git a/cc/compiler.go b/cc/compiler.go
index 7bba962eb..88d97aac8 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -100,6 +100,11 @@ type BaseCompilerProperties struct {
// of genrule modules.
Generated_headers proptools.Configurable[[]string] `android:"arch_variant,variant_prepend"`
+ // Same as generated_headers, but the dependencies will be added based on the first supported
+ // arch variant and the device os variant. This can be useful for creating a host tool that
+ // embeds a copy of a device tool, that it then extracts and pushes to a device at runtime.
+ Device_first_generated_headers proptools.Configurable[[]string] `android:"arch_variant,variant_prepend"`
+
// pass -frtti instead of -fno-rtti
Rtti *bool `android:"arch_variant"`
@@ -294,6 +299,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps.GeneratedSources = append(deps.GeneratedSources, compiler.Properties.Generated_sources...)
deps.GeneratedSources = removeListFromList(deps.GeneratedSources, compiler.Properties.Exclude_generated_sources)
deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers.GetOrDefault(ctx, nil)...)
+ deps.DeviceFirstGeneratedHeaders = append(deps.DeviceFirstGeneratedHeaders, compiler.Properties.Device_first_generated_headers.GetOrDefault(ctx, nil)...)
deps.AidlLibs = append(deps.AidlLibs, compiler.Properties.Aidl.Libs...)
android.ProtoDeps(ctx, &compiler.Proto)
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 0aa9d4ba1..8a974c0f0 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -347,6 +347,7 @@ func (fuzzBin *fuzzBinary) install(ctx ModuleContext, file android.Path) {
func PackageFuzzModule(ctx android.ModuleContext, fuzzPackagedModule fuzz.FuzzPackagedModule, pctx android.PackageContext) fuzz.FuzzPackagedModule {
fuzzPackagedModule.Corpus = android.PathsForModuleSrc(ctx, fuzzPackagedModule.FuzzProperties.Corpus)
+ fuzzPackagedModule.Corpus = append(fuzzPackagedModule.Corpus, android.PathsForModuleSrc(ctx, fuzzPackagedModule.FuzzProperties.Device_common_corpus)...)
fuzzPackagedModule.Data = android.PathsForModuleSrc(ctx, fuzzPackagedModule.FuzzProperties.Data)
diff --git a/cc/test.go b/cc/test.go
index f5bb7610c..ae7388628 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -15,10 +15,11 @@
package cc
import (
- "github.com/google/blueprint/proptools"
"path/filepath"
"strconv"
+ "github.com/google/blueprint/proptools"
+
"android/soong/android"
"android/soong/tradefed"
)
@@ -82,6 +83,16 @@ type TestBinaryProperties struct {
// the test
Data []string `android:"path,arch_variant"`
+ // Same as data, but adds depedencies on modules using the device's os variant, and common
+ // architecture's variant. Can be useful to add device-built apps to the data of a host
+ // test.
+ Device_common_data []string `android:"path_device_common"`
+
+ // Same as data, but adds depedencies on modules using the device's os variant, and the device's
+ // first architecture's variant. Can be useful to add device-built apps to the data of a host
+ // test.
+ Device_first_data []string `android:"path_device_first"`
+
// list of shared library modules that should be installed alongside the test
Data_libs []string `android:"arch_variant"`
@@ -324,6 +335,8 @@ func (test *testBinary) installerProps() []interface{} {
func (test *testBinary) install(ctx ModuleContext, file android.Path) {
dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data)
+ dataSrcPaths = append(dataSrcPaths, android.PathsForModuleSrc(ctx, test.Properties.Device_common_data)...)
+ dataSrcPaths = append(dataSrcPaths, android.PathsForModuleSrc(ctx, test.Properties.Device_first_data)...)
for _, dataSrcPath := range dataSrcPaths {
test.data = append(test.data, android.DataPath{SrcPath: dataSrcPath})
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go
index e796ab9b3..9d9392596 100644
--- a/filesystem/bootimg.go
+++ b/filesystem/bootimg.go
@@ -75,7 +75,7 @@ type bootimgProperties struct {
// Path to the private key that avbtool will use to sign this filesystem image.
// TODO(jiyong): allow apex_key to be specified here
- Avb_private_key *string `android:"path"`
+ Avb_private_key *string `android:"path_device_first"`
// Hash and signing algorithm for avbtool. Default is SHA256_RSA4096.
Avb_algorithm *string
diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go
index 1d647965a..51ba7c984 100644
--- a/filesystem/vbmeta.go
+++ b/filesystem/vbmeta.go
@@ -98,7 +98,7 @@ type chainedPartitionProperties struct {
func vbmetaFactory() android.Module {
module := &vbmeta{}
module.AddProperties(&module.properties)
- android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
return module
}
diff --git a/fuzz/fuzz_common.go b/fuzz/fuzz_common.go
index 42fd22886..aa393a2d5 100644
--- a/fuzz/fuzz_common.go
+++ b/fuzz/fuzz_common.go
@@ -411,6 +411,11 @@ type FuzzProperties struct {
// Optional list of seed files to be installed to the fuzz target's output
// directory.
Corpus []string `android:"path"`
+
+ // Same as corpus, but adds dependencies on module references using the device's os variant
+ // and the common arch variant.
+ Device_common_corpus []string `android:"path_device_common"`
+
// Optional list of data files to be installed to the fuzz target's output
// directory. Directory structure relative to the module is preserved.
Data []string `android:"path"`
diff --git a/genrule/genrule.go b/genrule/genrule.go
index f2a761cde..4ba5b6cc1 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -147,6 +147,18 @@ type generatorProperties struct {
// list of input files
Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
+ // Same as srcs, but will add dependencies on modules via a device os variation and the device's
+ // first supported arch's variation. Can be used to add a dependency from a host genrule to
+ // a device module.
+ Device_first_srcs proptools.Configurable[[]string] `android:"path_device_first"`
+
+ // Same as srcs, but will add dependencies on modules via a device os variation and the common
+ // arch variation. Can be used to add a dependency from a host genrule to a device module.
+ Device_common_srcs proptools.Configurable[[]string] `android:"path_device_common"`
+
+ // Same as srcs, but will add dependencies on modules via a common_os os variation.
+ Common_os_srcs proptools.Configurable[[]string] `android:"path_common_os"`
+
// input files to exclude
Exclude_srcs []string `android:"path,arch_variant"`
@@ -289,7 +301,15 @@ func isModuleInBuildNumberAllowlist(ctx android.ModuleContext) bool {
// approach zero; there should be no genrule action registration done directly
// by Soong logic in the mixed-build case.
func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
- g.subName = ctx.ModuleSubDir()
+ // Add the variant as a suffix to the make modules to create, so that the make modules
+ // don't conflict because make doesn't know about variants. However, this causes issues with
+ // tracking required dependencies as the required property in soong is passed straight to make
+ // without accounting for these suffixes. To make it a little easier to work with, don't use
+ // a suffix for android_common variants so that java_genrules look like regular 1-variant
+ // genrules to make.
+ if ctx.ModuleSubDir() != "android_common" {
+ g.subName = ctx.ModuleSubDir()
+ }
if len(g.properties.Export_include_dirs) > 0 {
for _, dir := range g.properties.Export_include_dirs {
@@ -431,6 +451,9 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
}
srcs := g.properties.Srcs.GetOrDefault(ctx, nil)
srcFiles := addLabelsForInputs("srcs", srcs, g.properties.Exclude_srcs)
+ srcFiles = append(srcFiles, addLabelsForInputs("device_first_srcs", g.properties.Device_first_srcs.GetOrDefault(ctx, nil), nil)...)
+ srcFiles = append(srcFiles, addLabelsForInputs("device_common_srcs", g.properties.Device_common_srcs.GetOrDefault(ctx, nil), nil)...)
+ srcFiles = append(srcFiles, addLabelsForInputs("common_os_srcs", g.properties.Common_os_srcs.GetOrDefault(ctx, nil), nil)...)
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcFiles.Strings()})
var copyFrom android.Paths
diff --git a/java/app.go b/java/app.go
index e112e93f7..22e367e9c 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1438,6 +1438,8 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.testConfig = a.FixTestConfig(ctx, testConfig)
a.extraTestConfigs = android.PathsForModuleSrc(ctx, a.testProperties.Test_options.Extra_test_configs)
a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
+ a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_common_data)...)
+ a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_first_data)...)
android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{})
android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{
InstalledFiles: a.data,
diff --git a/java/base.go b/java/base.go
index a9399cbd3..efc6a748b 100644
--- a/java/base.go
+++ b/java/base.go
@@ -71,6 +71,15 @@ type CommonProperties struct {
// list of files that should be excluded from java_resources and java_resource_dirs
Exclude_java_resources []string `android:"path,arch_variant"`
+ // Same as java_resources, but modules added here will use the device variant. Can be useful
+ // for making a host test that tests the contents of a device built app.
+ Device_common_java_resources []string `android:"path_device_common"`
+
+ // Same as java_resources, but modules added here will use the device's os variant and the
+ // device's first architecture variant. Can be useful for making a host test that tests the
+ // contents of a native device built app.
+ Device_first_java_resources []string `android:"path_device_first"`
+
// list of module-specific flags that will be used for javac compiles
Javacflags []string `android:"arch_variant"`
@@ -1482,6 +1491,10 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
dirArgs, dirDeps := ResourceDirsToJarArgs(ctx, j.properties.Java_resource_dirs,
j.properties.Exclude_java_resource_dirs, j.properties.Exclude_java_resources)
fileArgs, fileDeps := ResourceFilesToJarArgs(ctx, j.properties.Java_resources, j.properties.Exclude_java_resources)
+ fileArgs2, fileDeps2 := ResourceFilesToJarArgs(ctx, j.properties.Device_common_java_resources, nil)
+ fileArgs3, fileDeps3 := ResourceFilesToJarArgs(ctx, j.properties.Device_first_java_resources, nil)
+ fileArgs = slices.Concat(fileArgs, fileArgs2, fileArgs3)
+ fileDeps = slices.Concat(fileDeps, fileDeps2, fileDeps3)
extraArgs, extraDeps := resourcePathsToJarArgs(j.extraResources), j.extraResources
var resArgs []string
diff --git a/java/fuzz.go b/java/fuzz.go
index e5f1f04ee..90f09a899 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -110,6 +110,9 @@ func (j *JavaFuzzTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if j.fuzzPackagedModule.FuzzProperties.Corpus != nil {
j.fuzzPackagedModule.Corpus = android.PathsForModuleSrc(ctx, j.fuzzPackagedModule.FuzzProperties.Corpus)
}
+ if j.fuzzPackagedModule.FuzzProperties.Device_common_corpus != nil {
+ j.fuzzPackagedModule.Corpus = append(j.fuzzPackagedModule.Corpus, android.PathsForModuleSrc(ctx, j.fuzzPackagedModule.FuzzProperties.Device_common_corpus)...)
+ }
if j.fuzzPackagedModule.FuzzProperties.Data != nil {
j.fuzzPackagedModule.Data = android.PathsForModuleSrc(ctx, j.fuzzPackagedModule.FuzzProperties.Data)
}
diff --git a/java/java.go b/java/java.go
index 288042b42..14e31534d 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1291,6 +1291,16 @@ type testProperties struct {
// the test
Data []string `android:"path"`
+ // Same as data, but will add dependencies on modules using the device's os variation and
+ // the common arch variation. Useful for a host test that wants to embed a module built for
+ // device.
+ Device_common_data []string `android:"path_device_common"`
+
+ // same as data, but adds dependencies using the device's os variation and the device's first
+ // architecture's variation. Can be used to add a module built for device to the data of a
+ // host test.
+ Device_first_data []string `android:"path_device_first"`
+
// Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
// doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
// explicitly.
@@ -1581,6 +1591,8 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext,
})
j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data)
+ j.data = append(j.data, android.PathsForModuleSrc(ctx, j.testProperties.Device_common_data)...)
+ j.data = append(j.data, android.PathsForModuleSrc(ctx, j.testProperties.Device_first_data)...)
j.extraTestConfigs = android.PathsForModuleSrc(ctx, j.testProperties.Test_options.Extra_test_configs)
diff --git a/java/java_resources.go b/java/java_resources.go
index b0dc5a1cf..c525233d3 100644
--- a/java/java_resources.go
+++ b/java/java_resources.go
@@ -17,6 +17,7 @@ package java
import (
"fmt"
"path/filepath"
+ "slices"
"strings"
"github.com/google/blueprint/pathtools"
@@ -99,10 +100,7 @@ func ResourceDirsToJarArgs(ctx android.ModuleContext,
// that should not be treated as resources (including *.java).
func ResourceFilesToJarArgs(ctx android.ModuleContext,
res, exclude []string) (args []string, deps android.Paths) {
-
- exclude = append([]string(nil), exclude...)
- exclude = append(exclude, resourceExcludes...)
- return resourceFilesToJarArgs(ctx, res, exclude)
+ return resourceFilesToJarArgs(ctx, res, slices.Concat(exclude, resourceExcludes))
}
func resourceFilesToJarArgs(ctx android.ModuleContext,
diff --git a/java/java_test.go b/java/java_test.go
index 51cfdabb0..54eb3e14e 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1173,7 +1173,7 @@ func TestJavaLibraryOutputFiles(t *testing.T) {
filegroup {
name: "core-jar",
- srcs: [":core{.jar}"],
+ device_common_srcs: [":core{.jar}"],
}
`),
})
@@ -1189,7 +1189,7 @@ func TestJavaImportOutputFiles(t *testing.T) {
filegroup {
name: "core-jar",
- srcs: [":core{.jar}"],
+ device_common_srcs: [":core{.jar}"],
}
`),
})
diff --git a/java/robolectric.go b/java/robolectric.go
index 30c720352..fb820efed 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -149,6 +149,8 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
HostTemplate: "${RobolectricTestConfigTemplate}",
})
r.data = android.PathsForModuleSrc(ctx, r.testProperties.Data)
+ r.data = append(r.data, android.PathsForModuleSrc(ctx, r.testProperties.Device_common_data)...)
+ r.data = append(r.data, android.PathsForModuleSrc(ctx, r.testProperties.Device_first_data)...)
var ok bool
var instrumentedApp *AndroidApp
@@ -208,6 +210,11 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
installPath := android.PathForModuleInstall(ctx, r.BaseModuleName())
var installDeps android.InstallPaths
+ for _, data := range r.data {
+ installedData := ctx.InstallFile(installPath, data.Rel(), data)
+ installDeps = append(installDeps, installedData)
+ }
+
if manifest != nil {
r.data = append(r.data, manifest)
installedManifest := ctx.InstallFile(installPath, ctx.ModuleName()+"-AndroidManifest.xml", manifest)
@@ -228,11 +235,6 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
installedConfig := ctx.InstallFile(installPath, ctx.ModuleName()+".config", r.testConfig)
installDeps = append(installDeps, installedConfig)
- for _, data := range android.PathsForModuleSrc(ctx, r.testProperties.Data) {
- installedData := ctx.InstallFile(installPath, data.Rel(), data)
- installDeps = append(installDeps, installedData)
- }
-
soInstallPath := installPath.Join(ctx, getLibPath(r.forceArchType))
for _, jniLib := range collectTransitiveJniDeps(ctx) {
installJni := ctx.InstallFile(soInstallPath, jniLib.path.Base(), jniLib.path)
diff --git a/python/python.go b/python/python.go
index 01ac86c71..d3e5743b5 100644
--- a/python/python.go
+++ b/python/python.go
@@ -90,6 +90,11 @@ type BaseProperties struct {
// the test. the file extension can be arbitrary except for (.py).
Data []string `android:"path,arch_variant"`
+ // Same as data, but will add dependencies on modules using the device's os variation and
+ // the common arch variation. Useful for a host test that wants to embed a module built for
+ // device.
+ Device_common_data []string `android:"path_device_common"`
+
// list of java modules that provide data that should be installed alongside the test.
Java_data []string
@@ -451,6 +456,7 @@ func (p *PythonLibraryModule) GenerateAndroidBuildActions(ctx android.ModuleCont
// expand data files from "data" property.
expandedData := android.PathsForModuleSrc(ctx, p.properties.Data)
+ expandedData = append(expandedData, android.PathsForModuleSrc(ctx, p.properties.Device_common_data)...)
// Emulate the data property for java_data dependencies.
for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) {
diff --git a/rust/test.go b/rust/test.go
index b7ddd06a3..20ccfb31c 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -46,6 +46,9 @@ type TestProperties struct {
// the test
Data []string `android:"path,arch_variant"`
+ // Same as data, but will add dependencies on the device's
+ Device_common_data []string `android:"path_device_common"`
+
// list of shared library modules that should be installed alongside the test
Data_libs []string `android:"arch_variant"`
@@ -143,6 +146,7 @@ func (test *testDecorator) install(ctx ModuleContext) {
})
dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data)
+ dataSrcPaths = append(dataSrcPaths, android.PathsForModuleSrc(ctx, test.Properties.Device_common_data)...)
ctx.VisitDirectDepsWithTag(dataLibDepTag, func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
diff --git a/scripts/hiddenapi/Android.bp b/scripts/hiddenapi/Android.bp
index 43edf447c..061af1981 100644
--- a/scripts/hiddenapi/Android.bp
+++ b/scripts/hiddenapi/Android.bp
@@ -27,6 +27,12 @@ python_binary_host {
libs: [
"signature_trie",
],
+ target: {
+ windows: {
+ // go modules (bpmodify) don't support windows
+ enabled: false,
+ },
+ },
}
python_test_host {
@@ -44,6 +50,12 @@ python_test_host {
test_options: {
unit_test: true,
},
+ target: {
+ windows: {
+ // go modules (bpmodify) don't support windows
+ enabled: false,
+ },
+ },
}
python_binary_host {
diff --git a/sdk/genrule_test.go b/sdk/genrule_test.go
index 6e52a3db0..bf67795a7 100644
--- a/sdk/genrule_test.go
+++ b/sdk/genrule_test.go
@@ -23,21 +23,14 @@ import (
)
func TestSdkGenrule(t *testing.T) {
- // Test that an sdk_genrule can depend on an sdk, and that a genrule can depend on an sdk_genrule
+ // Test that a genrule can depend on an sdk if using common_os_srcs
bp := `
sdk {
name: "my_sdk",
}
- sdk_genrule {
- name: "my_sdk_genrule",
- tool_files: ["tool"],
- cmd: "$(location tool) $(in) $(out)",
- srcs: [":my_sdk"],
- out: ["out"],
- }
genrule {
name: "my_regular_genrule",
- srcs: [":my_sdk_genrule"],
+ common_os_srcs: [":my_sdk"],
out: ["out"],
cmd: "cp $(in) $(out)",
}
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 15e13dbcb..4db163cdf 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -1724,7 +1724,7 @@ func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) {
filegroup {
name: "mygroup",
- srcs: [":myjavalib{.doctags}"],
+ device_common_srcs: [":myjavalib{.doctags}"],
}
`)
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index 2e48d83e6..ac27df820 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -120,6 +120,16 @@ type TestProperties struct {
// the test.
Data []string `android:"path,arch_variant"`
+ // same as data, but adds dependencies using the device's os variation and the common
+ // architecture's variation. Can be used to add a module built for device to the data of a
+ // host test.
+ Device_common_data []string `android:"path_device_common"`
+
+ // same as data, but adds dependencies using the device's os variation and the device's first
+ // architecture's variation. Can be used to add a module built for device to the data of a
+ // host test.
+ Device_first_data []string `android:"path_device_first"`
+
// Add RootTargetPreparer to auto generated test config. This guarantees the test to run
// with root permission.
Require_root *bool
@@ -407,6 +417,8 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
s.ShBinary.generateAndroidBuildActions(ctx)
expandedData := android.PathsForModuleSrc(ctx, s.testProperties.Data)
+ expandedData = append(expandedData, android.PathsForModuleSrc(ctx, s.testProperties.Device_common_data)...)
+ expandedData = append(expandedData, android.PathsForModuleSrc(ctx, s.testProperties.Device_first_data)...)
// Emulate the data property for java_data dependencies.
for _, javaData := range ctx.GetDirectDepsWithTag(shTestJavaDataTag) {
expandedData = append(expandedData, android.OutputFilesForModule(ctx, javaData, "")...)
diff --git a/tradefed_modules/test_module_config_test.go b/tradefed_modules/test_module_config_test.go
index f76a152eb..cf6c7d17f 100644
--- a/tradefed_modules/test_module_config_test.go
+++ b/tradefed_modules/test_module_config_test.go
@@ -123,24 +123,24 @@ func TestModuleConfigOptions(t *testing.T) {
// Ensure we error for a base we don't support.
func TestModuleConfigWithHostBaseShouldFailWithExplicitMessage(t *testing.T) {
badBp := `
- java_test_host {
- name: "base",
- srcs: ["a.java"],
+ java_test {
+ name: "base",
+ srcs: ["a.java"],
}
- test_module_config {
- name: "derived_test",
- base: "base",
- exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
- include_annotations: ["android.platform.test.annotations.LargeTest"],
- test_suites: ["general-tests"],
- }`
+ test_module_config {
+ name: "derived_test",
+ base: "base",
+ exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
+ include_annotations: ["android.platform.test.annotations.LargeTest"],
+ test_suites: ["general-tests"],
+ }`
android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).ExtendWithErrorHandler(
- android.FixtureExpectsAtLeastOneErrorMatchingPattern("'java_test_host' module used as base, but 'android_test' expected")).
+ android.FixtureExpectsAtLeastOneErrorMatchingPattern("'base' module used as base but it is not a 'android_test' module.")).
RunTestWithBp(t, badBp)
}