Reapply "Make the enabled property configurable"

Previously, I had changed some loadhook-appended property structs
to use selects instead of the "target" property struct. This seems
to not be exactly equivalent because "target" properties are merged
with the regular properties later, at the time the arch mutator runs.

With this reapplication, leave those target property structs alone
to avoid breakages, but I'll have to look into what the issue is
with them later.

This reverts commit ed5276f082.

Ignore-AOSP-First: This cl needs to be in a topic with internal-only projects, will cherrypick to aosp after.
Bug: 323382414
Test: m nothing --no-skip-soong-tests
Change-Id: If355d24506e3f117d27b21442a6c02bca3402dc7
This commit is contained in:
Cole Faust 2024-05-01 16:59:00 -07:00
parent c2a1c063b4
commit 021bf3d973
53 changed files with 170 additions and 107 deletions

View file

@ -41,6 +41,7 @@ bootstrap_go_package {
"buildinfo_prop.go", "buildinfo_prop.go",
"config.go", "config.go",
"test_config.go", "test_config.go",
"configurable_properties.go",
"configured_jars.go", "configured_jars.go",
"csuite_config.go", "csuite_config.go",
"deapexer.go", "deapexer.go",

View file

@ -849,7 +849,7 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *
mod blueprint.Module, provider AndroidMkDataProvider) error { mod blueprint.Module, provider AndroidMkDataProvider) error {
amod := mod.(Module).base() amod := mod.(Module).base()
if shouldSkipAndroidMkProcessing(amod) { if shouldSkipAndroidMkProcessing(ctx, amod) {
return nil return nil
} }
@ -939,7 +939,7 @@ func WriteAndroidMkData(w io.Writer, data AndroidMkData) {
func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON, func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON,
mod blueprint.Module, provider AndroidMkEntriesProvider) error { mod blueprint.Module, provider AndroidMkEntriesProvider) error {
if shouldSkipAndroidMkProcessing(mod.(Module).base()) { if shouldSkipAndroidMkProcessing(ctx, mod.(Module).base()) {
return nil return nil
} }
@ -961,11 +961,11 @@ func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, moduleIn
return nil return nil
} }
func ShouldSkipAndroidMkProcessing(module Module) bool { func ShouldSkipAndroidMkProcessing(ctx ConfigAndErrorContext, module Module) bool {
return shouldSkipAndroidMkProcessing(module.base()) return shouldSkipAndroidMkProcessing(ctx, module.base())
} }
func shouldSkipAndroidMkProcessing(module *ModuleBase) bool { func shouldSkipAndroidMkProcessing(ctx ConfigAndErrorContext, module *ModuleBase) bool {
if !module.commonProperties.NamespaceExportedToMake { if !module.commonProperties.NamespaceExportedToMake {
// TODO(jeffrygaston) do we want to validate that there are no modules being // TODO(jeffrygaston) do we want to validate that there are no modules being
// exported to Kati that depend on this module? // exported to Kati that depend on this module?
@ -984,7 +984,7 @@ func shouldSkipAndroidMkProcessing(module *ModuleBase) bool {
return true return true
} }
return !module.Enabled() || return !module.Enabled(ctx) ||
module.commonProperties.HideFromMake || module.commonProperties.HideFromMake ||
// Make does not understand LinuxBionic // Make does not understand LinuxBionic
module.Os() == LinuxBionic || module.Os() == LinuxBionic ||

View file

@ -486,7 +486,7 @@ func osMutator(bpctx blueprint.BottomUpMutatorContext) {
// dependencies on OsType variants that are explicitly disabled in their // dependencies on OsType variants that are explicitly disabled in their
// properties. The CommonOS variant will still depend on disabled variants // properties. The CommonOS variant will still depend on disabled variants
// if they are disabled afterwards, e.g. in archMutator if // if they are disabled afterwards, e.g. in archMutator if
if module.Enabled() { if module.Enabled(mctx) {
mctx.AddInterVariantDependency(commonOsToOsSpecificVariantTag, commonOSVariant, module) mctx.AddInterVariantDependency(commonOsToOsSpecificVariantTag, commonOSVariant, module)
} }
} }
@ -511,7 +511,7 @@ func GetOsSpecificVariantsOfCommonOSVariant(mctx BaseModuleContext) []Module {
var variants []Module var variants []Module
mctx.VisitDirectDeps(func(m Module) { mctx.VisitDirectDeps(func(m Module) {
if mctx.OtherModuleDependencyTag(m) == commonOsToOsSpecificVariantTag { if mctx.OtherModuleDependencyTag(m) == commonOsToOsSpecificVariantTag {
if m.Enabled() { if m.Enabled(mctx) {
variants = append(variants, m) variants = append(variants, m)
} }
} }

View file

@ -423,7 +423,7 @@ func TestArchMutator(t *testing.T) {
variants := ctx.ModuleVariantsForTests(name) variants := ctx.ModuleVariantsForTests(name)
for _, variant := range variants { for _, variant := range variants {
m := ctx.ModuleForTests(name, variant) m := ctx.ModuleForTests(name, variant)
if m.Module().Enabled() { if m.Module().Enabled(PanickingConfigAndErrorContext(ctx)) {
ret = append(ret, variant) ret = append(ret, variant)
} }
} }
@ -533,7 +533,7 @@ func TestArchMutatorNativeBridge(t *testing.T) {
variants := ctx.ModuleVariantsForTests(name) variants := ctx.ModuleVariantsForTests(name)
for _, variant := range variants { for _, variant := range variants {
m := ctx.ModuleForTests(name, variant) m := ctx.ModuleForTests(name, variant)
if m.Module().Enabled() { if m.Module().Enabled(PanickingConfigAndErrorContext(ctx)) {
ret = append(ret, variant) ret = append(ret, variant)
} }
} }

View file

@ -325,7 +325,7 @@ func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag b
return nil return nil
} }
if !aModule.Enabled() { if !aModule.Enabled(b) {
if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependency(aModule) { if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependency(aModule) {
if b.Config().AllowMissingDependencies() { if b.Config().AllowMissingDependencies() {
b.AddMissingDependencies([]string{b.OtherModuleName(aModule)}) b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})

View file

@ -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,
)
}

View file

@ -173,5 +173,5 @@ func (e *earlyModuleContext) Namespace() *Namespace {
} }
func (e *earlyModuleContext) OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{}) { 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...)
} }

View file

@ -62,7 +62,7 @@ func (s *genNoticeBuildRules) GenerateBuildActions(ctx SingletonContext) {
if mod == nil { if mod == nil {
continue 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 continue
} }
modules = append(modules, mod) modules = append(modules, mod)

View file

@ -36,7 +36,7 @@ var (
func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) { func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) {
base := ctx.Module().base() base := ctx.Module().base()
if !base.Enabled() { if !base.Enabled(ctx) {
return return
} }
@ -69,7 +69,7 @@ func buildLicenseMetadata(ctx ModuleContext, licenseMetadataFile WritablePath) {
if dep == nil { if dep == nil {
return return
} }
if !dep.Enabled() { if !dep.Enabled(ctx) {
return return
} }

View file

@ -98,6 +98,7 @@ type MakeVarsContext interface {
BlueprintFile(module blueprint.Module) string BlueprintFile(module blueprint.Module) string
ModuleErrorf(module blueprint.Module, format string, args ...interface{}) ModuleErrorf(module blueprint.Module, format string, args ...interface{})
OtherModulePropertyErrorf(module Module, property, format string, args ...interface{})
Errorf(format string, args ...interface{}) Errorf(format string, args ...interface{})
VisitAllModules(visit func(Module)) VisitAllModules(visit func(Module))
@ -265,7 +266,7 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) {
} }
ctx.VisitAllModules(func(m Module) { ctx.VisitAllModules(func(m Module) {
if provider, ok := m.(ModuleMakeVarsProvider); ok && m.Enabled() { if provider, ok := m.(ModuleMakeVarsProvider); ok && m.Enabled(ctx) {
mctx := &makeVarsContext{ mctx := &makeVarsContext{
SingletonContext: ctx, SingletonContext: ctx,
} }

View file

@ -60,7 +60,7 @@ type Module interface {
base() *ModuleBase base() *ModuleBase
Disable() Disable()
Enabled() bool Enabled(ctx ConfigAndErrorContext) bool
Target() Target Target() Target
MultiTargets() []Target MultiTargets() []Target
@ -287,7 +287,7 @@ type commonProperties struct {
// but are not usually required (e.g. superceded by a prebuilt) should not be // 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 // 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. // 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 // Controls the visibility of this module to other modules. Allowable values are one or more of
// these formats: // these formats:
@ -1392,14 +1392,11 @@ func (m *ModuleBase) PartitionTag(config DeviceConfig) string {
return partition return partition
} }
func (m *ModuleBase) Enabled() bool { func (m *ModuleBase) Enabled(ctx ConfigAndErrorContext) bool {
if m.commonProperties.ForcedDisabled { if m.commonProperties.ForcedDisabled {
return false return false
} }
if m.commonProperties.Enabled == nil { return m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled)
return !m.Os().DefaultDisabled
}
return *m.commonProperties.Enabled
} }
func (m *ModuleBase) Disable() { func (m *ModuleBase) Disable() {
@ -1643,7 +1640,7 @@ func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
// not be created if the module is not exported to make. // not be created if the module is not exported to make.
// Those could depend on the build target and fail to compile // Those could depend on the build target and fail to compile
// for the current build target. // for the current build target.
if !ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(a) { if !ctx.Config().KatiEnabled() || !shouldSkipAndroidMkProcessing(ctx, a) {
allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...) allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
} }
}) })
@ -1835,7 +1832,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
checkDistProperties(ctx, fmt.Sprintf("dists[%d]", i), &m.distProperties.Dists[i]) 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 // ensure all direct android.Module deps are enabled
ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) { ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) {
if m, ok := bm.(Module); ok { if m, ok := bm.(Module); ok {
@ -2136,7 +2133,7 @@ func (m *ModuleBase) ConfigurableEvaluator(ctx ConfigAndErrorContext) proptools.
} }
func (e configurationEvalutor) PropertyErrorf(property string, fmt string, args ...interface{}) { 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 { func (e configurationEvalutor) EvaluateConfiguration(condition proptools.ConfigurableCondition, property string) proptools.ConfigurableValue {
@ -2535,7 +2532,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
} }
osDeps := map[osAndCross]Paths{} osDeps := map[osAndCross]Paths{}
ctx.VisitAllModules(func(module Module) { ctx.VisitAllModules(func(module Module) {
if module.Enabled() { if module.Enabled(ctx) {
key := osAndCross{os: module.Target().Os, hostCross: module.Target().HostCross} key := osAndCross{os: module.Target().Os, hostCross: module.Target().HostCross}
osDeps[key] = append(osDeps[key], module.base().checkbuildFiles...) osDeps[key] = append(osDeps[key], module.base().checkbuildFiles...)
} }

View file

@ -674,13 +674,11 @@ func RegisterComponentsMutator(ctx RegisterMutatorsContext) {
// on component modules to be added so that they can depend directly on a prebuilt // on component modules to be added so that they can depend directly on a prebuilt
// module. // module.
func componentDepsMutator(ctx BottomUpMutatorContext) { func componentDepsMutator(ctx BottomUpMutatorContext) {
if m := ctx.Module(); m.Enabled() { ctx.Module().ComponentDepsMutator(ctx)
m.ComponentDepsMutator(ctx)
}
} }
func depsMutator(ctx BottomUpMutatorContext) { func depsMutator(ctx BottomUpMutatorContext) {
if m := ctx.Module(); m.Enabled() { if m := ctx.Module(); m.Enabled(ctx) {
m.base().baseDepsMutator(ctx) m.base().baseDepsMutator(ctx)
m.DepsMutator(ctx) m.DepsMutator(ctx)
} }

View file

@ -322,7 +322,7 @@ func performOverrideMutator(ctx BottomUpMutatorContext) {
} }
func overridableModuleDepsMutator(ctx BottomUpMutatorContext) { 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) b.OverridablePropertiesDepsMutator(ctx)
} }
} }

View file

@ -60,6 +60,7 @@ type EarlyModulePathContext interface {
ModuleDir() string ModuleDir() string
ModuleErrorf(fmt string, args ...interface{}) ModuleErrorf(fmt string, args ...interface{})
OtherModulePropertyErrorf(module Module, property, fmt string, args ...interface{})
} }
var _ EarlyModulePathContext = ModuleContext(nil) var _ EarlyModulePathContext = ModuleContext(nil)
@ -561,7 +562,7 @@ func getPathsFromModuleDep(ctx ModuleWithDepsPathContext, path, moduleName, tag
if module == nil { if module == nil {
return nil, missingDependencyError{[]string{moduleName}} 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}} return nil, missingDependencyError{[]string{moduleName}}
} }
if outProducer, ok := module.(OutputFileProducer); ok { if outProducer, ok := module.(OutputFileProducer); ok {

View file

@ -275,7 +275,7 @@ func InitSingleSourcePrebuiltModule(module PrebuiltInterface, srcProps interface
srcPropertyName := proptools.PropertyNameForField(srcField) srcPropertyName := proptools.PropertyNameForField(srcField)
srcsSupplier := func(ctx BaseModuleContext, _ Module) []string { srcsSupplier := func(ctx BaseModuleContext, _ Module) []string {
if !module.Enabled() { if !module.Enabled(ctx) {
return nil return nil
} }
value := srcPropsValue.FieldByIndex(srcFieldIndex) value := srcPropsValue.FieldByIndex(srcFieldIndex)
@ -425,7 +425,7 @@ func PrebuiltSourceDepsMutator(ctx BottomUpMutatorContext) {
m := ctx.Module() m := ctx.Module()
// If this module is a prebuilt, is enabled and has not been renamed to source then add a // 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. // 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) bmn, _ := m.(baseModuleName)
name := bmn.BaseModuleName() name := bmn.BaseModuleName()
if ctx.OtherModuleReverseDependencyVariantExists(name) { if ctx.OtherModuleReverseDependencyVariantExists(name) {
@ -702,7 +702,7 @@ func (p *Prebuilt) usePrebuilt(ctx BaseMutatorContext, source Module, prebuilt M
} }
// If source is not available or is disabled then always use the prebuilt. // 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 return true
} }

View file

@ -351,7 +351,7 @@ func TestPrebuilts(t *testing.T) {
} }
}) })
moduleIsDisabled := !foo.Module().Enabled() moduleIsDisabled := !foo.Module().Enabled(PanickingConfigAndErrorContext(result.TestContext))
deps := foo.Module().(*sourceModule).deps deps := foo.Module().(*sourceModule).deps
if moduleIsDisabled { if moduleIsDisabled {
if len(deps) > 0 { if len(deps) > 0 {

View file

@ -16,8 +16,9 @@ package android
import ( import (
"fmt" "fmt"
"github.com/google/blueprint"
"reflect" "reflect"
"github.com/google/blueprint"
) )
// A sortable component is one whose registration order affects the order in which it is executed // A sortable component is one whose registration order affects the order in which it is executed

View file

@ -284,5 +284,5 @@ func (s *singletonContextAdaptor) moduleProvider(module blueprint.Module, provid
} }
func (s *singletonContextAdaptor) OtherModulePropertyErrorf(module Module, property string, format string, args ...interface{}) { 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...)
} }

View file

@ -1287,3 +1287,21 @@ func EnsureListContainsSuffix(t *testing.T, result []string, expected string) {
t.Errorf("%q is not found in %v", expected, result) 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,
}
}

View file

@ -58,13 +58,13 @@ type variableProperties struct {
// unbundled_build is a catch-all property to annotate modules that don't build in one or // 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. // more unbundled branches, usually due to dependencies missing from the manifest.
Unbundled_build struct { Unbundled_build struct {
Enabled *bool `android:"arch_variant"` Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"`
} `android:"arch_variant"` } `android:"arch_variant"`
// similar to `Unbundled_build`, but `Always_use_prebuilt_sdks` means that it uses prebuilt // similar to `Unbundled_build`, but `Always_use_prebuilt_sdks` means that it uses prebuilt
// sdk specifically. // sdk specifically.
Always_use_prebuilt_sdks struct { Always_use_prebuilt_sdks struct {
Enabled *bool `android:"arch_variant"` Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"`
} `android:"arch_variant"` } `android:"arch_variant"`
Malloc_not_svelte struct { Malloc_not_svelte struct {

View file

@ -1077,7 +1077,7 @@ type ApexInfoMutator interface {
// specific variant to modules that support the ApexInfoMutator. // specific variant to modules that support the ApexInfoMutator.
// It also propagates updatable=true to apps of updatable apexes // It also propagates updatable=true to apps of updatable apexes
func apexInfoMutator(mctx android.TopDownMutatorContext) { func apexInfoMutator(mctx android.TopDownMutatorContext) {
if !mctx.Module().Enabled() { if !mctx.Module().Enabled(mctx) {
return return
} }
@ -1094,7 +1094,7 @@ func apexInfoMutator(mctx android.TopDownMutatorContext) {
// apexStrictUpdatibilityLintMutator propagates strict_updatability_linting to transitive deps of a mainline module // apexStrictUpdatibilityLintMutator propagates strict_updatability_linting to transitive deps of a mainline module
// This check is enforced for updatable modules // This check is enforced for updatable modules
func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) { func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) {
if !mctx.Module().Enabled() { if !mctx.Module().Enabled(mctx) {
return return
} }
if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() { if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() {
@ -1121,7 +1121,7 @@ func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) {
// enforceAppUpdatability propagates updatable=true to apps of updatable apexes // enforceAppUpdatability propagates updatable=true to apps of updatable apexes
func enforceAppUpdatability(mctx android.TopDownMutatorContext) { func enforceAppUpdatability(mctx android.TopDownMutatorContext) {
if !mctx.Module().Enabled() { if !mctx.Module().Enabled(mctx) {
return return
} }
if apex, ok := mctx.Module().(*apexBundle); ok && apex.Updatable() { if apex, ok := mctx.Module().(*apexBundle); ok && apex.Updatable() {
@ -1199,7 +1199,7 @@ func (a *apexBundle) checkStrictUpdatabilityLinting() bool {
// unique apex variations for this module. See android/apex.go for more about unique apex variant. // unique apex variations for this module. See android/apex.go for more about unique apex variant.
// TODO(jiyong): move this to android/apex.go? // TODO(jiyong): move this to android/apex.go?
func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() { if !mctx.Module().Enabled(mctx) {
return return
} }
if am, ok := mctx.Module().(android.ApexModule); ok { if am, ok := mctx.Module().(android.ApexModule); ok {
@ -1211,7 +1211,7 @@ func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) {
// the apex in order to retrieve its contents later. // the apex in order to retrieve its contents later.
// TODO(jiyong): move this to android/apex.go? // TODO(jiyong): move this to android/apex.go?
func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() { if !mctx.Module().Enabled(mctx) {
return return
} }
if am, ok := mctx.Module().(android.ApexModule); ok { if am, ok := mctx.Module().(android.ApexModule); ok {
@ -1226,7 +1226,7 @@ func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) {
// TODO(jiyong): move this to android/apex.go? // TODO(jiyong): move this to android/apex.go?
func apexTestForMutator(mctx android.BottomUpMutatorContext) { func apexTestForMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() { if !mctx.Module().Enabled(mctx) {
return return
} }
if _, ok := mctx.Module().(android.ApexModule); ok { if _, ok := mctx.Module().(android.ApexModule); ok {
@ -1340,7 +1340,7 @@ func apexModuleTypeRequiresVariant(module ApexInfoMutator) bool {
// See android.UpdateDirectlyInAnyApex // See android.UpdateDirectlyInAnyApex
// TODO(jiyong): move this to android/apex.go? // TODO(jiyong): move this to android/apex.go?
func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) { func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() { if !mctx.Module().Enabled(mctx) {
return return
} }
if am, ok := mctx.Module().(android.ApexModule); ok { if am, ok := mctx.Module().(android.ApexModule); ok {
@ -1968,7 +1968,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
return false return false
} }
if mod, ok := child.(android.Module); ok && !mod.Enabled() { if mod, ok := child.(android.Module); ok && !mod.Enabled(ctx) {
return false return false
} }
depName := ctx.OtherModuleName(child) depName := ctx.OtherModuleName(child)

View file

@ -5601,8 +5601,21 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
compile_dex: true, 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, "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") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
@ -9220,7 +9233,7 @@ func TestPrebuiltStubLibDep(t *testing.T) {
continue continue
} }
mod := ctx.ModuleForTests(modName, variant).Module().(*cc.Module) mod := ctx.ModuleForTests(modName, variant).Module().(*cc.Module)
if !mod.Enabled() || mod.IsHideFromMake() { if !mod.Enabled(android.PanickingConfigAndErrorContext(ctx)) || mod.IsHideFromMake() {
continue continue
} }
for _, ent := range android.AndroidMkEntriesForTest(t, ctx, mod) { for _, ent := range android.AndroidMkEntriesForTest(t, ctx, mod) {

View file

@ -2509,7 +2509,7 @@ func (c *Module) shouldUseApiSurface() bool {
} }
func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
if !c.Enabled() { if !c.Enabled(actx) {
return return
} }
@ -2757,7 +2757,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
} }
func BeginMutator(ctx android.BottomUpMutatorContext) { 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) c.beginMutator(ctx)
} }
} }

View file

@ -433,7 +433,7 @@ func (s *ccRustFuzzPackager) GenerateBuildActions(ctx android.SingletonContext)
return return
} }
// Discard non-fuzz targets. // Discard non-fuzz targets.
if ok := fuzz.IsValid(ccModule.FuzzModuleStruct()); !ok { if ok := fuzz.IsValid(ctx, ccModule.FuzzModuleStruct()); !ok {
return return
} }

View file

@ -181,7 +181,7 @@ func llndkMutator(mctx android.BottomUpMutatorContext) {
return return
} }
if shouldSkipLlndkMutator(m) { if shouldSkipLlndkMutator(mctx, m) {
return return
} }
@ -201,8 +201,8 @@ func llndkMutator(mctx android.BottomUpMutatorContext) {
} }
// Check for modules that mustn't be LLNDK // Check for modules that mustn't be LLNDK
func shouldSkipLlndkMutator(m *Module) bool { func shouldSkipLlndkMutator(mctx android.BottomUpMutatorContext, m *Module) bool {
if !m.Enabled() { if !m.Enabled(mctx) {
return true return true
} }
if !m.Device() { if !m.Device() {

View file

@ -279,7 +279,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
sanitizerLibs := android.SortedStringValues(sanitizerVariables) sanitizerLibs := android.SortedStringValues(sanitizerVariables)
var sanitizerLibStems []string var sanitizerLibStems []string
ctx.VisitAllModules(func(m android.Module) { ctx.VisitAllModules(func(m android.Module) {
if !m.Enabled() { if !m.Enabled(ctx) {
return return
} }

View file

@ -40,7 +40,7 @@ type ndkAbiDumpSingleton struct{}
func (n *ndkAbiDumpSingleton) GenerateBuildActions(ctx android.SingletonContext) { func (n *ndkAbiDumpSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var depPaths android.Paths var depPaths android.Paths
ctx.VisitAllModules(func(module android.Module) { ctx.VisitAllModules(func(module android.Module) {
if !module.Enabled() { if !module.Enabled(ctx) {
return return
} }
@ -78,7 +78,7 @@ type ndkAbiDiffSingleton struct{}
func (n *ndkAbiDiffSingleton) GenerateBuildActions(ctx android.SingletonContext) { func (n *ndkAbiDiffSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var depPaths android.Paths var depPaths android.Paths
ctx.VisitAllModules(func(module android.Module) { 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 return
} }

View file

@ -148,7 +148,7 @@ func ndkLibraryVersions(ctx android.BaseMutatorContext, from android.ApiLevel) [
} }
func (this *stubDecorator) stubsVersions(ctx android.BaseMutatorContext) []string { func (this *stubDecorator) stubsVersions(ctx android.BaseMutatorContext) []string {
if !ctx.Module().Enabled() { if !ctx.Module().Enabled(ctx) {
return nil return nil
} }
if ctx.Target().NativeBridge == android.NativeBridgeEnabled { if ctx.Target().NativeBridge == android.NativeBridgeEnabled {

View file

@ -150,7 +150,7 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var installPaths android.Paths var installPaths android.Paths
var licensePaths android.Paths var licensePaths android.Paths
ctx.VisitAllModules(func(module android.Module) { 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 return
} }

View file

@ -82,7 +82,7 @@ var (
hwasanGlobalOptions = []string{"heap_history_size=1023", "stack_history_size=512", hwasanGlobalOptions = []string{"heap_history_size=1023", "stack_history_size=512",
"export_memory_stats=0", "max_malloc_fill_size=131072", "malloc_fill_byte=0"} "export_memory_stats=0", "max_malloc_fill_size=131072", "malloc_fill_byte=0"}
memtagStackCommonFlags = []string{"-march=armv8-a+memtag"} 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"} hostOnlySanitizeFlags = []string{"-fno-sanitize-recover=all"}
deviceOnlySanitizeFlags = []string{"-fsanitize-trap=all"} deviceOnlySanitizeFlags = []string{"-fsanitize-trap=all"}
@ -858,7 +858,7 @@ func (s *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
flags.Local.CFlags = append(flags.Local.CFlags, cfiCflags...) flags.Local.CFlags = append(flags.Local.CFlags, cfiCflags...)
flags.Local.AsFlags = append(flags.Local.AsFlags, cfiAsflags...) 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) { if Bool(s.Properties.Sanitize.Config.Cfi_assembly_support) {
flags.Local.CFlags = append(flags.Local.CFlags, cfiAssemblySupportFlag) flags.Local.CFlags = append(flags.Local.CFlags, cfiAssemblySupportFlag)
} }
@ -1378,7 +1378,7 @@ func sanitizerRuntimeDepsMutator(mctx android.TopDownMutatorContext) {
// Add the dependency to the runtime library for each of the sanitizer variants // Add the dependency to the runtime library for each of the sanitizer variants
func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil { if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
if !c.Enabled() { if !c.Enabled(mctx) {
return return
} }
var sanitizers []string var sanitizers []string

View file

@ -220,7 +220,7 @@ func collectTidyObjModuleTargets(ctx android.SingletonContext, module android.Mo
// (1) Collect all obj/tidy files into OS-specific groups. // (1) Collect all obj/tidy files into OS-specific groups.
ctx.VisitAllModuleVariants(module, func(variant android.Module) { ctx.VisitAllModuleVariants(module, func(variant android.Module) {
if ctx.Config().KatiEnabled() && android.ShouldSkipAndroidMkProcessing(variant) { if ctx.Config().KatiEnabled() && android.ShouldSkipAndroidMkProcessing(ctx, variant) {
return return
} }
if m, ok := variant.(*Module); ok { if m, ok := variant.(*Module); ok {

View file

@ -322,8 +322,8 @@ func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
} }
// Check for modules that mustn't be VNDK // Check for modules that mustn't be VNDK
func shouldSkipVndkMutator(m *Module) bool { func shouldSkipVndkMutator(ctx android.ConfigAndErrorContext, m *Module) bool {
if !m.Enabled() { if !m.Enabled(ctx) {
return true return true
} }
if !m.Device() { if !m.Device() {
@ -338,7 +338,7 @@ func shouldSkipVndkMutator(m *Module) bool {
} }
func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool { func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool {
if shouldSkipVndkMutator(m) { if shouldSkipVndkMutator(mctx, m) {
return false return false
} }
@ -369,7 +369,7 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
return return
} }
if shouldSkipVndkMutator(m) { if shouldSkipVndkMutator(mctx, m) {
return return
} }
@ -548,6 +548,7 @@ func (txt *vndkLibrariesTxt) SubDir() string {
func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) { func (txt *vndkLibrariesTxt) OutputFiles(tag string) (android.Paths, error) {
return android.Paths{txt.outputFile}, nil return android.Paths{txt.outputFile}, nil
} }
func getVndkFileName(m *Module) (string, error) { func getVndkFileName(m *Module) (string, error) {
if library, ok := m.linker.(*libraryDecorator); ok { if library, ok := m.linker.(*libraryDecorator); ok {
return library.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil return library.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil

View file

@ -449,10 +449,10 @@ func IsValidFrameworkForModule(targetFramework Framework, lang Lang, moduleFrame
} }
} }
func IsValid(fuzzModule FuzzModule) bool { func IsValid(ctx android.ConfigAndErrorContext, fuzzModule FuzzModule) bool {
// Discard ramdisk + vendor_ramdisk + recovery modules, they're duplicates of // Discard ramdisk + vendor_ramdisk + recovery modules, they're duplicates of
// fuzz targets we're going to package anyway. // 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 return false
} }

View file

@ -299,7 +299,7 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
case android.HostToolProvider: case android.HostToolProvider:
// A HostToolProvider provides the path to a tool, which will be copied // A HostToolProvider provides the path to a tool, which will be copied
// into the sandbox. // into the sandbox.
if !t.(android.Module).Enabled() { if !t.(android.Module).Enabled(ctx) {
if ctx.Config().AllowMissingDependencies() { if ctx.Config().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{tool}) ctx.AddMissingDependencies([]string{tool})
} else { } else {

View file

@ -509,7 +509,7 @@ func TestAndroidAppImport_ArchVariants(t *testing.T) {
variant := ctx.ModuleForTests("foo", "android_common") variant := ctx.ModuleForTests("foo", "android_common")
if test.expected == "" { if test.expected == "" {
if variant.Module().Enabled() { if variant.Module().Enabled(android.PanickingConfigAndErrorContext(ctx)) {
t.Error("module should have been disabled, but wasn't") t.Error("module should have been disabled, but wasn't")
} }
rule := variant.MaybeRule("genProvenanceMetaData") rule := variant.MaybeRule("genProvenanceMetaData")
@ -586,7 +586,7 @@ func TestAndroidAppImport_SoongConfigVariables(t *testing.T) {
variant := ctx.ModuleForTests("foo", "android_common") variant := ctx.ModuleForTests("foo", "android_common")
if test.expected == "" { if test.expected == "" {
if variant.Module().Enabled() { if variant.Module().Enabled(android.PanickingConfigAndErrorContext(ctx)) {
t.Error("module should have been disabled, but wasn't") t.Error("module should have been disabled, but wasn't")
} }
rule := variant.MaybeRule("genProvenanceMetaData") rule := variant.MaybeRule("genProvenanceMetaData")
@ -629,7 +629,7 @@ func TestAndroidAppImport_overridesDisabledAndroidApp(t *testing.T) {
if !a.prebuilt.UsePrebuilt() { if !a.prebuilt.UsePrebuilt() {
t.Errorf("prebuilt foo module is not active") t.Errorf("prebuilt foo module is not active")
} }
if !a.Enabled() { if !a.Enabled(android.PanickingConfigAndErrorContext(ctx)) {
t.Errorf("prebuilt foo module is disabled") t.Errorf("prebuilt foo module is disabled")
} }
} }

View file

@ -21,8 +21,8 @@ import (
// isActiveModule returns true if the given module should be considered for boot // 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 // jars, i.e. if it's enabled and the preferred one in case of source and
// prebuilt alternatives. // prebuilt alternatives.
func isActiveModule(module android.Module) bool { func isActiveModule(ctx android.ConfigAndErrorContext, module android.Module) bool {
if !module.Enabled() { if !module.Enabled(ctx) {
return false return false
} }
return android.IsModulePreferred(module) return android.IsModulePreferred(module)

View file

@ -127,7 +127,10 @@ func reportMissingVariationDependency(ctx android.BottomUpMutatorContext, variat
// added by addDependencyOntoApexModulePair. // added by addDependencyOntoApexModulePair.
func gatherApexModulePairDepsWithTag(ctx android.BaseModuleContext, tag blueprint.DependencyTag) []android.Module { func gatherApexModulePairDepsWithTag(ctx android.BaseModuleContext, tag blueprint.DependencyTag) []android.Module {
var modules []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) t := ctx.OtherModuleDependencyTag(module)
if t == tag { if t == tag {
modules = append(modules, module) modules = append(modules, module)

View file

@ -474,7 +474,7 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
// Only perform a consistency check if this module is the active module. That will prevent an // 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 // unused prebuilt that was created without instrumentation from breaking an instrumentation
// build. // build.
if isActiveModule(ctx.Module()) { if isActiveModule(ctx, ctx.Module()) {
b.bootclasspathFragmentPropertyCheck(ctx) b.bootclasspathFragmentPropertyCheck(ctx)
} }
@ -519,7 +519,7 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
// empty string if this module should not provide a boot image profile. // empty string if this module should not provide a boot image profile.
func (b *BootclasspathFragmentModule) getProfileProviderApex(ctx android.BaseModuleContext) string { func (b *BootclasspathFragmentModule) getProfileProviderApex(ctx android.BaseModuleContext) string {
// Only use the profile from the module that is preferred. // Only use the profile from the module that is preferred.
if !isActiveModule(ctx.Module()) { if !isActiveModule(ctx, ctx.Module()) {
return "" return ""
} }
@ -590,7 +590,7 @@ func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext)
// So ignore it even if it is not in PRODUCT_APEX_BOOT_JARS. // So ignore it even if it is not in PRODUCT_APEX_BOOT_JARS.
// TODO(b/202896428): Add better way to handle this. // TODO(b/202896428): Add better way to handle this.
_, unknown = android.RemoveFromList("android.car-module", unknown) _, 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) ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_BOOT_JARS", unknown)
} }
} }

View file

@ -562,7 +562,7 @@ func gatherBootclasspathFragments(ctx android.ModuleContext) map[string]android.
return ctx.Config().Once(dexBootJarsFragmentsKey, func() interface{} { return ctx.Config().Once(dexBootJarsFragmentsKey, func() interface{} {
fragments := make(map[string]android.Module) fragments := make(map[string]android.Module)
ctx.WalkDeps(func(child, parent android.Module) bool { ctx.WalkDeps(func(child, parent android.Module) bool {
if !isActiveModule(child) { if !isActiveModule(ctx, child) {
return false return false
} }
tag := ctx.OtherModuleDependencyTag(child) tag := ctx.OtherModuleDependencyTag(child)
@ -1125,7 +1125,7 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p
image.unstrippedInstalls = unstrippedInstalls image.unstrippedInstalls = unstrippedInstalls
// Only set the licenseMetadataFile from the active module. // Only set the licenseMetadataFile from the active module.
if isActiveModule(ctx.Module()) { if isActiveModule(ctx, ctx.Module()) {
image.licenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile()) image.licenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile())
} }

View file

@ -179,7 +179,7 @@ func (s *javaFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
javaFuzzModule.ApexModuleBase, javaFuzzModule.ApexModuleBase,
} }
if ok := fuzz.IsValid(fuzzModuleValidator); !ok { if ok := fuzz.IsValid(ctx, fuzzModuleValidator); !ok {
return return
} }

View file

@ -1428,7 +1428,7 @@ func deferReportingMissingBootDexJar(ctx android.ModuleContext, module android.M
// should not contribute to anything. So, rather than have a missing dex jar cause a Soong // 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 // failure defer the error reporting to Ninja. Unless the prebuilt build target is explicitly
// built Ninja should never use the dex jar file. // built Ninja should never use the dex jar file.
if !isActiveModule(module) { if !isActiveModule(ctx, module) {
return true return true
} }

View file

@ -53,7 +53,7 @@ func jacocoDepsMutator(ctx android.BottomUpMutatorContext) {
} }
j, ok := ctx.Module().(instrumentable) j, ok := ctx.Module().(instrumentable)
if !ctx.Module().Enabled() || !ok { if !ctx.Module().Enabled(ctx) || !ok {
return return
} }

View file

@ -48,7 +48,7 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont
moduleInfos := make(map[string]android.IdeInfo) moduleInfos := make(map[string]android.IdeInfo)
ctx.VisitAllModules(func(module android.Module) { ctx.VisitAllModules(func(module android.Module) {
if !module.Enabled() { if !module.Enabled(ctx) {
return return
} }

View file

@ -19,6 +19,7 @@ import (
"path/filepath" "path/filepath"
"android/soong/android" "android/soong/android"
"github.com/google/blueprint" "github.com/google/blueprint"
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
) )
@ -233,7 +234,7 @@ func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.Singlet
var compatConfigMetadata android.Paths var compatConfigMetadata android.Paths
ctx.VisitAllModules(func(module android.Module) { ctx.VisitAllModules(func(module android.Module) {
if !module.Enabled() { if !module.Enabled(ctx) {
return return
} }
if c, ok := module.(platformCompatConfigMetadataProvider); ok { if c, ok := module.(platformCompatConfigMetadataProvider); ok {

View file

@ -2294,7 +2294,7 @@ func (module *SdkLibrary) getApiDir() string {
// once for public API level and once for system API level // once for public API level and once for system API level
func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookContext) { func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookContext) {
// If the module has been disabled then don't create any child modules. // If the module has been disabled then don't create any child modules.
if !module.Enabled() { if !module.Enabled(mctx) {
return return
} }

View file

@ -18,6 +18,7 @@ package provenance
import ( import (
"android/soong/android" "android/soong/android"
"github.com/google/blueprint" "github.com/google/blueprint"
) )
@ -68,6 +69,15 @@ type provenanceInfoSingleton struct {
func (p *provenanceInfoSingleton) GenerateBuildActions(context android.SingletonContext) { func (p *provenanceInfoSingleton) GenerateBuildActions(context android.SingletonContext) {
allMetaDataFiles := make([]android.Path, 0) 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) { context.VisitAllModulesIf(moduleFilter, func(module android.Module) {
if p, ok := module.(ProvenanceMetadata); ok { if p, ok := module.(ProvenanceMetadata); ok {
allMetaDataFiles = append(allMetaDataFiles, p.ProvenanceMetaDataFile()) allMetaDataFiles = append(allMetaDataFiles, p.ProvenanceMetaDataFile())
@ -91,16 +101,6 @@ func (p *provenanceInfoSingleton) GenerateBuildActions(context android.Singleton
context.Phony("droidcore", android.PathForPhony(context, "provenance_metadata")) 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 { func GenerateArtifactProvenanceMetaData(ctx android.ModuleContext, artifactPath android.Path, installedFile android.InstallPath) android.OutputPath {
onDevicePathOfInstalledFile := android.InstallPathToOnDevicePath(ctx, installedFile) onDevicePathOfInstalledFile := android.InstallPathToOnDevicePath(ctx, installedFile)
artifactMetaDataFile := android.PathForIntermediates(ctx, "provenance_metadata", ctx.ModuleDir(), ctx.ModuleName(), "provenance_metadata.textproto") artifactMetaDataFile := android.PathForIntermediates(ctx, "provenance_metadata", ctx.ModuleDir(), ctx.ModuleName(), "provenance_metadata.textproto")

View file

@ -39,7 +39,7 @@ func (afdo *afdo) addDep(ctx BaseModuleContext, actx android.BottomUpMutatorCont
return 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()) fdoProfileName, err := actx.DeviceConfig().AfdoProfile(actx.ModuleName())
if err != nil { if err != nil {
ctx.ModuleErrorf("%s", err.Error()) ctx.ModuleErrorf("%s", err.Error())

View file

@ -38,7 +38,7 @@ func (n *rustdocSingleton) GenerateBuildActions(ctx android.SingletonContext) {
FlagWithArg("-D ", docDir.String()) FlagWithArg("-D ", docDir.String())
ctx.VisitAllModules(func(module android.Module) { ctx.VisitAllModules(func(module android.Module) {
if !module.Enabled() { if !module.Enabled(ctx) {
return return
} }

View file

@ -713,7 +713,7 @@ func LibraryMutator(mctx android.BottomUpMutatorContext) {
if sourceVariant { if sourceVariant {
sv := modules[0] sv := modules[0]
for _, v := range modules[1:] { for _, v := range modules[1:] {
if !v.Enabled() { if !v.Enabled(mctx) {
continue continue
} }
mctx.AddInterVariantDependency(sourceDepTag, v, sv) mctx.AddInterVariantDependency(sourceDepTag, v, sv)

View file

@ -119,7 +119,7 @@ func isModuleSupported(ctx android.SingletonContext, module android.Module) (*Mo
if !ok { if !ok {
return nil, false return nil, false
} }
if !rModule.Enabled() { if !rModule.Enabled(ctx) {
return nil, false return nil, false
} }
return rModule, true return rModule, true

View file

@ -1697,7 +1697,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
} }
func BeginMutator(ctx android.BottomUpMutatorContext) { 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) mod.beginMutator(ctx)
} }
} }

View file

@ -258,7 +258,7 @@ func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps {
func rustSanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { func rustSanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
if mod, ok := mctx.Module().(*Module); ok && mod.sanitize != nil { if mod, ok := mctx.Module().(*Module); ok && mod.sanitize != nil {
if !mod.Enabled() { if !mod.Enabled(mctx) {
return return
} }

View file

@ -116,7 +116,7 @@ func (c *hostFakeSingleton) GenerateBuildActions(ctx android.SingletonContext) {
prebuilts[android.RemoveOptionalPrebuiltPrefix(module.Name())] = true prebuilts[android.RemoveOptionalPrebuiltPrefix(module.Name())] = true
return return
} }
if !module.Enabled() || module.IsHideFromMake() { if !module.Enabled(ctx) || module.IsHideFromMake() {
return return
} }
apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider) apexInfo, _ := android.SingletonModuleProvider(ctx, module, android.ApexInfoProvider)