Rename InApexes -> InApexVariants
.. in preparation for the upcoming change. This change doesn't alter any behavior. InApexes is a misleading name. People expects that it has the list of soong module names of the APEXes that a module is part of. So, for example, `core-oj` is a part of both `com.android.art` and `com.google.android.art`. However, in reality, that's not true. The field has `com.android.art` only. This is because the two APEXes (android and Google) have the same apex name which is `com.android.art`. That apex name is used in various places like the `apex_available` and allows us to keep using the same name regardless of whether the APEX is overridden or not. However, this is causing problems in some cases where the exact list of soong module names is required. The upcoming change will add a new field to handle the case and the new field actually will get the name 'InApexes'. So, the existing field is renamed to a less misleading name `InApexVariants`. Bug: 180325915 Test: m nothing Change-Id: I0c73361b452eddb812acd5ebef5dcedaab382436
This commit is contained in:
@@ -36,11 +36,16 @@ var (
|
|||||||
// Accessible via `ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)`
|
// Accessible via `ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)`
|
||||||
type ApexInfo struct {
|
type ApexInfo struct {
|
||||||
// Name of the apex variation that this module (i.e. the apex variant of the module) is
|
// Name of the apex variation that this module (i.e. the apex variant of the module) is
|
||||||
// mutated into, or "" for a platform (i.e. non-APEX) variant. Note that a module can be
|
// mutated into, or "" for a platform (i.e. non-APEX) variant. Note that this name and the
|
||||||
// included in multiple APEXes, in which case, the module is mutated into one or more
|
// Soong module name of the APEX can be different. That happens when there is
|
||||||
// variants, each of which is for an APEX. The variants then can later be deduped if they
|
// `override_apex` that overrides `apex`. In that case, both Soong modules have the same
|
||||||
// don't need to be compiled differently. This is an optimization done in
|
// apex variation name which usually is `com.android.foo`. This name is also the `name`
|
||||||
// mergeApexVariations.
|
// in the path `/apex/<name>` where this apex is activated on at runtime.
|
||||||
|
//
|
||||||
|
// Also note that a module can be included in multiple APEXes, in which case, the module is
|
||||||
|
// mutated into one or more variants, each of which is for an APEX. The variants then can
|
||||||
|
// later be deduped if they don't need to be compiled differently. This is an optimization
|
||||||
|
// done in mergeApexVariations.
|
||||||
ApexVariationName string
|
ApexVariationName string
|
||||||
|
|
||||||
// ApiLevel that this module has to support at minimum.
|
// ApiLevel that this module has to support at minimum.
|
||||||
@@ -52,11 +57,11 @@ type ApexInfo struct {
|
|||||||
// The list of SDK modules that the containing apexBundle depends on.
|
// The list of SDK modules that the containing apexBundle depends on.
|
||||||
RequiredSdks SdkRefs
|
RequiredSdks SdkRefs
|
||||||
|
|
||||||
// List of apexBundles that this apex variant of the module is associated with. Initially,
|
// List of Apex variant names that this module is associated with. This initially is the
|
||||||
// the size of this list is one because one apex variant is associated with one apexBundle.
|
// same as the `ApexVariationName` field. Then when multiple apex variants are merged in
|
||||||
// When multiple apex variants are merged in mergeApexVariations, ApexInfo struct of the
|
// mergeApexVariations, ApexInfo struct of the merged variant holds the list of apexBundles
|
||||||
// merged variant holds the list of apexBundles that are merged together.
|
// that are merged together.
|
||||||
InApexes []string
|
InApexVariants []string
|
||||||
|
|
||||||
// Pointers to the ApexContents struct each of which is for apexBundle modules that this
|
// Pointers to the ApexContents struct each of which is for apexBundle modules that this
|
||||||
// module is part of. The ApexContents gives information about which modules the apexBundle
|
// module is part of. The ApexContents gives information about which modules the apexBundle
|
||||||
@@ -93,23 +98,24 @@ func (i ApexInfo) IsForPlatform() bool {
|
|||||||
return i.ApexVariationName == ""
|
return i.ApexVariationName == ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// InApex tells whether this apex variant of the module is part of the given apexBundle or not.
|
// InApexVariant tells whether this apex variant of the module is part of the given apexVariant or
|
||||||
func (i ApexInfo) InApex(apex string) bool {
|
// not.
|
||||||
for _, a := range i.InApexes {
|
func (i ApexInfo) InApexVariant(apexVariant string) bool {
|
||||||
if a == apex {
|
for _, a := range i.InApexVariants {
|
||||||
|
if a == apexVariant {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// InApexByBaseName tells whether this apex variant of the module is part of the given APEX or not,
|
// InApexByBaseName tells whether this apex variant of the module is part of the given apexVariant
|
||||||
// where the APEX is specified by its canonical base name, i.e. typically beginning with
|
// or not, where the APEX is specified by its canonical base name, i.e. typically beginning with
|
||||||
// "com.android.". In particular this function doesn't differentiate between source and prebuilt
|
// "com.android.". In particular this function doesn't differentiate between source and prebuilt
|
||||||
// APEXes, where the latter may have "prebuilt_" prefixes.
|
// APEXes, where the latter may have "prebuilt_" prefixes.
|
||||||
func (i ApexInfo) InApexByBaseName(apex string) bool {
|
func (i ApexInfo) InApexVariantByBaseName(apexVariant string) bool {
|
||||||
for _, a := range i.InApexes {
|
for _, a := range i.InApexVariants {
|
||||||
if RemoveOptionalPrebuiltPrefix(a) == apex {
|
if RemoveOptionalPrebuiltPrefix(a) == apexVariant {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -496,21 +502,21 @@ func mergeApexVariations(ctx PathContext, apexInfos []ApexInfo) (merged []ApexIn
|
|||||||
// Merge the ApexInfo together. If a compatible ApexInfo exists then merge the information from
|
// Merge the ApexInfo together. If a compatible ApexInfo exists then merge the information from
|
||||||
// this one into it, otherwise create a new merged ApexInfo from this one and save it away so
|
// this one into it, otherwise create a new merged ApexInfo from this one and save it away so
|
||||||
// other ApexInfo instances can be merged into it.
|
// other ApexInfo instances can be merged into it.
|
||||||
apexName := apexInfo.ApexVariationName
|
variantName := apexInfo.ApexVariationName
|
||||||
mergedName := apexInfo.mergedName(ctx)
|
mergedName := apexInfo.mergedName(ctx)
|
||||||
if index, exists := seen[mergedName]; exists {
|
if index, exists := seen[mergedName]; exists {
|
||||||
// Variants having the same mergedName are deduped
|
// Variants having the same mergedName are deduped
|
||||||
merged[index].InApexes = append(merged[index].InApexes, apexName)
|
merged[index].InApexVariants = append(merged[index].InApexVariants, variantName)
|
||||||
merged[index].ApexContents = append(merged[index].ApexContents, apexInfo.ApexContents...)
|
merged[index].ApexContents = append(merged[index].ApexContents, apexInfo.ApexContents...)
|
||||||
merged[index].Updatable = merged[index].Updatable || apexInfo.Updatable
|
merged[index].Updatable = merged[index].Updatable || apexInfo.Updatable
|
||||||
} else {
|
} else {
|
||||||
seen[mergedName] = len(merged)
|
seen[mergedName] = len(merged)
|
||||||
apexInfo.ApexVariationName = mergedName
|
apexInfo.ApexVariationName = mergedName
|
||||||
apexInfo.InApexes = CopyOf(apexInfo.InApexes)
|
apexInfo.InApexVariants = CopyOf(apexInfo.InApexVariants)
|
||||||
apexInfo.ApexContents = append([]*ApexContents(nil), apexInfo.ApexContents...)
|
apexInfo.ApexContents = append([]*ApexContents(nil), apexInfo.ApexContents...)
|
||||||
merged = append(merged, apexInfo)
|
merged = append(merged, apexInfo)
|
||||||
}
|
}
|
||||||
aliases = append(aliases, [2]string{apexName, mergedName})
|
aliases = append(aliases, [2]string{variantName, mergedName})
|
||||||
}
|
}
|
||||||
return merged, aliases
|
return merged, aliases
|
||||||
}
|
}
|
||||||
@@ -583,15 +589,15 @@ func CreateApexVariations(mctx BottomUpMutatorContext, module ApexModule) []Modu
|
|||||||
// in the same APEX have unique APEX variations so that the module can link against the right
|
// in the same APEX have unique APEX variations so that the module can link against the right
|
||||||
// variant.
|
// variant.
|
||||||
func UpdateUniqueApexVariationsForDeps(mctx BottomUpMutatorContext, am ApexModule) {
|
func UpdateUniqueApexVariationsForDeps(mctx BottomUpMutatorContext, am ApexModule) {
|
||||||
// anyInSameApex returns true if the two ApexInfo lists contain any values in an InApexes
|
// anyInSameApex returns true if the two ApexInfo lists contain any values in an
|
||||||
// list in common. It is used instead of DepIsInSameApex because it needs to determine if
|
// InApexVariants list in common. It is used instead of DepIsInSameApex because it needs to
|
||||||
// the dep is in the same APEX due to being directly included, not only if it is included
|
// determine if the dep is in the same APEX due to being directly included, not only if it
|
||||||
// _because_ it is a dependency.
|
// is included _because_ it is a dependency.
|
||||||
anyInSameApex := func(a, b []ApexInfo) bool {
|
anyInSameApex := func(a, b []ApexInfo) bool {
|
||||||
collectApexes := func(infos []ApexInfo) []string {
|
collectApexes := func(infos []ApexInfo) []string {
|
||||||
var ret []string
|
var ret []string
|
||||||
for _, info := range infos {
|
for _, info := range infos {
|
||||||
ret = append(ret, info.InApexes...)
|
ret = append(ret, info.InApexVariants...)
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
@@ -911,7 +911,7 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
|
|||||||
MinSdkVersion: minSdkVersion,
|
MinSdkVersion: minSdkVersion,
|
||||||
RequiredSdks: a.RequiredSdks(),
|
RequiredSdks: a.RequiredSdks(),
|
||||||
Updatable: a.Updatable(),
|
Updatable: a.Updatable(),
|
||||||
InApexes: []string{mctx.ModuleName()},
|
InApexVariants: []string{mctx.ModuleName()},
|
||||||
ApexContents: []*android.ApexContents{apexContents},
|
ApexContents: []*android.ApexContents{apexContents},
|
||||||
}
|
}
|
||||||
mctx.WalkDeps(func(child, parent android.Module) bool {
|
mctx.WalkDeps(func(child, parent android.Module) bool {
|
||||||
@@ -1604,7 +1604,7 @@ func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.Paylo
|
|||||||
}
|
}
|
||||||
|
|
||||||
ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
|
ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
|
||||||
externalDep := !android.InList(ctx.ModuleName(), ai.InApexes)
|
externalDep := !android.InList(ctx.ModuleName(), ai.InApexVariants)
|
||||||
|
|
||||||
// Visit actually
|
// Visit actually
|
||||||
return do(ctx, parent, am, externalDep)
|
return do(ctx, parent, am, externalDep)
|
||||||
|
@@ -230,7 +230,7 @@ func (p *prebuiltCommon) apexInfoMutator(mctx android.TopDownMutatorContext) {
|
|||||||
// Create an ApexInfo for the prebuilt_apex.
|
// Create an ApexInfo for the prebuilt_apex.
|
||||||
apexInfo := android.ApexInfo{
|
apexInfo := android.ApexInfo{
|
||||||
ApexVariationName: android.RemoveOptionalPrebuiltPrefix(mctx.ModuleName()),
|
ApexVariationName: android.RemoveOptionalPrebuiltPrefix(mctx.ModuleName()),
|
||||||
InApexes: []string{mctx.ModuleName()},
|
InApexVariants: []string{mctx.ModuleName()},
|
||||||
ApexContents: []*android.ApexContents{apexContents},
|
ApexContents: []*android.ApexContents{apexContents},
|
||||||
ForPrebuiltApex: true,
|
ForPrebuiltApex: true,
|
||||||
}
|
}
|
||||||
|
2
cc/cc.go
2
cc/cc.go
@@ -2833,7 +2833,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
// Add the dependency to the APEX(es) providing the library so that
|
// Add the dependency to the APEX(es) providing the library so that
|
||||||
// m <module> can trigger building the APEXes as well.
|
// m <module> can trigger building the APEXes as well.
|
||||||
depApexInfo := ctx.OtherModuleProvider(dep, android.ApexInfoProvider).(android.ApexInfo)
|
depApexInfo := ctx.OtherModuleProvider(dep, android.ApexInfoProvider).(android.ApexInfo)
|
||||||
for _, an := range depApexInfo.InApexes {
|
for _, an := range depApexInfo.InApexVariants {
|
||||||
c.Properties.ApexesProvidingSharedLibs = append(
|
c.Properties.ApexesProvidingSharedLibs = append(
|
||||||
c.Properties.ApexesProvidingSharedLibs, an)
|
c.Properties.ApexesProvidingSharedLibs, an)
|
||||||
}
|
}
|
||||||
|
@@ -89,7 +89,7 @@ func (b *bootJarsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
name := android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName(module))
|
name := android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName(module))
|
||||||
if apex, ok := moduleToApex[name]; ok {
|
if apex, ok := moduleToApex[name]; ok {
|
||||||
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
|
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
|
||||||
if (apex == "platform" && apexInfo.IsForPlatform()) || apexInfo.InApexByBaseName(apex) {
|
if (apex == "platform" && apexInfo.IsForPlatform()) || apexInfo.InApexVariantByBaseName(apex) {
|
||||||
// The module name/apex variant should be unique in the system but double check
|
// The module name/apex variant should be unique in the system but double check
|
||||||
// just in case something has gone wrong.
|
// just in case something has gone wrong.
|
||||||
if existing, ok := nameToApexVariant[name]; ok {
|
if existing, ok := nameToApexVariant[name]; ok {
|
||||||
|
@@ -167,11 +167,11 @@ func isModuleInConfiguredList(ctx android.BaseModuleContext, module android.Modu
|
|||||||
// Now match the apex part of the boot image configuration.
|
// Now match the apex part of the boot image configuration.
|
||||||
requiredApex := configuredBootJars.Apex(index)
|
requiredApex := configuredBootJars.Apex(index)
|
||||||
if requiredApex == "platform" || requiredApex == "system_ext" {
|
if requiredApex == "platform" || requiredApex == "system_ext" {
|
||||||
if len(apexInfo.InApexes) != 0 {
|
if len(apexInfo.InApexVariants) != 0 {
|
||||||
// A platform variant is required but this is for an apex so ignore it.
|
// A platform variant is required but this is for an apex so ignore it.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else if !apexInfo.InApexByBaseName(requiredApex) {
|
} else if !apexInfo.InApexVariantByBaseName(requiredApex) {
|
||||||
// An apex variant for a specific apex is required but this is the wrong apex.
|
// An apex variant for a specific apex is required but this is the wrong apex.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@@ -225,7 +225,7 @@ func (b *platformBootclasspathModule) checkNonUpdatableModules(ctx android.Modul
|
|||||||
fromUpdatableApex := apexInfo.Updatable
|
fromUpdatableApex := apexInfo.Updatable
|
||||||
if fromUpdatableApex {
|
if fromUpdatableApex {
|
||||||
// error: this jar is part of an updatable apex
|
// error: this jar is part of an updatable apex
|
||||||
ctx.ModuleErrorf("module %q from updatable apexes %q is not allowed in the framework boot image", ctx.OtherModuleName(m), apexInfo.InApexes)
|
ctx.ModuleErrorf("module %q from updatable apexes %q is not allowed in the framework boot image", ctx.OtherModuleName(m), apexInfo.InApexVariants)
|
||||||
} else {
|
} else {
|
||||||
// ok: this jar is part of the platform or a non-updatable apex
|
// ok: this jar is part of the platform or a non-updatable apex
|
||||||
}
|
}
|
||||||
|
@@ -1546,7 +1546,7 @@ func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s android.SdkS
|
|||||||
func withinSameApexesAs(ctx android.BaseModuleContext, other android.Module) bool {
|
func withinSameApexesAs(ctx android.BaseModuleContext, other android.Module) bool {
|
||||||
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
||||||
otherApexInfo := ctx.OtherModuleProvider(other, android.ApexInfoProvider).(android.ApexInfo)
|
otherApexInfo := ctx.OtherModuleProvider(other, android.ApexInfoProvider).(android.ApexInfo)
|
||||||
return len(otherApexInfo.InApexes) > 0 && reflect.DeepEqual(apexInfo.InApexes, otherApexInfo.InApexes)
|
return len(otherApexInfo.InApexVariants) > 0 && reflect.DeepEqual(apexInfo.InApexVariants, otherApexInfo.InApexVariants)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec, headerJars bool) android.Paths {
|
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec, headerJars bool) android.Paths {
|
||||||
|
@@ -24,6 +24,7 @@ import (
|
|||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/cc"
|
"android/soong/cc"
|
||||||
"android/soong/dexpreopt"
|
"android/soong/dexpreopt"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -371,7 +372,7 @@ func apexNamePairFromModule(ctx *android.TestContext, module android.Module) str
|
|||||||
if apexInfo.IsForPlatform() {
|
if apexInfo.IsForPlatform() {
|
||||||
apex = "platform"
|
apex = "platform"
|
||||||
} else {
|
} else {
|
||||||
apex = apexInfo.InApexes[0]
|
apex = apexInfo.InApexVariants[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s:%s", apex, name)
|
return fmt.Sprintf("%s:%s", apex, name)
|
||||||
|
Reference in New Issue
Block a user