From a866713ddb8698616f83e3f49857a8bb42f616fd Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 30 May 2024 16:46:44 +0000 Subject: [PATCH] Handle missing apex_contributions Some minimal branches have v/g_s/build/release (where apex_contibutions have been set to mainline prebuilts), but not v/g/b (where the apex_contributions for prebuilts have been defined). These minimal branches are unsuitable for building a product that consume mainline prebuilts, but they would still like to do aosp product builds. aosp products should not use the mainline prebuilts anyways, but this has been implemented as - always create the dependency edge to the selected apex contributions - do not visit the dependency edge subsequently if IgnoreApexContributions is set set to true To support aosp product builds in minimal branches, this CL updates the implementation to skip creating the dependency edge when IgnoreApexContributions is set to true Test: go test ./android Change-Id: Iaa0971760e64f9b7a03542f179231ce2268b6616 --- android/apex_contributions.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/android/apex_contributions.go b/android/apex_contributions.go index 91549e5d8..8b72f8e4f 100644 --- a/android/apex_contributions.go +++ b/android/apex_contributions.go @@ -106,7 +106,13 @@ var ( // Creates a dep to each selected apex_contributions func (a *allApexContributions) DepsMutator(ctx BottomUpMutatorContext) { - ctx.AddDependency(ctx.Module(), AcDepTag, ctx.Config().AllApexContributions()...) + // Skip apex_contributions if BuildApexContributionContents is true + // This product config var allows some products in the same family to use mainline modules from source + // (e.g. shiba and shiba_fullmte) + // Eventually these product variants will have their own release config maps. + if !proptools.Bool(ctx.Config().BuildIgnoreApexContributionContents()) { + ctx.AddDependency(ctx.Module(), AcDepTag, ctx.Config().AllApexContributions()...) + } } // Set PrebuiltSelectionInfoProvider in post deps phase @@ -126,19 +132,13 @@ func (a *allApexContributions) SetPrebuiltSelectionInfoProvider(ctx BaseModuleCo } p := PrebuiltSelectionInfoMap{} - // Skip apex_contributions if BuildApexContributionContents is true - // This product config var allows some products in the same family to use mainline modules from source - // (e.g. shiba and shiba_fullmte) - // Eventually these product variants will have their own release config maps. - if !proptools.Bool(ctx.Config().BuildIgnoreApexContributionContents()) { - ctx.VisitDirectDepsWithTag(AcDepTag, func(child Module) { - if m, ok := child.(*apexContributions); ok { - addContentsToProvider(&p, m) - } else { - ctx.ModuleErrorf("%s is not an apex_contributions module\n", child.Name()) - } - }) - } + ctx.VisitDirectDepsWithTag(AcDepTag, func(child Module) { + if m, ok := child.(*apexContributions); ok { + addContentsToProvider(&p, m) + } else { + ctx.ModuleErrorf("%s is not an apex_contributions module\n", child.Name()) + } + }) SetProvider(ctx, PrebuiltSelectionInfoProvider, p) }