Make the enabled property configurable This allows using select statements with it. Bug: 323382414 Test: m nothing --no-skip-soong-tests Change-Id: I6f3efaaa3d82505e38a91ee4ba0e18e404360191 Merged-In: If355d24506e3f117d27b21442a6c02bca3402dc7
diff --git a/android/Android.bp b/android/Android.bp index f130d3a..fa78e15 100644 --- a/android/Android.bp +++ b/android/Android.bp
@@ -41,6 +41,7 @@ "buildinfo_prop.go", "config.go", "test_config.go", + "configurable_properties.go", "configured_jars.go", "csuite_config.go", "deapexer.go",
diff --git a/android/androidmk.go b/android/androidmk.go index 07f7c58..0a366e1 100644 --- a/android/androidmk.go +++ b/android/androidmk.go
@@ -849,7 +849,7 @@ mod blueprint.Module, provider AndroidMkDataProvider) error { amod := mod.(Module).base() - if shouldSkipAndroidMkProcessing(amod) { + if shouldSkipAndroidMkProcessing(ctx, amod) { return nil } @@ -939,7 +939,7 @@ func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON, mod blueprint.Module, provider AndroidMkEntriesProvider) error { - if shouldSkipAndroidMkProcessing(mod.(Module).base()) { + if shouldSkipAndroidMkProcessing(ctx, mod.(Module).base()) { return nil } @@ -961,11 +961,11 @@ return nil } -func ShouldSkipAndroidMkProcessing(module Module) bool { - return shouldSkipAndroidMkProcessing(module.base()) +func ShouldSkipAndroidMkProcessing(ctx ConfigAndErrorContext, module Module) bool { + return shouldSkipAndroidMkProcessing(ctx, module.base()) } -func shouldSkipAndroidMkProcessing(module *ModuleBase) bool { +func shouldSkipAndroidMkProcessing(ctx ConfigAndErrorContext, module *ModuleBase) bool { if !module.commonProperties.NamespaceExportedToMake { // TODO(jeffrygaston) do we want to validate that there are no modules being // exported to Kati that depend on this module? @@ -984,7 +984,7 @@ return true } - return !module.Enabled() || + return !module.Enabled(ctx) || module.commonProperties.HideFromMake || // Make does not understand LinuxBionic module.Os() == LinuxBionic ||
diff --git a/android/arch.go b/android/arch.go index cd8882b..e0c6908 100644 --- a/android/arch.go +++ b/android/arch.go
@@ -486,7 +486,7 @@ // dependencies on OsType variants that are explicitly disabled in their // properties. The CommonOS variant will still depend on disabled variants // if they are disabled afterwards, e.g. in archMutator if - if module.Enabled() { + if module.Enabled(mctx) { mctx.AddInterVariantDependency(commonOsToOsSpecificVariantTag, commonOSVariant, module) } } @@ -511,7 +511,7 @@ var variants []Module mctx.VisitDirectDeps(func(m Module) { if mctx.OtherModuleDependencyTag(m) == commonOsToOsSpecificVariantTag { - if m.Enabled() { + if m.Enabled(mctx) { variants = append(variants, m) } }
diff --git a/android/arch_test.go b/android/arch_test.go index 5021a67..f0a58a9 100644 --- a/android/arch_test.go +++ b/android/arch_test.go
@@ -423,7 +423,7 @@ variants := ctx.ModuleVariantsForTests(name) for _, variant := range variants { m := ctx.ModuleForTests(name, variant) - if m.Module().Enabled() { + if m.Module().Enabled(PanickingConfigAndErrorContext(ctx)) { ret = append(ret, variant) } } @@ -533,7 +533,7 @@ variants := ctx.ModuleVariantsForTests(name) for _, variant := range variants { m := ctx.ModuleForTests(name, variant) - if m.Module().Enabled() { + if m.Module().Enabled(PanickingConfigAndErrorContext(ctx)) { ret = append(ret, variant) } }
diff --git a/android/base_module_context.go b/android/base_module_context.go index c5fe585..2963520 100644 --- a/android/base_module_context.go +++ b/android/base_module_context.go
@@ -325,7 +325,7 @@ return nil } - if !aModule.Enabled() { + if !aModule.Enabled(b) { if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependency(aModule) { if b.Config().AllowMissingDependencies() { b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
diff --git a/android/configurable_properties.go b/android/configurable_properties.go new file mode 100644 index 0000000..dad42fa --- /dev/null +++ b/android/configurable_properties.go
@@ -0,0 +1,28 @@ +package android + +import "github.com/google/blueprint/proptools" + +// CreateSelectOsToBool is a utility function that makes it easy to create a +// Configurable property value that maps from os to a bool. Use an empty string +// to indicate a "default" case. +func CreateSelectOsToBool(cases map[string]*bool) proptools.Configurable[bool] { + var resultCases []proptools.ConfigurableCase[bool] + for pattern, value := range cases { + if pattern == "" { + resultCases = append(resultCases, proptools.NewConfigurableCase( + []proptools.ConfigurablePattern{proptools.NewDefaultConfigurablePattern()}, + value, + )) + } else { + resultCases = append(resultCases, proptools.NewConfigurableCase( + []proptools.ConfigurablePattern{proptools.NewStringConfigurablePattern(pattern)}, + value, + )) + } + } + + return proptools.NewConfigurable( + []proptools.ConfigurableCondition{proptools.NewConfigurableCondition("os", nil)}, + resultCases, + ) +}
diff --git a/android/early_module_context.go b/android/early_module_context.go index cf1b5fc..23f4c90 100644 --- a/android/early_module_context.go +++ b/android/early_module_context.go
@@ -173,5 +173,5 @@ } func (e *earlyModuleContext) OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{}) { - e.EarlyModuleContext.OtherModulePropertyErrorf(module, property, fmt, args) + e.EarlyModuleContext.OtherModulePropertyErrorf(module, property, fmt, args...) }
diff --git a/android/gen_notice.go b/android/gen_notice.go index 1acc638..6815f64 100644 --- a/android/gen_notice.go +++ b/android/gen_notice.go
@@ -62,7 +62,7 @@ if mod == nil { continue } - if !mod.Enabled() { // don't depend on variants without build rules + if !mod.Enabled(ctx) { // don't depend on variants without build rules continue } modules = append(modules, mod)
diff --git a/android/license_metadata.go b/android/license_metadata.go index eabb1b1..d515cdd 100644 --- a/android/license_metadata.go +++ b/android/license_metadata.go
@@ -36,7 +36,7 @@ func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) { base := ctx.Module().base() - if !base.Enabled() { + if !base.Enabled(ctx) { return } @@ -69,7 +69,7 @@ if dep == nil { return } - if !dep.Enabled() { + if !dep.Enabled(ctx) { return }
diff --git a/android/makevars.go b/android/makevars.go index 4039e7e..e73645f 100644 --- a/android/makevars.go +++ b/android/makevars.go
@@ -98,6 +98,7 @@ BlueprintFile(module blueprint.Module) string ModuleErrorf(module blueprint.Module, format string, args ...interface{}) + OtherModulePropertyErrorf(module Module, property, format string, args ...interface{}) Errorf(format string, args ...interface{}) VisitAllModules(visit func(Module)) @@ -265,7 +266,7 @@ } ctx.VisitAllModules(func(m Module) { - if provider, ok := m.(ModuleMakeVarsProvider); ok && m.Enabled() { + if provider, ok := m.(ModuleMakeVarsProvider); ok && m.Enabled(ctx) { mctx := &makeVarsContext{ SingletonContext: ctx, }
diff --git a/android/module.go b/android/module.go index effca03..5d69ba1 100644 --- a/android/module.go +++ b/android/module.go
@@ -60,7 +60,7 @@ base() *ModuleBase Disable() - Enabled() bool + Enabled(ctx ConfigAndErrorContext) bool Target() Target MultiTargets() []Target @@ -287,7 +287,7 @@ // but are not usually required (e.g. superceded by a prebuilt) should not be // disabled as that will prevent them from being built by the checkbuild target // and so prevent early detection of changes that have broken those modules. - Enabled *bool `android:"arch_variant"` + Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"` // Controls the visibility of this module to other modules. Allowable values are one or more of // these formats: @@ -1392,14 +1392,11 @@ return partition } -func (m *ModuleBase) Enabled() bool { +func (m *ModuleBase) Enabled(ctx ConfigAndErrorContext) bool { if m.commonProperties.ForcedDisabled { return false } - if m.commonProperties.Enabled == nil { - return !m.Os().DefaultDisabled - } - return *m.commonProperties.Enabled + return m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled) } func (m *ModuleBase) Disable() { @@ -1643,7 +1640,7 @@ // not be created if the module is not exported to make. // Those could depend on the build target and fail to compile // for the current build target. - if !ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(a) { + if !ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(ctx, a) { allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...) } }) @@ -1835,7 +1832,7 @@ checkDistProperties(ctx, fmt.Sprintf("dists[%d]", i), &m.distProperties.Dists[i]) } - if m.Enabled() { + if m.Enabled(ctx) { // ensure all direct android.Module deps are enabled ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) { if m, ok := bm.(Module); ok { @@ -2136,7 +2133,7 @@ } func (e configurationEvalutor) PropertyErrorf(property string, fmt string, args ...interface{}) { - e.ctx.OtherModulePropertyErrorf(e.m, property, fmt, args) + e.ctx.OtherModulePropertyErrorf(e.m, property, fmt, args...) } func (e configurationEvalutor) EvaluateConfiguration(condition proptools.ConfigurableCondition, property string) proptools.ConfigurableValue { @@ -2535,7 +2532,7 @@ } osDeps := map[osAndCross]Paths{} ctx.VisitAllModules(func(module Module) { - if module.Enabled() { + if module.Enabled(ctx) { key := osAndCross{os: module.Target().Os, hostCross: module.Target().HostCross} osDeps[key] = append(osDeps[key], module.base().checkbuildFiles...) }
diff --git a/android/mutator.go b/android/mutator.go index 75ba650..5abb05d 100644 --- a/android/mutator.go +++ b/android/mutator.go
@@ -674,13 +674,11 @@ // on component modules to be added so that they can depend directly on a prebuilt // module. func componentDepsMutator(ctx BottomUpMutatorContext) { - if m := ctx.Module(); m.Enabled() { - m.ComponentDepsMutator(ctx) - } + ctx.Module().ComponentDepsMutator(ctx) } func depsMutator(ctx BottomUpMutatorContext) { - if m := ctx.Module(); m.Enabled() { + if m := ctx.Module(); m.Enabled(ctx) { m.base().baseDepsMutator(ctx) m.DepsMutator(ctx) }
diff --git a/android/override_module.go b/android/override_module.go index 1341f53..21cf381 100644 --- a/android/override_module.go +++ b/android/override_module.go
@@ -322,7 +322,7 @@ } func overridableModuleDepsMutator(ctx BottomUpMutatorContext) { - if b, ok := ctx.Module().(OverridableModule); ok && b.Enabled() { + if b, ok := ctx.Module().(OverridableModule); ok && b.Enabled(ctx) { b.OverridablePropertiesDepsMutator(ctx) } }
diff --git a/android/paths.go b/android/paths.go index 39b660c..8d92aa4 100644 --- a/android/paths.go +++ b/android/paths.go
@@ -60,6 +60,7 @@ ModuleDir() string ModuleErrorf(fmt string, args ...interface{}) + OtherModulePropertyErrorf(module Module, property, fmt string, args ...interface{}) } var _ EarlyModulePathContext = ModuleContext(nil) @@ -561,7 +562,7 @@ if module == nil { return nil, missingDependencyError{[]string{moduleName}} } - if aModule, ok := module.(Module); ok && !aModule.Enabled() { + if aModule, ok := module.(Module); ok && !aModule.Enabled(ctx) { return nil, missingDependencyError{[]string{moduleName}} } if outProducer, ok := module.(OutputFileProducer); ok {
diff --git a/android/prebuilt.go b/android/prebuilt.go index 2b7b55b..1f9b331 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go
@@ -275,7 +275,7 @@ srcPropertyName := proptools.PropertyNameForField(srcField) srcsSupplier := func(ctx BaseModuleContext, _ Module) []string { - if !module.Enabled() { + if !module.Enabled(ctx) { return nil } value := srcPropsValue.FieldByIndex(srcFieldIndex) @@ -425,7 +425,7 @@ m := ctx.Module() // If this module is a prebuilt, is enabled and has not been renamed to source then add a // dependency onto the source if it is present. - if p := GetEmbeddedPrebuilt(m); p != nil && m.Enabled() && !p.properties.PrebuiltRenamedToSource { + if p := GetEmbeddedPrebuilt(m); p != nil && m.Enabled(ctx) && !p.properties.PrebuiltRenamedToSource { bmn, _ := m.(baseModuleName) name := bmn.BaseModuleName() if ctx.OtherModuleReverseDependencyVariantExists(name) { @@ -702,7 +702,7 @@ } // If source is not available or is disabled then always use the prebuilt. - if source == nil || !source.Enabled() { + if source == nil || !source.Enabled(ctx) { return true }
diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go index 575b926..d775ac3 100644 --- a/android/prebuilt_test.go +++ b/android/prebuilt_test.go
@@ -351,7 +351,7 @@ } }) - moduleIsDisabled := !foo.Module().Enabled() + moduleIsDisabled := !foo.Module().Enabled(PanickingConfigAndErrorContext(result.TestContext)) deps := foo.Module().(*sourceModule).deps if moduleIsDisabled { if len(deps) > 0 {
diff --git a/android/register.go b/android/register.go index d00c15f..aeb3b4c 100644 --- a/android/register.go +++ b/android/register.go
@@ -16,8 +16,9 @@ import ( "fmt" - "github.com/google/blueprint" "reflect" + + "github.com/google/blueprint" ) // A sortable component is one whose registration order affects the order in which it is executed
diff --git a/android/singleton.go b/android/singleton.go index 76df1eb..d364384 100644 --- a/android/singleton.go +++ b/android/singleton.go
@@ -284,5 +284,5 @@ } func (s *singletonContextAdaptor) OtherModulePropertyErrorf(module Module, property string, format string, args ...interface{}) { - s.blueprintSingletonContext().OtherModulePropertyErrorf(module, property, format, args) + s.blueprintSingletonContext().OtherModulePropertyErrorf(module, property, format, args...) }
diff --git a/android/testing.go b/android/testing.go index 7b4411e..c692c72 100644 --- a/android/testing.go +++ b/android/testing.go
@@ -1287,3 +1287,21 @@ t.Errorf("%q is not found in %v", expected, result) } } + +type panickingConfigAndErrorContext struct { + ctx *TestContext +} + +func (ctx *panickingConfigAndErrorContext) OtherModulePropertyErrorf(module Module, property, fmt string, args ...interface{}) { + panic(ctx.ctx.PropertyErrorf(module, property, fmt, args...).Error()) +} + +func (ctx *panickingConfigAndErrorContext) Config() Config { + return ctx.ctx.Config() +} + +func PanickingConfigAndErrorContext(ctx *TestContext) ConfigAndErrorContext { + return &panickingConfigAndErrorContext{ + ctx: ctx, + } +}
diff --git a/android/variable.go b/android/variable.go index 599f88e..309824f 100644 --- a/android/variable.go +++ b/android/variable.go
@@ -58,13 +58,13 @@ // unbundled_build is a catch-all property to annotate modules that don't build in one or // more unbundled branches, usually due to dependencies missing from the manifest. Unbundled_build struct { - Enabled *bool `android:"arch_variant"` + Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"` } `android:"arch_variant"` // similar to `Unbundled_build`, but `Always_use_prebuilt_sdks` means that it uses prebuilt // sdk specifically. Always_use_prebuilt_sdks struct { - Enabled *bool `android:"arch_variant"` + Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"` } `android:"arch_variant"` Malloc_not_svelte struct {
diff --git a/apex/apex.go b/apex/apex.go index ef57d7e..12a6c9b 100644 --- a/apex/apex.go +++ b/apex/apex.go
@@ -1077,7 +1077,7 @@ // specific variant to modules that support the ApexInfoMutator. // It also propagates updatable=true to apps of updatable apexes func apexInfoMutator(mctx android.TopDownMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } @@ -1094,7 +1094,7 @@ // apexStrictUpdatibilityLintMutator propagates strict_updatability_linting to transitive deps of a mainline module // This check is enforced for updatable modules func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() { @@ -1121,7 +1121,7 @@ // enforceAppUpdatability propagates updatable=true to apps of updatable apexes func enforceAppUpdatability(mctx android.TopDownMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if apex, ok := mctx.Module().(*apexBundle); ok && apex.Updatable() { @@ -1199,7 +1199,7 @@ // unique apex variations for this module. See android/apex.go for more about unique apex variant. // TODO(jiyong): move this to android/apex.go? func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if am, ok := mctx.Module().(android.ApexModule); ok { @@ -1211,7 +1211,7 @@ // the apex in order to retrieve its contents later. // TODO(jiyong): move this to android/apex.go? func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if am, ok := mctx.Module().(android.ApexModule); ok { @@ -1226,7 +1226,7 @@ // TODO(jiyong): move this to android/apex.go? func apexTestForMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if _, ok := mctx.Module().(android.ApexModule); ok { @@ -1340,7 +1340,7 @@ // See android.UpdateDirectlyInAnyApex // TODO(jiyong): move this to android/apex.go? func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { + if !mctx.Module().Enabled(mctx) { return } if am, ok := mctx.Module().(android.ApexModule); ok { @@ -1968,7 +1968,7 @@ if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { return false } - if mod, ok := child.(android.Module); ok && !mod.Enabled() { + if mod, ok := child.(android.Module); ok && !mod.Enabled(ctx) { return false } depName := ctx.OtherModuleName(child)
diff --git a/apex/apex_test.go b/apex/apex_test.go index 1be1048..47d609a 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go
@@ -5601,8 +5601,21 @@ compile_dex: true, } ` + // This test disables libbar, which causes the ComponentDepsMutator to add + // deps on libbar.stubs and other sub-modules that don't exist. We can + // enable AllowMissingDependencies to work around that, but enabling that + // causes extra checks for missing source files to dex_bootjars, so add those + // to the mock fs as well. + preparer2 := android.GroupFixturePreparers( + preparer, + android.PrepareForTestWithAllowMissingDependencies, + android.FixtureMergeMockFs(map[string][]byte{ + "build/soong/scripts/check_boot_jars/package_allowed_list.txt": nil, + "frameworks/base/config/boot-profile.txt": nil, + }), + ) - ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment) + ctx := testDexpreoptWithApexes(t, bp, "", preparer2, fragment) checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar") @@ -9220,7 +9233,7 @@ continue } mod := ctx.ModuleForTests(modName, variant).Module().(*cc.Module) - if !mod.Enabled() || mod.IsHideFromMake() { + if !mod.Enabled(android.PanickingConfigAndErrorContext(ctx)) || mod.IsHideFromMake() { continue } for _, ent := range android.AndroidMkEntriesForTest(t, ctx, mod) {
diff --git a/cc/cc.go b/cc/cc.go index e9cdc34..c84a65e 100644 --- a/cc/cc.go +++ b/cc/cc.go
@@ -2509,7 +2509,7 @@ } func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { - if !c.Enabled() { + if !c.Enabled(actx) { return } @@ -2757,7 +2757,7 @@ } func BeginMutator(ctx android.BottomUpMutatorContext) { - if c, ok := ctx.Module().(*Module); ok && c.Enabled() { + if c, ok := ctx.Module().(*Module); ok && c.Enabled(ctx) { c.beginMutator(ctx) } }
diff --git a/cc/fuzz.go b/cc/fuzz.go index 2436f33..b3e6639 100644 --- a/cc/fuzz.go +++ b/cc/fuzz.go
@@ -433,7 +433,7 @@ return } // Discard non-fuzz targets. - if ok := fuzz.IsValid(ccModule.FuzzModuleStruct()); !ok { + if ok := fuzz.IsValid(ctx, ccModule.FuzzModuleStruct()); !ok { return }
diff --git a/cc/llndk_library.go b/cc/llndk_library.go index ae9da98..cf229c9 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go
@@ -181,7 +181,7 @@ return } - if shouldSkipLlndkMutator(m) { + if shouldSkipLlndkMutator(mctx, m) { return } @@ -201,8 +201,8 @@ } // Check for modules that mustn't be LLNDK -func shouldSkipLlndkMutator(m *Module) bool { - if !m.Enabled() { +func shouldSkipLlndkMutator(mctx android.BottomUpMutatorContext, m *Module) bool { + if !m.Enabled(mctx) { return true } if !m.Device() {
diff --git a/cc/makevars.go b/cc/makevars.go index 9251d6a..51bcbf0 100644 --- a/cc/makevars.go +++ b/cc/makevars.go
@@ -279,7 +279,7 @@ sanitizerLibs := android.SortedStringValues(sanitizerVariables) var sanitizerLibStems []string ctx.VisitAllModules(func(m android.Module) { - if !m.Enabled() { + if !m.Enabled(ctx) { return }
diff --git a/cc/ndk_abi.go b/cc/ndk_abi.go index 86166dc..5beeab1 100644 --- a/cc/ndk_abi.go +++ b/cc/ndk_abi.go
@@ -40,7 +40,7 @@ func (n *ndkAbiDumpSingleton) GenerateBuildActions(ctx android.SingletonContext) { var depPaths android.Paths ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return } @@ -78,7 +78,7 @@ func (n *ndkAbiDiffSingleton) GenerateBuildActions(ctx android.SingletonContext) { var depPaths android.Paths ctx.VisitAllModules(func(module android.Module) { - if m, ok := module.(android.Module); ok && !m.Enabled() { + if m, ok := module.(android.Module); ok && !m.Enabled(ctx) { return }
diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 25231fd..f326068 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go
@@ -148,7 +148,7 @@ } func (this *stubDecorator) stubsVersions(ctx android.BaseMutatorContext) []string { - if !ctx.Module().Enabled() { + if !ctx.Module().Enabled(ctx) { return nil } if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go index e815172..3c48f68 100644 --- a/cc/ndk_sysroot.go +++ b/cc/ndk_sysroot.go
@@ -150,7 +150,7 @@ var installPaths android.Paths var licensePaths android.Paths ctx.VisitAllModules(func(module android.Module) { - if m, ok := module.(android.Module); ok && !m.Enabled() { + if m, ok := module.(android.Module); ok && !m.Enabled(ctx) { return }
diff --git a/cc/sanitize.go b/cc/sanitize.go index 2a1ee3c..3f70f37 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go
@@ -82,7 +82,7 @@ hwasanGlobalOptions = []string{"heap_history_size=1023", "stack_history_size=512", "export_memory_stats=0", "max_malloc_fill_size=131072", "malloc_fill_byte=0"} memtagStackCommonFlags = []string{"-march=armv8-a+memtag"} - memtagStackLlvmFlags = []string{"-dom-tree-reachability-max-bbs-to-explore=128"} + memtagStackLlvmFlags = []string{"-dom-tree-reachability-max-bbs-to-explore=128"} hostOnlySanitizeFlags = []string{"-fno-sanitize-recover=all"} deviceOnlySanitizeFlags = []string{"-fsanitize-trap=all"} @@ -858,7 +858,7 @@ flags.Local.CFlags = append(flags.Local.CFlags, cfiCflags...) flags.Local.AsFlags = append(flags.Local.AsFlags, cfiAsflags...) - flags.CFlagsDeps = append(flags.CFlagsDeps, android.PathForSource(ctx, cfiBlocklistPath + "/" + cfiBlocklistFilename)) + flags.CFlagsDeps = append(flags.CFlagsDeps, android.PathForSource(ctx, cfiBlocklistPath+"/"+cfiBlocklistFilename)) if Bool(s.Properties.Sanitize.Config.Cfi_assembly_support) { flags.Local.CFlags = append(flags.Local.CFlags, cfiAssemblySupportFlag) } @@ -1378,7 +1378,7 @@ // Add the dependency to the runtime library for each of the sanitizer variants func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil { - if !c.Enabled() { + if !c.Enabled(mctx) { return } var sanitizers []string
diff --git a/cc/tidy.go b/cc/tidy.go index 76ac7d5..ec1e8a2 100644 --- a/cc/tidy.go +++ b/cc/tidy.go
@@ -220,7 +220,7 @@ // (1) Collect all obj/tidy files into OS-specific groups. ctx.VisitAllModuleVariants(module, func(variant android.Module) { - if ctx.Config().KatiEnabled() && android.ShouldSkipAndroidMkProcessing(variant) { + if ctx.Config().KatiEnabled() && android.ShouldSkipAndroidMkProcessing(ctx, variant) { return } if m, ok := variant.(*Module); ok {
diff --git a/cc/vndk.go b/cc/vndk.go index 50e6d4b..548992d 100644 --- a/cc/vndk.go +++ b/cc/vndk.go
@@ -322,8 +322,8 @@ } // Check for modules that mustn't be VNDK -func shouldSkipVndkMutator(m *Module) bool { - if !m.Enabled() { +func shouldSkipVndkMutator(ctx android.ConfigAndErrorContext, m *Module) bool { + if !m.Enabled(ctx) { return true } if !m.Device() { @@ -338,7 +338,7 @@ } func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool { - if shouldSkipVndkMutator(m) { + if shouldSkipVndkMutator(mctx, m) { return false } @@ -369,7 +369,7 @@ return } - if shouldSkipVndkMutator(m) { + if shouldSkipVndkMutator(mctx, m) { return } @@ -548,6 +548,7 @@ func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) { return android.Paths{txt.outputFile}, nil } + func getVndkFileName(m *Module) (string, error) { if library, ok := m.linker.(*libraryDecorator); ok { return library.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil
diff --git a/fuzz/fuzz_common.go b/fuzz/fuzz_common.go index 47fd8f4..306d65e 100644 --- a/fuzz/fuzz_common.go +++ b/fuzz/fuzz_common.go
@@ -449,10 +449,10 @@ } } -func IsValid(fuzzModule FuzzModule) bool { +func IsValid(ctx android.ConfigAndErrorContext, fuzzModule FuzzModule) bool { // Discard ramdisk + vendor_ramdisk + recovery modules, they're duplicates of // fuzz targets we're going to package anyway. - if !fuzzModule.Enabled() || fuzzModule.InRamdisk() || fuzzModule.InVendorRamdisk() || fuzzModule.InRecovery() { + if !fuzzModule.Enabled(ctx) || fuzzModule.InRamdisk() || fuzzModule.InVendorRamdisk() || fuzzModule.InRecovery() { return false }
diff --git a/genrule/genrule.go b/genrule/genrule.go index 4ff82e6..67b96ca 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go
@@ -299,7 +299,7 @@ case android.HostToolProvider: // A HostToolProvider provides the path to a tool, which will be copied // into the sandbox. - if !t.(android.Module).Enabled() { + if !t.(android.Module).Enabled(ctx) { if ctx.Config().AllowMissingDependencies() { ctx.AddMissingDependencies([]string{tool}) } else {
diff --git a/java/app_import_test.go b/java/app_import_test.go index 5de50e7..496fc13 100644 --- a/java/app_import_test.go +++ b/java/app_import_test.go
@@ -509,7 +509,7 @@ variant := ctx.ModuleForTests("foo", "android_common") if test.expected == "" { - if variant.Module().Enabled() { + if variant.Module().Enabled(android.PanickingConfigAndErrorContext(ctx)) { t.Error("module should have been disabled, but wasn't") } rule := variant.MaybeRule("genProvenanceMetaData") @@ -586,7 +586,7 @@ variant := ctx.ModuleForTests("foo", "android_common") if test.expected == "" { - if variant.Module().Enabled() { + if variant.Module().Enabled(android.PanickingConfigAndErrorContext(ctx)) { t.Error("module should have been disabled, but wasn't") } rule := variant.MaybeRule("genProvenanceMetaData") @@ -629,7 +629,7 @@ if !a.prebuilt.UsePrebuilt() { t.Errorf("prebuilt foo module is not active") } - if !a.Enabled() { + if !a.Enabled(android.PanickingConfigAndErrorContext(ctx)) { t.Errorf("prebuilt foo module is disabled") } }
diff --git a/java/boot_jars.go b/java/boot_jars.go index 5d40ec3..6223ded 100644 --- a/java/boot_jars.go +++ b/java/boot_jars.go
@@ -21,8 +21,8 @@ // isActiveModule returns true if the given module should be considered for boot // jars, i.e. if it's enabled and the preferred one in case of source and // prebuilt alternatives. -func isActiveModule(module android.Module) bool { - if !module.Enabled() { +func isActiveModule(ctx android.ConfigAndErrorContext, module android.Module) bool { + if !module.Enabled(ctx) { return false } return android.IsModulePreferred(module)
diff --git a/java/bootclasspath.go b/java/bootclasspath.go index c7dc3af..77ddf5c 100644 --- a/java/bootclasspath.go +++ b/java/bootclasspath.go
@@ -127,7 +127,10 @@ // added by addDependencyOntoApexModulePair. func gatherApexModulePairDepsWithTag(ctx android.BaseModuleContext, tag blueprint.DependencyTag) []android.Module { var modules []android.Module - ctx.VisitDirectDepsIf(isActiveModule, func(module android.Module) { + isActiveModulePred := func(module android.Module) bool { + return isActiveModule(ctx, module) + } + ctx.VisitDirectDepsIf(isActiveModulePred, func(module android.Module) { t := ctx.OtherModuleDependencyTag(module) if t == tag { modules = append(modules, module)
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index cc3da76..82a34ca 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go
@@ -474,7 +474,7 @@ // Only perform a consistency check if this module is the active module. That will prevent an // unused prebuilt that was created without instrumentation from breaking an instrumentation // build. - if isActiveModule(ctx.Module()) { + if isActiveModule(ctx, ctx.Module()) { b.bootclasspathFragmentPropertyCheck(ctx) } @@ -519,7 +519,7 @@ // empty string if this module should not provide a boot image profile. func (b *BootclasspathFragmentModule) getProfileProviderApex(ctx android.BaseModuleContext) string { // Only use the profile from the module that is preferred. - if !isActiveModule(ctx.Module()) { + if !isActiveModule(ctx, ctx.Module()) { return "" } @@ -590,7 +590,7 @@ // So ignore it even if it is not in PRODUCT_APEX_BOOT_JARS. // TODO(b/202896428): Add better way to handle this. _, unknown = android.RemoveFromList("android.car-module", unknown) - if isActiveModule(ctx.Module()) && len(unknown) > 0 { + if isActiveModule(ctx, ctx.Module()) && len(unknown) > 0 { ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_BOOT_JARS", unknown) } }
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index f7e3cb9..7229ca0 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go
@@ -562,7 +562,7 @@ return ctx.Config().Once(dexBootJarsFragmentsKey, func() interface{} { fragments := make(map[string]android.Module) ctx.WalkDeps(func(child, parent android.Module) bool { - if !isActiveModule(child) { + if !isActiveModule(ctx, child) { return false } tag := ctx.OtherModuleDependencyTag(child) @@ -1125,7 +1125,7 @@ image.unstrippedInstalls = unstrippedInstalls // Only set the licenseMetadataFile from the active module. - if isActiveModule(ctx.Module()) { + if isActiveModule(ctx, ctx.Module()) { image.licenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile()) }
diff --git a/java/fuzz.go b/java/fuzz.go index fb31ce7..d37c558 100644 --- a/java/fuzz.go +++ b/java/fuzz.go
@@ -179,7 +179,7 @@ javaFuzzModule.ApexModuleBase, } - if ok := fuzz.IsValid(fuzzModuleValidator); !ok { + if ok := fuzz.IsValid(ctx, fuzzModuleValidator); !ok { return }
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index ae587ea..cab5402 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go
@@ -1428,7 +1428,7 @@ // should not contribute to anything. So, rather than have a missing dex jar cause a Soong // failure defer the error reporting to Ninja. Unless the prebuilt build target is explicitly // built Ninja should never use the dex jar file. - if !isActiveModule(module) { + if !isActiveModule(ctx, module) { return true }
diff --git a/java/jacoco.go b/java/jacoco.go index a820b38..696a0cc 100644 --- a/java/jacoco.go +++ b/java/jacoco.go
@@ -53,7 +53,7 @@ } j, ok := ctx.Module().(instrumentable) - if !ctx.Module().Enabled() || !ok { + if !ctx.Module().Enabled(ctx) || !ok { return }
diff --git a/java/jdeps.go b/java/jdeps.go index 91f7ce7..3400263 100644 --- a/java/jdeps.go +++ b/java/jdeps.go
@@ -48,7 +48,7 @@ moduleInfos := make(map[string]android.IdeInfo) ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return }
diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index 2fc6c02..99fa092 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go
@@ -19,6 +19,7 @@ "path/filepath" "android/soong/android" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -233,7 +234,7 @@ var compatConfigMetadata android.Paths ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return } if c, ok := module.(platformCompatConfigMetadataProvider); ok {
diff --git a/java/sdk_library.go b/java/sdk_library.go index 113071f..2b6c8f8 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go
@@ -2294,7 +2294,7 @@ // once for public API level and once for system API level func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookContext) { // If the module has been disabled then don't create any child modules. - if !module.Enabled() { + if !module.Enabled(mctx) { return }
diff --git a/provenance/provenance_singleton.go b/provenance/provenance_singleton.go index 97345af..679632c 100644 --- a/provenance/provenance_singleton.go +++ b/provenance/provenance_singleton.go
@@ -18,6 +18,7 @@ import ( "android/soong/android" + "github.com/google/blueprint" ) @@ -68,6 +69,15 @@ func (p *provenanceInfoSingleton) GenerateBuildActions(context android.SingletonContext) { allMetaDataFiles := make([]android.Path, 0) + moduleFilter := func(module android.Module) bool { + if !module.Enabled(context) || module.IsSkipInstall() { + return false + } + if p, ok := module.(ProvenanceMetadata); ok { + return p.ProvenanceMetaDataFile().String() != "" + } + return false + } context.VisitAllModulesIf(moduleFilter, func(module android.Module) { if p, ok := module.(ProvenanceMetadata); ok { allMetaDataFiles = append(allMetaDataFiles, p.ProvenanceMetaDataFile()) @@ -91,16 +101,6 @@ context.Phony("droidcore", android.PathForPhony(context, "provenance_metadata")) } -func moduleFilter(module android.Module) bool { - if !module.Enabled() || module.IsSkipInstall() { - return false - } - if p, ok := module.(ProvenanceMetadata); ok { - return p.ProvenanceMetaDataFile().String() != "" - } - return false -} - func GenerateArtifactProvenanceMetaData(ctx android.ModuleContext, artifactPath android.Path, installedFile android.InstallPath) android.OutputPath { onDevicePathOfInstalledFile := android.InstallPathToOnDevicePath(ctx, installedFile) artifactMetaDataFile := android.PathForIntermediates(ctx, "provenance_metadata", ctx.ModuleDir(), ctx.ModuleName(), "provenance_metadata.textproto")
diff --git a/rust/afdo.go b/rust/afdo.go index 6116c5e..6bd4bae 100644 --- a/rust/afdo.go +++ b/rust/afdo.go
@@ -39,7 +39,7 @@ return } - if mod, ok := ctx.Module().(*Module); ok && mod.Enabled() { + if mod, ok := ctx.Module().(*Module); ok && mod.Enabled(ctx) { fdoProfileName, err := actx.DeviceConfig().AfdoProfile(actx.ModuleName()) if err != nil { ctx.ModuleErrorf("%s", err.Error())
diff --git a/rust/doc.go b/rust/doc.go index 6970d79..fe20523 100644 --- a/rust/doc.go +++ b/rust/doc.go
@@ -38,7 +38,7 @@ FlagWithArg("-D ", docDir.String()) ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return }
diff --git a/rust/library.go b/rust/library.go index 6be4917..f58a54f 100644 --- a/rust/library.go +++ b/rust/library.go
@@ -713,7 +713,7 @@ if sourceVariant { sv := modules[0] for _, v := range modules[1:] { - if !v.Enabled() { + if !v.Enabled(mctx) { continue } mctx.AddInterVariantDependency(sourceDepTag, v, sv)
diff --git a/rust/project_json.go b/rust/project_json.go index 05fc09b..24dcc89 100644 --- a/rust/project_json.go +++ b/rust/project_json.go
@@ -119,7 +119,7 @@ if !ok { return nil, false } - if !rModule.Enabled() { + if !rModule.Enabled(ctx) { return nil, false } return rModule, true
diff --git a/rust/rust.go b/rust/rust.go index c2b6151..de049f7 100644 --- a/rust/rust.go +++ b/rust/rust.go
@@ -1697,7 +1697,7 @@ } func BeginMutator(ctx android.BottomUpMutatorContext) { - if mod, ok := ctx.Module().(*Module); ok && mod.Enabled() { + if mod, ok := ctx.Module().(*Module); ok && mod.Enabled(ctx) { mod.beginMutator(ctx) } }
diff --git a/rust/sanitize.go b/rust/sanitize.go index bfd3971..c086880 100644 --- a/rust/sanitize.go +++ b/rust/sanitize.go
@@ -258,7 +258,7 @@ func rustSanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { if mod, ok := mctx.Module().(*Module); ok && mod.sanitize != nil { - if !mod.Enabled() { + if !mod.Enabled(mctx) { return }
diff --git a/snapshot/host_fake_snapshot.go b/snapshot/host_fake_snapshot.go index 63cd4e1..b416ebd 100644 --- a/snapshot/host_fake_snapshot.go +++ b/snapshot/host_fake_snapshot.go
@@ -116,7 +116,7 @@ prebuilts[android.RemoveOptionalPrebuiltPrefix(module.Name())] = true return } - if !module.Enabled() || module.IsHideFromMake() { + if !module.Enabled(ctx) || module.IsHideFromMake() { return } apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)