Remove configurationName from java library and hidden API

The configurationName was intended to separate the name of the module
from the name used in configuration (such as BootJars) so that the
child implementation library of a java_sdk_library on the bootclasspath
would have hidden API encoding performed on it just as for the main
java_library embedded within the java_sdk_library.

While that did use to work it no longer does as the test added in the
preceding change proves. It is not surprising that this regression does
not appear to have caused any issues as the the child implementation
library is only a build time artifact and not used at runtime.

In future the only modules that will require hidden API encoding are
those that are part of a bootclasspath module so there is no point in
maintaining this capability.

Bug: 179354495
Test: m droid
Change-Id: Ief8136fa9e98600cdd8d36108ec22edc2ebd7c69
This commit is contained in:
Paul Duffin
2021-05-14 16:35:06 +01:00
parent 0d586581d1
commit 66cdbf07ef
4 changed files with 10 additions and 46 deletions

View File

@@ -229,12 +229,6 @@ type DeviceProperties struct {
// otherwise provides defaults libraries to add to the bootclasspath. // otherwise provides defaults libraries to add to the bootclasspath.
System_modules *string System_modules *string
// The name of the module as used in build configuration.
//
// Allows a library to separate its actual name from the name used in
// build configuration, e.g.ctx.Config().BootJars().
ConfigurationName *string `blueprint:"mutated"`
// set the name of the output // set the name of the output
Stem *string Stem *string
@@ -1501,15 +1495,6 @@ func (j *Module) Stem() string {
return proptools.StringDefault(j.deviceProperties.Stem, j.Name()) return proptools.StringDefault(j.deviceProperties.Stem, j.Name())
} }
// ConfigurationName returns the name of the module as used in build configuration.
//
// This is usually the same as BaseModuleName() except for the <x>.impl libraries created by
// java_sdk_library in which case this is the BaseModuleName() without the ".impl" suffix,
// i.e. just <x>.
func (j *Module) ConfigurationName() string {
return proptools.StringDefault(j.deviceProperties.ConfigurationName, j.BaseModuleName())
}
func (j *Module) JacocoReportClassesFile() android.Path { func (j *Module) JacocoReportClassesFile() android.Path {
return j.jacocoReportClassesFile return j.jacocoReportClassesFile
} }

View File

@@ -26,11 +26,6 @@ var hiddenAPIGenerateCSVRule = pctx.AndroidStaticRule("hiddenAPIGenerateCSV", bl
}, "outFlag", "stubAPIFlags") }, "outFlag", "stubAPIFlags")
type hiddenAPI struct { type hiddenAPI struct {
// The name of the module as it would be used in the boot jars configuration, e.g. without any
// prebuilt_ prefix (if it is a prebuilt) and without any ".impl" suffix if it is a
// java_sdk_library implementation library.
configurationName string
// True if the module containing this structure contributes to the hiddenapi information or has // True if the module containing this structure contributes to the hiddenapi information or has
// that information encoded within it. // that information encoded within it.
active bool active bool
@@ -84,14 +79,12 @@ type hiddenAPIIntf interface {
var _ hiddenAPIIntf = (*hiddenAPI)(nil) var _ hiddenAPIIntf = (*hiddenAPI)(nil)
// Initialize the hiddenapi structure // Initialize the hiddenapi structure
func (h *hiddenAPI) initHiddenAPI(ctx android.BaseModuleContext, configurationName string) { func (h *hiddenAPI) initHiddenAPI(ctx android.BaseModuleContext) {
// If hiddenapi processing is disabled treat this as inactive. // If hiddenapi processing is disabled treat this as inactive.
if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") { if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
return return
} }
h.configurationName = configurationName
// If the frameworks/base directories does not exist and no prebuilt hidden API flag files have // If the frameworks/base directories does not exist and no prebuilt hidden API flag files have
// been configured then it is not possible to do hidden API encoding. // been configured then it is not possible to do hidden API encoding.
if !ctx.Config().FrameworksBaseDirExists(ctx) && ctx.Config().PrebuiltHiddenApiDir(ctx) == "" { if !ctx.Config().FrameworksBaseDirExists(ctx) && ctx.Config().PrebuiltHiddenApiDir(ctx) == "" {
@@ -119,12 +112,6 @@ func (h *hiddenAPI) initHiddenAPI(ctx android.BaseModuleContext, configurationNa
primary = p.UsePrebuilt() primary = p.UsePrebuilt()
} }
} else { } else {
// The only module that will pass a different configurationName to its module name to this
// method is the implementation library of a java_sdk_library. It has a configuration name of
// <x> the same as its parent java_sdk_library but a module name of <x>.impl. It is not the
// primary module, the java_sdk_library with the name of <x> is.
primary = configurationName == ctx.ModuleName()
// A source module that has been replaced by a prebuilt can never be the primary module. // A source module that has been replaced by a prebuilt can never be the primary module.
if module.IsReplacedByPrebuilt() { if module.IsReplacedByPrebuilt() {
if ctx.HasProvider(android.ApexInfoProvider) { if ctx.HasProvider(android.ApexInfoProvider) {
@@ -172,7 +159,7 @@ func (h *hiddenAPI) hiddenAPIEncodeDex(ctx android.ModuleContext, dexJar android
return dexJar return dexJar
} }
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", h.configurationName+".jar").OutputPath hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", dexJar.Base()).OutputPath
// Create a copy of the dex jar which has been encoded with hiddenapi flags. // Create a copy of the dex jar which has been encoded with hiddenapi flags.
hiddenAPIEncodeDex(ctx, hiddenAPIJar, dexJar, uncompressDex) hiddenAPIEncodeDex(ctx, hiddenAPIJar, dexJar, uncompressDex)

View File

@@ -481,10 +481,8 @@ func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bo
} }
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Initialize the hiddenapi structure. Pass in the configuration name rather than the module name // Initialize the hiddenapi structure.
// so the hidden api will encode the <x>.impl java_ library created by java_sdk_library just as it j.initHiddenAPI(ctx)
// would the <x> library if <x> was configured as a boot jar.
j.initHiddenAPI(ctx, j.ConfigurationName())
j.sdkVersion = j.SdkVersion(ctx) j.sdkVersion = j.SdkVersion(ctx)
j.minSdkVersion = j.MinSdkVersion(ctx) j.minSdkVersion = j.MinSdkVersion(ctx)
@@ -1242,7 +1240,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.minSdkVersion = j.MinSdkVersion(ctx) j.minSdkVersion = j.MinSdkVersion(ctx)
// Initialize the hiddenapi structure. // Initialize the hiddenapi structure.
j.initHiddenAPI(ctx, j.BaseModuleName()) j.initHiddenAPI(ctx)
if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() { if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() {
j.hideApexVariantFromMake = true j.hideApexVariantFromMake = true

View File

@@ -1235,8 +1235,6 @@ func childModuleVisibility(childVisibility []string) []string {
// Creates the implementation java library // Creates the implementation java library
func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) { func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) {
moduleNamePtr := proptools.StringPtr(module.BaseModuleName())
visibility := childModuleVisibility(module.sdkLibraryProperties.Impl_library_visibility) visibility := childModuleVisibility(module.sdkLibraryProperties.Impl_library_visibility)
props := struct { props := struct {
@@ -1244,7 +1242,6 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext)
Visibility []string Visibility []string
Instrument bool Instrument bool
Libs []string Libs []string
ConfigurationName *string
}{ }{
Name: proptools.StringPtr(module.implLibraryModuleName()), Name: proptools.StringPtr(module.implLibraryModuleName()),
Visibility: visibility, Visibility: visibility,
@@ -1253,9 +1250,6 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext)
// Set the impl_only libs. Note that the module's "Libs" get appended as well, via the // Set the impl_only libs. Note that the module's "Libs" get appended as well, via the
// addition of &module.properties below. // addition of &module.properties below.
Libs: module.sdkLibraryProperties.Impl_only_libs, Libs: module.sdkLibraryProperties.Impl_only_libs,
// Make the created library behave as if it had the same name as this module.
ConfigurationName: moduleNamePtr,
} }
properties := []interface{}{ properties := []interface{}{
@@ -2127,7 +2121,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo) di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
if dexOutputPath := di.PrebuiltExportPath(module.BaseModuleName(), ".dexjar"); dexOutputPath != nil { if dexOutputPath := di.PrebuiltExportPath(module.BaseModuleName(), ".dexjar"); dexOutputPath != nil {
module.dexJarFile = dexOutputPath module.dexJarFile = dexOutputPath
module.initHiddenAPI(ctx, module.configurationName) module.initHiddenAPI(ctx)
module.hiddenAPIUpdatePaths(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0]) module.hiddenAPIUpdatePaths(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0])
} else { } else {
// This should never happen as a variant for a prebuilt_apex is only created if the // This should never happen as a variant for a prebuilt_apex is only created if the