Fix inconsistencies in the apex names used for the apex variations.

Add an apex_name property to prebuilt APEX modules to allow specifying
the "runtime" name of the APEX, i.e. the one it gets mounted as in /apex/,
which is also the one used for the apex variations.

Introduce a callback to retrieve that name consistently for all APEX
modules (apex, override_apex, prebuilt_apex, and apex_set), and update
some apex mutator code paths to use it.

For APEX source modules (apex and override_apex), it's necessary to add
a new field in apexBundle, since the name property gets overridden for
the override variant that override_apex creates.

Test: m nothing
Bug: 191269918
Change-Id: If8612639bffdf91cbcab3387b0603bf5dffef1f5
This commit is contained in:
Martin Stjernholm
2021-06-24 14:37:13 +01:00
parent 9477c26f6c
commit bfffae7bec
3 changed files with 90 additions and 22 deletions

View File

@@ -24,7 +24,6 @@ import (
"android/soong/java"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -76,6 +75,10 @@ type sanitizedPrebuilt interface {
type PrebuiltCommonProperties struct {
SelectedApexProperties
// Canonical name of this APEX. Used to determine the path to the activated APEX on
// device (/apex/<apex_name>). If unspecified, follows the name property.
Apex_name *string
ForceDisable bool `blueprint:"mutated"`
// whether the extracted apex file is installable.
@@ -110,6 +113,10 @@ func (p *prebuiltCommon) initPrebuiltCommon(module android.Module, properties *P
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
}
func (p *prebuiltCommon) ApexVariationName() string {
return proptools.StringDefault(p.prebuiltCommonProperties.Apex_name, p.ModuleBase.BaseModuleName())
}
func (p *prebuiltCommon) Prebuilt() *android.Prebuilt {
return &p.prebuilt
}
@@ -390,11 +397,11 @@ func (p *prebuiltCommon) apexInfoMutator(mctx android.TopDownMutatorContext) {
})
// Create an ApexInfo for the prebuilt_apex.
apexVariationName := android.RemoveOptionalPrebuiltPrefix(mctx.ModuleName())
apexVariationName := p.ApexVariationName()
apexInfo := android.ApexInfo{
ApexVariationName: apexVariationName,
InApexVariants: []string{apexVariationName},
InApexModules: []string{apexVariationName},
InApexModules: []string{p.ModuleBase.BaseModuleName()}, // BaseModuleName() to avoid the prebuilt_ prefix.
ApexContents: []*android.ApexContents{apexContents},
ForPrebuiltApex: true,
}