Merge changes from topic "avf_apex_android_bp_select" into main
* changes:
Make more apex properties configurable
Make genrule's srcs property configurable
Make some apex properties configurable
Make the vintf_fragments property configurable
Make the defaults property configurable
diff --git a/android/defaults.go b/android/defaults.go
index ff79002..ba26e00 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -28,7 +28,7 @@
var DefaultsDepTag defaultsDependencyTag
type defaultsProperties struct {
- Defaults []string
+ Defaults proptools.Configurable[[]string]
}
type DefaultableModuleBase struct {
@@ -278,13 +278,14 @@
func defaultsDepsMutator(ctx BottomUpMutatorContext) {
if defaultable, ok := ctx.Module().(Defaultable); ok {
- ctx.AddDependency(ctx.Module(), DefaultsDepTag, defaultable.defaults().Defaults...)
+ ctx.AddDependency(ctx.Module(), DefaultsDepTag, defaultable.defaults().Defaults.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)...)
}
}
func defaultsMutator(ctx TopDownMutatorContext) {
if defaultable, ok := ctx.Module().(Defaultable); ok {
- if len(defaultable.defaults().Defaults) > 0 {
+ defaults := defaultable.defaults().Defaults.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)
+ if len(defaults) > 0 {
var defaultsList []Defaults
seen := make(map[Defaults]bool)
@@ -294,7 +295,7 @@
if !seen[defaults] {
seen[defaults] = true
defaultsList = append(defaultsList, defaults)
- return len(defaults.defaults().Defaults) > 0
+ return len(defaults.defaults().Defaults.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)) > 0
}
} else {
ctx.PropertyErrorf("defaults", "module %s is not an defaults module",
diff --git a/android/module.go b/android/module.go
index 37e26f9..39c257c 100644
--- a/android/module.go
+++ b/android/module.go
@@ -389,7 +389,7 @@
Init_rc []string `android:"arch_variant,path"`
// VINTF manifest fragments to be installed if this module is installed
- Vintf_fragments []string `android:"path"`
+ Vintf_fragments proptools.Configurable[[]string] `android:"path"`
// names of other modules to install if this module is installed
Required proptools.Configurable[[]string] `android:"arch_variant"`
@@ -1853,7 +1853,7 @@
}
}
- m.vintfFragmentsPaths = PathsForModuleSrc(ctx, m.commonProperties.Vintf_fragments)
+ m.vintfFragmentsPaths = PathsForModuleSrc(ctx, m.commonProperties.Vintf_fragments.GetOrDefault(m.ConfigurableEvaluator(ctx), nil))
vintfDir := PathForModuleInstall(ctx, "etc", "vintf", "manifest")
for _, src := range m.vintfFragmentsPaths {
installedVintfFragment := vintfDir.Join(ctx, src.Base())
diff --git a/android/module_test.go b/android/module_test.go
index 922ea21..829c079 100644
--- a/android/module_test.go
+++ b/android/module_test.go
@@ -722,7 +722,6 @@
propInfo{Name: "Arch.X86_64.A", Type: "string", Value: "x86_64 a"},
propInfo{Name: "B", Type: "bool", Value: "true"},
propInfo{Name: "C", Type: "string slice", Values: []string{"default_c", "c"}},
- propInfo{Name: "Defaults", Type: "string slice", Values: []string{"foo_defaults"}},
propInfo{Name: "Embedded_prop", Type: "string", Value: "a"},
propInfo{Name: "Name", Type: "string", Value: "foo"},
propInfo{Name: "Nested.E", Type: "string", Value: "nested e"},
@@ -746,7 +745,6 @@
foo := result.ModuleForTests("foo", "").Module().base()
AssertDeepEquals(t, "foo ", tc.expectedProps, foo.propertiesWithValues())
-
})
}
}
diff --git a/apex/apex.go b/apex/apex.go
index c1a9d74..4c36458 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -86,7 +86,7 @@
// AndroidManifest.xml file used for the zip container of this APEX bundle. If unspecified,
// a default one is automatically generated.
- AndroidManifest *string `android:"path"`
+ AndroidManifest proptools.Configurable[string] `android:"path,replace_instead_of_append"`
// Determines the file contexts file for setting the security contexts to files in this APEX
// bundle. For platform APEXes, this should points to a file under /system/sepolicy Default:
@@ -104,7 +104,7 @@
// path_or_glob is a path or glob pattern for a file or set of files,
// uid/gid are numerial values of user ID and group ID, mode is octal value
// for the file mode, and cap is hexadecimal value for the capability.
- Canned_fs_config *string `android:"path"`
+ Canned_fs_config proptools.Configurable[string] `android:"path,replace_instead_of_append"`
ApexNativeDependencies
@@ -117,7 +117,8 @@
Bootclasspath_fragments []string
// List of systemserverclasspath fragments that are embedded inside this APEX bundle.
- Systemserverclasspath_fragments []string
+ Systemserverclasspath_fragments proptools.Configurable[[]string]
+ ResolvedSystemserverclasspathFragments []string `blueprint:"mutated"`
// List of java libraries that are embedded inside this APEX bundle.
Java_libs []string
@@ -221,7 +222,8 @@
Rust_dyn_libs []string
// List of native executables that are embedded inside this APEX.
- Binaries []string
+ Binaries proptools.Configurable[[]string]
+ ResolvedBinaries []string `blueprint:"mutated"`
// List of native tests that are embedded inside this APEX.
Tests []string
@@ -230,7 +232,8 @@
Filesystems []string
// List of prebuilt_etcs that are embedded inside this APEX bundle.
- Prebuilts []string
+ Prebuilts proptools.Configurable[[]string]
+ ResolvedPrebuilts []string `blueprint:"mutated"`
// List of native libraries to exclude from this APEX.
Exclude_native_shared_libs []string
@@ -255,14 +258,14 @@
}
// Merge combines another ApexNativeDependencies into this one
-func (a *ApexNativeDependencies) Merge(b ApexNativeDependencies) {
+func (a *ApexNativeDependencies) Merge(ctx android.BaseMutatorContext, b ApexNativeDependencies) {
a.Native_shared_libs = append(a.Native_shared_libs, b.Native_shared_libs...)
a.Jni_libs = append(a.Jni_libs, b.Jni_libs...)
a.Rust_dyn_libs = append(a.Rust_dyn_libs, b.Rust_dyn_libs...)
- a.Binaries = append(a.Binaries, b.Binaries...)
+ a.ResolvedBinaries = append(a.ResolvedBinaries, b.Binaries.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)...)
a.Tests = append(a.Tests, b.Tests...)
a.Filesystems = append(a.Filesystems, b.Filesystems...)
- a.Prebuilts = append(a.Prebuilts, b.Prebuilts...)
+ a.ResolvedPrebuilts = append(a.ResolvedPrebuilts, b.Prebuilts.GetOrDefault(ctx.Module().ConfigurableEvaluator(ctx), nil)...)
a.Exclude_native_shared_libs = append(a.Exclude_native_shared_libs, b.Exclude_native_shared_libs...)
a.Exclude_jni_libs = append(a.Exclude_jni_libs, b.Exclude_jni_libs...)
@@ -338,10 +341,10 @@
// base apex.
type overridableProperties struct {
// List of APKs that are embedded inside this APEX.
- Apps []string
+ Apps proptools.Configurable[[]string]
// List of prebuilt files that are embedded inside this APEX bundle.
- Prebuilts []string
+ Prebuilts proptools.Configurable[[]string]
// List of BPF programs inside this APEX bundle.
Bpfs []string
@@ -715,7 +718,7 @@
// this module. This is required since arch variant of an APEX bundle is 'common' but it is
// 'arm' or 'arm64' for native shared libs.
ctx.AddFarVariationDependencies(binVariations, executableTag,
- android.RemoveListFromList(nativeModules.Binaries, nativeModules.Exclude_binaries)...)
+ android.RemoveListFromList(nativeModules.ResolvedBinaries, nativeModules.Exclude_binaries)...)
ctx.AddFarVariationDependencies(binVariations, testTag,
android.RemoveListFromList(nativeModules.Tests, nativeModules.Exclude_tests)...)
ctx.AddFarVariationDependencies(libVariations, jniLibTag,
@@ -727,7 +730,7 @@
ctx.AddFarVariationDependencies(target.Variations(), fsTag,
android.RemoveListFromList(nativeModules.Filesystems, nativeModules.Exclude_filesystems)...)
ctx.AddFarVariationDependencies(target.Variations(), prebuiltTag,
- android.RemoveListFromList(nativeModules.Prebuilts, nativeModules.Exclude_prebuilts)...)
+ android.RemoveListFromList(nativeModules.ResolvedPrebuilts, nativeModules.Exclude_prebuilts)...)
}
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
@@ -782,20 +785,19 @@
// Add native modules targeting both ABIs. When multilib.* is omitted for
// native_shared_libs/jni_libs/tests, it implies multilib.both
- deps.Merge(a.properties.Multilib.Both)
- deps.Merge(ApexNativeDependencies{
+ deps.Merge(ctx, a.properties.Multilib.Both)
+ deps.Merge(ctx, ApexNativeDependencies{
Native_shared_libs: a.properties.Native_shared_libs,
Tests: a.properties.Tests,
Jni_libs: a.properties.Jni_libs,
- Binaries: nil,
})
// Add native modules targeting the first ABI When multilib.* is omitted for
// binaries, it implies multilib.first
isPrimaryAbi := i == 0
if isPrimaryAbi {
- deps.Merge(a.properties.Multilib.First)
- deps.Merge(ApexNativeDependencies{
+ deps.Merge(ctx, a.properties.Multilib.First)
+ deps.Merge(ctx, ApexNativeDependencies{
Native_shared_libs: nil,
Tests: nil,
Jni_libs: nil,
@@ -806,27 +808,27 @@
// Add native modules targeting either 32-bit or 64-bit ABI
switch target.Arch.ArchType.Multilib {
case "lib32":
- deps.Merge(a.properties.Multilib.Lib32)
- deps.Merge(a.properties.Multilib.Prefer32)
+ deps.Merge(ctx, a.properties.Multilib.Lib32)
+ deps.Merge(ctx, a.properties.Multilib.Prefer32)
case "lib64":
- deps.Merge(a.properties.Multilib.Lib64)
+ deps.Merge(ctx, a.properties.Multilib.Lib64)
if !has32BitTarget {
- deps.Merge(a.properties.Multilib.Prefer32)
+ deps.Merge(ctx, a.properties.Multilib.Prefer32)
}
}
// Add native modules targeting a specific arch variant
switch target.Arch.ArchType {
case android.Arm:
- deps.Merge(a.archProperties.Arch.Arm.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.Arm.ApexNativeDependencies)
case android.Arm64:
- deps.Merge(a.archProperties.Arch.Arm64.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.Arm64.ApexNativeDependencies)
case android.Riscv64:
- deps.Merge(a.archProperties.Arch.Riscv64.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.Riscv64.ApexNativeDependencies)
case android.X86:
- deps.Merge(a.archProperties.Arch.X86.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.X86.ApexNativeDependencies)
case android.X86_64:
- deps.Merge(a.archProperties.Arch.X86_64.ApexNativeDependencies)
+ deps.Merge(ctx, a.archProperties.Arch.X86_64.ApexNativeDependencies)
default:
panic(fmt.Errorf("unsupported arch %v\n", ctx.Arch().ArchType))
}
@@ -840,11 +842,13 @@
}
}
+ a.properties.ResolvedSystemserverclasspathFragments = a.properties.Systemserverclasspath_fragments.GetOrDefault(a.ConfigurableEvaluator(ctx), nil)
+
// Common-arch dependencies come next
commonVariation := ctx.Config().AndroidCommonTarget.Variations()
ctx.AddFarVariationDependencies(commonVariation, rroTag, a.properties.Rros...)
ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...)
- ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.Systemserverclasspath_fragments...)
+ ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.ResolvedSystemserverclasspathFragments...)
ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...)
ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...)
ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...)
@@ -857,9 +861,9 @@
}
commonVariation := ctx.Config().AndroidCommonTarget.Variations()
- ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps...)
+ ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps.GetOrDefault(a.ConfigurableEvaluator(ctx), nil)...)
ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.overridableProperties.Bpfs...)
- if prebuilts := a.overridableProperties.Prebuilts; len(prebuilts) > 0 {
+ if prebuilts := a.overridableProperties.Prebuilts.GetOrDefault(a.ConfigurableEvaluator(ctx), nil); len(prebuilts) > 0 {
// For prebuilt_etc, use the first variant (64 on 64/32bit device, 32 on 32bit device)
// regardless of the TARGET_PREFER_* setting. See b/144532908
arches := ctx.DeviceConfig().Arches()
@@ -1492,7 +1496,6 @@
Native_shared_libs: []string{"libclang_rt.hwasan"},
Tests: nil,
Jni_libs: nil,
- Binaries: nil,
}, target, imageVariation)
break
}
@@ -2806,7 +2809,7 @@
func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...)
dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...)
- dpInfo.Deps = append(dpInfo.Deps, a.properties.Systemserverclasspath_fragments...)
+ dpInfo.Deps = append(dpInfo.Deps, a.properties.ResolvedSystemserverclasspathFragments...)
}
var (
diff --git a/apex/builder.go b/apex/builder.go
index 763ce4d..6f645ab 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -704,8 +704,9 @@
optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName)
}
- if a.properties.AndroidManifest != nil {
- androidManifestFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.AndroidManifest))
+ androidManifest := a.properties.AndroidManifest.GetOrDefault(a.ConfigurableEvaluator(ctx), "")
+ if androidManifest != "" {
+ androidManifestFile := android.PathForModuleSrc(ctx, androidManifest)
if a.testApex {
androidManifestFile = markManifestTestOnly(ctx, androidManifestFile)
@@ -1195,8 +1196,9 @@
}
// Custom fs_config is "appended" to the last so that entries from the file are preferred
// over default ones set above.
- if a.properties.Canned_fs_config != nil {
- cmd.Text("cat").Input(android.PathForModuleSrc(ctx, *a.properties.Canned_fs_config))
+ customFsConfig := a.properties.Canned_fs_config.GetOrDefault(a.ConfigurableEvaluator(ctx), "")
+ if customFsConfig != "" {
+ cmd.Text("cat").Input(android.PathForModuleSrc(ctx, customFsConfig))
}
cmd.Text(")").FlagWithOutput("> ", cannedFsConfig)
builder.Build("generateFsConfig", fmt.Sprintf("Generating canned fs config for %s", a.BaseModuleName()))
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 5b40768..08d857d 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -139,7 +139,8 @@
Export_include_dirs []string
// list of input files
- Srcs []string `android:"path,arch_variant"`
+ Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
+ ResolvedSrcs []string `blueprint:"mutated"`
// input files to exclude
Exclude_srcs []string `android:"path,arch_variant"`
@@ -382,7 +383,8 @@
}
return srcFiles
}
- srcFiles := addLabelsForInputs("srcs", g.properties.Srcs, g.properties.Exclude_srcs)
+ g.properties.ResolvedSrcs = g.properties.Srcs.GetOrDefault(g.ConfigurableEvaluator(ctx), nil)
+ srcFiles := addLabelsForInputs("srcs", g.properties.ResolvedSrcs, g.properties.Exclude_srcs)
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcFiles.Strings()})
var copyFrom android.Paths
@@ -589,7 +591,7 @@
// Collect information for opening IDE project files in java/jdeps.go.
func (g *Module) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Srcs = append(dpInfo.Srcs, g.Srcs().Strings()...)
- for _, src := range g.properties.Srcs {
+ for _, src := range g.properties.ResolvedSrcs {
if strings.HasPrefix(src, ":") {
src = strings.Trim(src, ":")
dpInfo.Deps = append(dpInfo.Deps, src)
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index fba9aec..444aedb 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -694,7 +694,7 @@
android.AssertStringEquals(t, "cmd", expectedCmd, gen.rawCommands[0])
expectedSrcs := []string{"in1"}
- android.AssertDeepEquals(t, "srcs", expectedSrcs, gen.properties.Srcs)
+ android.AssertDeepEquals(t, "srcs", expectedSrcs, gen.properties.ResolvedSrcs)
}
func TestGenruleAllowMissingDependencies(t *testing.T) {