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
This commit is contained in:
@@ -28,7 +28,7 @@ type defaultsDependencyTag struct {
|
||||
var DefaultsDepTag defaultsDependencyTag
|
||||
|
||||
type defaultsProperties struct {
|
||||
Defaults []string
|
||||
Defaults proptools.Configurable[[]string]
|
||||
}
|
||||
|
||||
type DefaultableModuleBase struct {
|
||||
@@ -278,13 +278,14 @@ func RegisterDefaultsPreArchMutators(ctx RegisterMutatorsContext) {
|
||||
|
||||
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 @@ func defaultsMutator(ctx TopDownMutatorContext) {
|
||||
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",
|
||||
|
@@ -389,7 +389,7 @@ type commonProperties struct {
|
||||
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 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
||||
}
|
||||
}
|
||||
|
||||
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())
|
||||
|
@@ -722,7 +722,6 @@ test {
|
||||
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 @@ test {
|
||||
foo := result.ModuleForTests("foo", "").Module().base()
|
||||
|
||||
AssertDeepEquals(t, "foo ", tc.expectedProps, foo.propertiesWithValues())
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
65
apex/apex.go
65
apex/apex.go
@@ -86,7 +86,7 @@ type apexBundleProperties struct {
|
||||
|
||||
// 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 @@ type apexBundleProperties struct {
|
||||
// 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 @@ type apexBundleProperties struct {
|
||||
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 @@ type ApexNativeDependencies struct {
|
||||
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 @@ type ApexNativeDependencies struct {
|
||||
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 @@ type ApexNativeDependencies struct {
|
||||
}
|
||||
|
||||
// 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 @@ type apexArchBundleProperties struct {
|
||||
// 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 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeM
|
||||
// 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 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeM
|
||||
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 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
|
||||
// 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 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
// 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 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutato
|
||||
}
|
||||
|
||||
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 @@ func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext
|
||||
Native_shared_libs: []string{"libclang_rt.hwasan"},
|
||||
Tests: nil,
|
||||
Jni_libs: nil,
|
||||
Binaries: nil,
|
||||
}, target, imageVariation)
|
||||
break
|
||||
}
|
||||
@@ -2806,7 +2809,7 @@ func isStaticExecutableAllowed(apex string, exec string) bool {
|
||||
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 (
|
||||
|
@@ -704,8 +704,9 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
|
||||
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 @@ func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext, defaultReadO
|
||||
}
|
||||
// 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()))
|
||||
|
@@ -139,7 +139,8 @@ type generatorProperties struct {
|
||||
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 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
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 @@ func (g *Module) setOutputFiles(ctx android.ModuleContext) {
|
||||
// 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)
|
||||
|
@@ -694,7 +694,7 @@ func TestGenruleDefaults(t *testing.T) {
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user