Merge "Reland: Deduplicate APEX variants that would build identically"

This commit is contained in:
Treehugger Robot
2020-08-21 06:46:51 +00:00
committed by Gerrit Code Review
11 changed files with 418 additions and 104 deletions

View File

@@ -1375,22 +1375,22 @@ func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) and
return android.Paths{jarPath.Path()}
}
// Get the apex name for module, "" if it is for platform.
func getApexNameForModule(module android.Module) string {
// Get the apex names for module, nil if it is for platform.
func getApexNamesForModule(module android.Module) []string {
if apex, ok := module.(android.ApexModule); ok {
return apex.ApexVariationName()
return apex.InApexes()
}
return ""
return nil
}
// Check to see if the other module is within the same named APEX as this module.
// Check to see if the other module is within the same set of named APEXes as this module.
//
// If either this or the other module are on the platform then this will return
// false.
func withinSameApexAs(module android.ApexModule, other android.Module) bool {
name := module.ApexVariationName()
return name != "" && getApexNameForModule(other) == name
func withinSameApexesAs(module android.ApexModule, other android.Module) bool {
names := module.InApexes()
return len(names) > 0 && reflect.DeepEqual(names, getApexNamesForModule(other))
}
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkSpec, headerJars bool) android.Paths {
@@ -1409,7 +1409,7 @@ func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkS
// Only allow access to the implementation library in the following condition:
// * No sdk_version specified on the referencing module.
// * The referencing module is in the same apex as this.
if sdkVersion.kind == sdkPrivate || withinSameApexAs(module, ctx.Module()) {
if sdkVersion.kind == sdkPrivate || withinSameApexesAs(module, ctx.Module()) {
if headerJars {
return module.HeaderJars()
} else {
@@ -1948,7 +1948,7 @@ func (module *SdkLibraryImport) sdkJars(ctx android.BaseModuleContext, sdkVersio
// For consistency with SdkLibrary make the implementation jar available to libraries that
// are within the same APEX.
implLibraryModule := module.implLibraryModule
if implLibraryModule != nil && withinSameApexAs(module, ctx.Module()) {
if implLibraryModule != nil && withinSameApexesAs(module, ctx.Module()) {
if headerJars {
return implLibraryModule.HeaderJars()
} else {
@@ -2064,6 +2064,12 @@ func sdkLibraryXmlFactory() android.Module {
return module
}
func (module *sdkLibraryXml) UniqueApexVariations() bool {
// sdkLibraryXml needs a unique variation per APEX because the generated XML file contains the path to the
// mounted APEX, which contains the name of the APEX.
return true
}
// from android.PrebuiltEtcModule
func (module *sdkLibraryXml) SubDir() string {
return "permissions"