From 1e0a69a02e628d8d674b7283780c0f6aa8f6fe7e Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Sat, 16 Dec 2023 18:03:18 +0000 Subject: [PATCH] aconfig: harden dependency collection To prevent errors, when we collect dependencies for a module, walk the blueprint modules, and ignore blueprint and disabled modules. This avoids errors in validateAndroidModule when a android.Module (such as a genrule) depends on a blueprint.Module, and strict checking is enabled. Bug: 308625757 Test: manual Change-Id: I11f0a0b504aa18d6d786cc91319b9d1d9497c04f --- android/aconfig_providers.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go index ddebec343..11fc6600d 100644 --- a/android/aconfig_providers.go +++ b/android/aconfig_providers.go @@ -49,7 +49,13 @@ func CollectDependencyAconfigFiles(ctx ModuleContext, mergedAconfigFiles *map[st if *mergedAconfigFiles == nil { *mergedAconfigFiles = make(map[string]Paths) } - ctx.VisitDirectDeps(func(module Module) { + ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) { + // Walk our direct dependencies, ignoring blueprint Modules and disabled Android Modules. + aModule, _ := module.(Module) + if aModule == nil || !aModule.Enabled() { + return + } + if dep, _ := OtherModuleProvider(ctx, module, AconfigDeclarationsProviderKey); dep.IntermediateCacheOutputPath != nil { (*mergedAconfigFiles)[dep.Container] = append((*mergedAconfigFiles)[dep.Container], dep.IntermediateCacheOutputPath) return