summaryrefslogtreecommitdiff
path: root/android/module.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/module.go')
-rw-r--r--android/module.go48
1 files changed, 31 insertions, 17 deletions
diff --git a/android/module.go b/android/module.go
index 009b0dfb6..1a3f328eb 100644
--- a/android/module.go
+++ b/android/module.go
@@ -58,7 +58,7 @@ type Module interface {
base() *ModuleBase
Disable()
- Enabled(ctx ConfigAndErrorContext) bool
+ Enabled(ctx ConfigurableEvaluatorContext) bool
Target() Target
MultiTargets() []Target
@@ -109,12 +109,12 @@ type Module interface {
// Get information about the properties that can contain visibility rules.
visibilityProperties() []visibilityProperty
- RequiredModuleNames(ctx ConfigAndErrorContext) []string
+ RequiredModuleNames(ctx ConfigurableEvaluatorContext) []string
HostRequiredModuleNames() []string
TargetRequiredModuleNames() []string
- VintfFragmentModuleNames(ctx ConfigAndErrorContext) []string
+ VintfFragmentModuleNames(ctx ConfigurableEvaluatorContext) []string
- ConfigurableEvaluator(ctx ConfigAndErrorContext) proptools.ConfigurableEvaluator
+ ConfigurableEvaluator(ctx ConfigurableEvaluatorContext) proptools.ConfigurableEvaluator
}
// Qualified id for a module
@@ -443,12 +443,6 @@ type commonProperties struct {
// Set at module initialization time by calling InitCommonOSAndroidMultiTargetsArchModule
CreateCommonOSVariant bool `blueprint:"mutated"`
- // If set to true then this variant is the CommonOS variant that has dependencies on its
- // OsType specific variants.
- //
- // Set by osMutator.
- CommonOSVariant bool `blueprint:"mutated"`
-
// When set to true, this module is not installed to the full install path (ex: under
// out/target/product/<name>/<partition>). It can be installed only to the packaging
// modules like android_filesystem.
@@ -1221,7 +1215,7 @@ func (m *ModuleBase) ArchSpecific() bool {
// True if the current variant is a CommonOS variant, false otherwise.
func (m *ModuleBase) IsCommonOSVariant() bool {
- return m.commonProperties.CommonOSVariant
+ return m.commonProperties.CompileOS == CommonOS
}
// supportsTarget returns true if the given Target is supported by the current module.
@@ -1339,13 +1333,21 @@ func (m *ModuleBase) PartitionTag(config DeviceConfig) string {
return partition
}
-func (m *ModuleBase) Enabled(ctx ConfigAndErrorContext) bool {
+func (m *ModuleBase) Enabled(ctx ConfigurableEvaluatorContext) bool {
if m.commonProperties.ForcedDisabled {
return false
}
return m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled)
}
+// Returns a copy of the enabled property, useful for passing it on to sub-modules
+func (m *ModuleBase) EnabledProperty() proptools.Configurable[bool] {
+ if m.commonProperties.ForcedDisabled {
+ return proptools.NewSimpleConfigurable(false)
+ }
+ return m.commonProperties.Enabled.Clone()
+}
+
func (m *ModuleBase) Disable() {
m.commonProperties.ForcedDisabled = true
}
@@ -1536,7 +1538,7 @@ func (m *ModuleBase) InRecovery() bool {
return m.base().commonProperties.ImageVariation == RecoveryVariation
}
-func (m *ModuleBase) RequiredModuleNames(ctx ConfigAndErrorContext) []string {
+func (m *ModuleBase) RequiredModuleNames(ctx ConfigurableEvaluatorContext) []string {
return m.base().commonProperties.Required.GetOrDefault(m.ConfigurableEvaluator(ctx), nil)
}
@@ -1548,7 +1550,7 @@ func (m *ModuleBase) TargetRequiredModuleNames() []string {
return m.base().commonProperties.Target_required
}
-func (m *ModuleBase) VintfFragmentModuleNames(ctx ConfigAndErrorContext) []string {
+func (m *ModuleBase) VintfFragmentModuleNames(ctx ConfigurableEvaluatorContext) []string {
return m.base().commonProperties.Vintf_fragment_modules.GetOrDefault(m.ConfigurableEvaluator(ctx), nil)
}
@@ -2204,17 +2206,23 @@ func (m *ModuleBase) IsNativeBridgeSupported() bool {
return proptools.Bool(m.commonProperties.Native_bridge_supported)
}
-type ConfigAndErrorContext interface {
+type ConfigContext interface {
+ Config() Config
+}
+
+type ConfigurableEvaluatorContext interface {
+ OtherModuleProviderContext
Config() Config
OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{})
+ HasMutatorFinished(mutatorName string) bool
}
type configurationEvalutor struct {
- ctx ConfigAndErrorContext
+ ctx ConfigurableEvaluatorContext
m Module
}
-func (m *ModuleBase) ConfigurableEvaluator(ctx ConfigAndErrorContext) proptools.ConfigurableEvaluator {
+func (m *ModuleBase) ConfigurableEvaluator(ctx ConfigurableEvaluatorContext) proptools.ConfigurableEvaluator {
return configurationEvalutor{
ctx: ctx,
m: m.module,
@@ -2228,6 +2236,12 @@ func (e configurationEvalutor) PropertyErrorf(property string, fmt string, args
func (e configurationEvalutor) EvaluateConfiguration(condition proptools.ConfigurableCondition, property string) proptools.ConfigurableValue {
ctx := e.ctx
m := e.m
+
+ if !ctx.HasMutatorFinished("defaults") {
+ ctx.OtherModulePropertyErrorf(m, property, "Cannot evaluate configurable property before the defaults mutator has run")
+ return proptools.ConfigurableValueUndefined()
+ }
+
switch condition.FunctionName() {
case "release_flag":
if condition.NumArgs() != 1 {