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
Merged-In: Ief8136fa9e98600cdd8d36108ec22edc2ebd7c69
Change-Id: Ief8136fa9e98600cdd8d36108ec22edc2ebd7c69
(cherry picked from commit 66cdbf07ef2af6caf42e2c7b77b1a5fb86a4cee3)
This commit is contained in:
Paul Duffin 2021-05-14 16:35:06 +01:00
parent 78fc68695e
commit 59190602af
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.
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
Stem *string
@ -1501,15 +1495,6 @@ func (j *Module) Stem() string {
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 {
return j.jacocoReportClassesFile
}

View File

@ -26,11 +26,6 @@ var hiddenAPIGenerateCSVRule = pctx.AndroidStaticRule("hiddenAPIGenerateCSV", bl
}, "outFlag", "stubAPIFlags")
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
// that information encoded within it.
active bool
@ -84,14 +79,12 @@ type hiddenAPIIntf interface {
var _ hiddenAPIIntf = (*hiddenAPI)(nil)
// 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 ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
return
}
h.configurationName = configurationName
// 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.
if !ctx.Config().FrameworksBaseDirExists(ctx) && ctx.Config().PrebuiltHiddenApiDir(ctx) == "" {
@ -119,12 +112,6 @@ func (h *hiddenAPI) initHiddenAPI(ctx android.BaseModuleContext, configurationNa
primary = p.UsePrebuilt()
}
} 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.
if module.IsReplacedByPrebuilt() {
if ctx.HasProvider(android.ApexInfoProvider) {
@ -172,7 +159,7 @@ func (h *hiddenAPI) hiddenAPIEncodeDex(ctx android.ModuleContext, dexJar android
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.
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) {
// Initialize the hiddenapi structure. Pass in the configuration name rather than the module name
// so the hidden api will encode the <x>.impl java_ library created by java_sdk_library just as it
// would the <x> library if <x> was configured as a boot jar.
j.initHiddenAPI(ctx, j.ConfigurationName())
// Initialize the hiddenapi structure.
j.initHiddenAPI(ctx)
j.sdkVersion = j.SdkVersion(ctx)
j.minSdkVersion = j.MinSdkVersion(ctx)
@ -1242,7 +1240,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.minSdkVersion = j.MinSdkVersion(ctx)
// Initialize the hiddenapi structure.
j.initHiddenAPI(ctx, j.BaseModuleName())
j.initHiddenAPI(ctx)
if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() {
j.hideApexVariantFromMake = true

View File

@ -1235,16 +1235,13 @@ func childModuleVisibility(childVisibility []string) []string {
// Creates the implementation java library
func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) {
moduleNamePtr := proptools.StringPtr(module.BaseModuleName())
visibility := childModuleVisibility(module.sdkLibraryProperties.Impl_library_visibility)
props := struct {
Name *string
Visibility []string
Instrument bool
Libs []string
ConfigurationName *string
Name *string
Visibility []string
Instrument bool
Libs []string
}{
Name: proptools.StringPtr(module.implLibraryModuleName()),
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
// addition of &module.properties below.
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{}{
@ -2127,7 +2121,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
if dexOutputPath := di.PrebuiltExportPath(module.BaseModuleName(), ".dexjar"); dexOutputPath != nil {
module.dexJarFile = dexOutputPath
module.initHiddenAPI(ctx, module.configurationName)
module.initHiddenAPI(ctx)
module.hiddenAPIUpdatePaths(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0])
} else {
// This should never happen as a variant for a prebuilt_apex is only created if the