Use VisitAllModuleVariantProxies in generateModuleTarget.
Also rename android.CommonPropertiesProvider to android.CommonModuleInfo.
Bug: 377723687
Test: Compare the ninja and mk files generated.
Change-Id: Iea46c16234204eef808b590b5cc1b43b5a874636
diff --git a/android/base_module_context.go b/android/base_module_context.go
index ab28676..1f89dea 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -211,6 +211,12 @@
// data modified by the current mutator.
VisitAllModuleVariants(visit func(Module))
+ // VisitAllModuleVariantProxies calls visit for each variant of the current module. Variants of a module are always
+ // visited in order by mutators and GenerateBuildActions, so the data created by the current mutator can be read
+ // from all variants if the current module is the last one. Otherwise, care must be taken to not access any
+ // data modified by the current mutator.
+ VisitAllModuleVariantProxies(visit func(proxy ModuleProxy))
+
// GetTagPath is supposed to be called in visit function passed in WalkDeps()
// and returns a top-down dependency tags path from a start module to current child module.
// It has one less entry than GetWalkPath() as it contains the dependency tags that
@@ -382,7 +388,7 @@
return &aModule
}
- if !OtherModuleProviderOrDefault(b, module, CommonPropertiesProviderKey).Enabled {
+ if !OtherModuleProviderOrDefault(b, module, CommonModuleInfoKey).Enabled {
if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependencyProxy(b, aModule) {
if b.Config().AllowMissingDependencies() {
b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
@@ -594,6 +600,10 @@
})
}
+func (b *baseModuleContext) VisitAllModuleVariantProxies(visit func(ModuleProxy)) {
+ b.bp.VisitAllModuleVariantProxies(visitProxyAdaptor(visit))
+}
+
func (b *baseModuleContext) PrimaryModule() Module {
return b.bp.PrimaryModule().(Module)
}
diff --git a/android/module.go b/android/module.go
index 4314357..ce995ad 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1643,25 +1643,27 @@
func (m *ModuleBase) generateModuleTarget(ctx *moduleContext) {
var allInstalledFiles InstallPaths
var allCheckbuildTargets Paths
- ctx.VisitAllModuleVariants(func(module Module) {
- a := module.base()
+ ctx.VisitAllModuleVariantProxies(func(module ModuleProxy) {
var checkbuildTarget Path
var uncheckedModule bool
- if a == m {
+ var skipAndroidMkProcessing bool
+ if ctx.EqualModules(m.module, module) {
allInstalledFiles = append(allInstalledFiles, ctx.installFiles...)
checkbuildTarget = ctx.checkbuildTarget
uncheckedModule = ctx.uncheckedModule
+ skipAndroidMkProcessing = shouldSkipAndroidMkProcessing(ctx, m)
} else {
info := OtherModuleProviderOrDefault(ctx, module, InstallFilesProvider)
allInstalledFiles = append(allInstalledFiles, info.InstallFiles...)
checkbuildTarget = info.CheckbuildTarget
uncheckedModule = info.UncheckedModule
+ skipAndroidMkProcessing = OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoKey).SkipAndroidMkProcessing
}
// A module's -checkbuild phony targets should
// 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(ctx, a)) && !uncheckedModule && checkbuildTarget != nil {
+ if (!ctx.Config().KatiEnabled() || !skipAndroidMkProcessing) && !uncheckedModule && checkbuildTarget != nil {
allCheckbuildTargets = append(allCheckbuildTargets, checkbuildTarget)
}
})
@@ -1850,15 +1852,16 @@
var FinalModuleBuildTargetsProvider = blueprint.NewProvider[FinalModuleBuildTargetsInfo]()
-type CommonPropertiesProviderData struct {
+type CommonModuleInfo struct {
Enabled bool
// Whether the module has been replaced by a prebuilt
ReplacedByPrebuilt bool
// The Target of artifacts that this module variant is responsible for creating.
- CompileTarget Target
+ CompileTarget Target
+ SkipAndroidMkProcessing bool
}
-var CommonPropertiesProviderKey = blueprint.NewProvider[CommonPropertiesProviderData]()
+var CommonModuleInfoKey = blueprint.NewProvider[CommonModuleInfo]()
type PrebuiltModuleProviderData struct {
// Empty for now
@@ -2120,16 +2123,17 @@
}
buildComplianceMetadataProvider(ctx, m)
- commonData := CommonPropertiesProviderData{
- ReplacedByPrebuilt: m.commonProperties.ReplacedByPrebuilt,
- CompileTarget: m.commonProperties.CompileTarget,
+ commonData := CommonModuleInfo{
+ ReplacedByPrebuilt: m.commonProperties.ReplacedByPrebuilt,
+ CompileTarget: m.commonProperties.CompileTarget,
+ SkipAndroidMkProcessing: shouldSkipAndroidMkProcessing(ctx, m),
}
if m.commonProperties.ForcedDisabled {
commonData.Enabled = false
} else {
commonData.Enabled = m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled)
}
- SetProvider(ctx, CommonPropertiesProviderKey, commonData)
+ SetProvider(ctx, CommonModuleInfoKey, commonData)
if p, ok := m.module.(PrebuiltInterface); ok && p.Prebuilt() != nil {
SetProvider(ctx, PrebuiltModuleProviderKey, PrebuiltModuleProviderData{})
}
@@ -2138,7 +2142,7 @@
HostToolPath: h.HostToolPath()})
}
- if p, ok := m.module.(AndroidMkProviderInfoProducer); ok && !shouldSkipAndroidMkProcessing(ctx, m) {
+ if p, ok := m.module.(AndroidMkProviderInfoProducer); ok && !commonData.SkipAndroidMkProcessing {
SetProvider(ctx, AndroidMkInfoProvider, p.PrepareAndroidMKProviderInfo(ctx.Config()))
}
}
diff --git a/android/paths.go b/android/paths.go
index 8f066cc..7ab1f22 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -675,7 +675,7 @@
if module == nil {
return nil, missingDependencyError{[]string{moduleName}}
}
- if !OtherModuleProviderOrDefault(ctx, *module, CommonPropertiesProviderKey).Enabled {
+ if !OtherModuleProviderOrDefault(ctx, *module, CommonModuleInfoKey).Enabled {
return nil, missingDependencyError{[]string{moduleName}}
}
diff --git a/android/prebuilt.go b/android/prebuilt.go
index 51e72af..0ac67b3 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -381,7 +381,7 @@
// the right module. This function is only safe to call after all TransitionMutators
// have run, e.g. in GenerateAndroidBuildActions.
func PrebuiltGetPreferred(ctx BaseModuleContext, module Module) Module {
- if !OtherModuleProviderOrDefault(ctx, module, CommonPropertiesProviderKey).ReplacedByPrebuilt {
+ if !OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoKey).ReplacedByPrebuilt {
return module
}
if _, ok := OtherModuleProvider(ctx, module, PrebuiltModuleProviderKey); ok {