diff options
| author | 2024-09-13 23:56:18 +0000 | |
|---|---|---|
| committer | 2024-09-13 23:56:18 +0000 | |
| commit | 0bfceee17855cb2e47e512073d639f797fd31f7b (patch) | |
| tree | a8e89aec2fbe782062391e0bab9a751ac7b2dbd8 | |
| parent | e372d287c020977b866cf00e70746e5b6362f05d (diff) | |
| parent | d706709bf07e4a37093917c29e68151a0b14e441 (diff) | |
Merge "Prevent evaluating configurable properties before the defaults mutator" into main
| -rw-r--r-- | android/module.go | 7 | ||||
| -rw-r--r-- | android/packaging_test.go | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/android/module.go b/android/module.go index 491c295fb..dd83d6407 100644 --- a/android/module.go +++ b/android/module.go @@ -2215,6 +2215,7 @@ func (m *ModuleBase) IsNativeBridgeSupported() bool { type ConfigurableEvaluatorContext interface { Config() Config OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{}) + HasMutatorFinished(mutatorName string) bool } type configurationEvalutor struct { @@ -2236,6 +2237,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 { diff --git a/android/packaging_test.go b/android/packaging_test.go index 0f7bb39a1..f5b1020fc 100644 --- a/android/packaging_test.go +++ b/android/packaging_test.go @@ -118,6 +118,7 @@ func runPackagingTest(t *testing.T, config testConfig, bp string, expected []str } result := GroupFixturePreparers( + PrepareForTestWithDefaults, PrepareForTestWithArchMutator, FixtureRegisterWithContext(func(ctx RegistrationContext) { ctx.RegisterModuleType("component", componentTestModuleFactory) |