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 ed5276f0827915166e89b72bf26f7e65f68d2dd5.
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
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...)
}