From 55b56feb869f3217e3395473ae84e03673aea661 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 23 Aug 2024 12:06:11 -0700 Subject: [PATCH 1/2] Add otherModuleProvider to ConfigurableEvaluatorContext So that it can make decisisons based on a provider set by the base config mutator. Bug: 361816274 Test: m nothing Change-Id: I19e8a9e800dfabcd05740f9c0ed5db833c5b2377 --- android/defaults.go | 1 + android/module.go | 1 + android/paths.go | 1 + android/testing.go | 4 ++++ 4 files changed, 7 insertions(+) diff --git a/android/defaults.go b/android/defaults.go index 0d51d9d7c..371106779 100644 --- a/android/defaults.go +++ b/android/defaults.go @@ -101,6 +101,7 @@ func InitDefaultableModule(module DefaultableModule) { // A restricted subset of context methods, similar to LoadHookContext. type DefaultableHookContext interface { EarlyModuleContext + OtherModuleProviderContext CreateModule(ModuleFactory, ...interface{}) Module AddMissingDependencies(missingDeps []string) diff --git a/android/module.go b/android/module.go index dd83d6407..77bdfd6d3 100644 --- a/android/module.go +++ b/android/module.go @@ -2213,6 +2213,7 @@ func (m *ModuleBase) IsNativeBridgeSupported() bool { } type ConfigurableEvaluatorContext interface { + OtherModuleProviderContext Config() Config OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{}) HasMutatorFinished(mutatorName string) bool diff --git a/android/paths.go b/android/paths.go index 0a4f89187..0d94f03e6 100644 --- a/android/paths.go +++ b/android/paths.go @@ -91,6 +91,7 @@ func GlobFiles(ctx EarlyModulePathContext, globPattern string, excludes []string // the Path methods that rely on module dependencies having been resolved. type ModuleWithDepsPathContext interface { EarlyModulePathContext + OtherModuleProviderContext VisitDirectDepsBlueprint(visit func(blueprint.Module)) OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag HasMutatorFinished(mutatorName string) bool diff --git a/android/testing.go b/android/testing.go index 1ee6e4cdb..196b22e3e 100644 --- a/android/testing.go +++ b/android/testing.go @@ -1330,6 +1330,10 @@ func (ctx *panickingConfigAndErrorContext) HasMutatorFinished(mutatorName string return ctx.ctx.HasMutatorFinished(mutatorName) } +func (ctx *panickingConfigAndErrorContext) otherModuleProvider(m blueprint.Module, p blueprint.AnyProviderKey) (any, bool) { + return ctx.ctx.otherModuleProvider(m, p) +} + func PanickingConfigAndErrorContext(ctx *TestContext) ConfigurableEvaluatorContext { return &panickingConfigAndErrorContext{ ctx: ctx, From 2cfe696f4cdfd23e5cad7c951351ac82291aa439 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Tue, 17 Sep 2024 11:31:14 -0700 Subject: [PATCH 2/2] Properly initialize android_system_image modules android_system_image just passed its embedded filesystem module to InitAndroidModule (transitively via initFilesystemModule). This meant that ModuleBase.module was pointing to the filesystem module, not the system image module. This was a problem for the new "changeable configuration" feature I'm working on, but you can also more readily see the issue if you add a GenerateAndroidBuildActions function to android_system_image: it won't be called. Bug: 361816274 Test: Presubmits Change-Id: I41978037b81910309a000dc1bba327e513ba5dce --- filesystem/filesystem.go | 10 +++++----- filesystem/system_image.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index 0b390624f..035399282 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -147,14 +147,14 @@ type filesystemProperties struct { func filesystemFactory() android.Module { module := &filesystem{} module.filterPackagingSpec = module.filterInstallablePackagingSpec - initFilesystemModule(module) + initFilesystemModule(module, module) return module } -func initFilesystemModule(module *filesystem) { - module.AddProperties(&module.properties) - android.InitPackageModule(module) - module.PackagingBase.DepsCollectFirstTargetOnly = true +func initFilesystemModule(module android.DefaultableModule, filesystemModule *filesystem) { + module.AddProperties(&filesystemModule.properties) + android.InitPackageModule(filesystemModule) + filesystemModule.PackagingBase.DepsCollectFirstTargetOnly = true android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) android.InitDefaultableModule(module) } diff --git a/filesystem/system_image.go b/filesystem/system_image.go index 805249e9a..63cb627d8 100644 --- a/filesystem/system_image.go +++ b/filesystem/system_image.go @@ -38,7 +38,7 @@ func systemImageFactory() android.Module { module.AddProperties(&module.properties) module.filesystem.buildExtraFiles = module.buildExtraFiles module.filesystem.filterPackagingSpec = module.filterPackagingSpec - initFilesystemModule(&module.filesystem) + initFilesystemModule(module, &module.filesystem) return module }