aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-06-27 01:08:36 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-06-27 01:08:36 +0000
commit6b0b3faf73fb1dff73dd408d1e1f636534789d39 (patch)
tree3ab8dd6f8c982103b80b2789f262e7f844ea1dbb
parent76db5d66913c7398f54d59634de930149caf90b6 (diff)
parentc4422106a7cf4731e27d664646bc0d57ad3f37fa (diff)
downloadsoong-6b0b3faf73fb1dff73dd408d1e1f636534789d39.tar.gz
Snap for 6634012 from c4422106a7cf4731e27d664646bc0d57ad3f37fa to rvc-release
Change-Id: Idfd3a3487b11fdc16265d015d34aa79237cab6e8
-rw-r--r--java/hiddenapi.go12
-rw-r--r--java/java.go15
-rw-r--r--java/sdk_library.go13
3 files changed, 33 insertions, 7 deletions
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index ce624bfc1..130b63496 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -59,10 +59,9 @@ type hiddenAPIIntf interface {
var _ hiddenAPIIntf = (*hiddenAPI)(nil)
-func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, dexJar android.ModuleOutPath,
+func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, name string, primary bool, dexJar android.ModuleOutPath,
implementationJar android.Path, uncompressDex bool) android.ModuleOutPath {
if !ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
- name := ctx.ModuleName()
// Modules whose names are of the format <x>-hiddenapi provide hiddenapi information
// for the boot jar module <x>. Otherwise, the module provides information for itself.
@@ -90,7 +89,14 @@ func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, dexJar android.ModuleOu
// the gathered information in the generated dex file.
if name == bootJarName {
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", name+".jar")
- h.bootDexJarPath = dexJar
+
+ // More than one library with the same classes can be encoded but only one can
+ // be added to the global set of flags, otherwise it will result in duplicate
+ // classes which is an error. Therefore, only add the dex jar of one of them
+ // to the global set of flags.
+ if primary {
+ h.bootDexJarPath = dexJar
+ }
hiddenAPIEncodeDex(ctx, hiddenAPIJar, dexJar, uncompressDex)
dexJar = hiddenAPIJar
}
diff --git a/java/java.go b/java/java.go
index 90e9b1f6f..5632ff586 100644
--- a/java/java.go
+++ b/java/java.go
@@ -342,6 +342,12 @@ type CompilerDeviceProperties 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
@@ -1617,8 +1623,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
return
}
+ configurationName := j.ConfigurationName()
+ primary := configurationName == ctx.ModuleName()
+
// Hidden API CSV generation and dex encoding
- dexOutputFile = j.hiddenAPI.hiddenAPI(ctx, dexOutputFile, j.implementationJarFile,
+ dexOutputFile = j.hiddenAPI.hiddenAPI(ctx, configurationName, primary, dexOutputFile, j.implementationJarFile,
proptools.Bool(j.deviceProperties.Uncompress_dex))
// merge dex jar with resources if necessary
@@ -1872,6 +1881,10 @@ func (j *Module) Stem() string {
return proptools.StringDefault(j.deviceProperties.Stem, j.Name())
}
+func (j *Module) ConfigurationName() string {
+ return proptools.StringDefault(j.deviceProperties.ConfigurationName, j.BaseModuleName())
+}
+
func (j *Module) JacocoReportClassesFile() android.Path {
return j.jacocoReportClassesFile
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index e64310fbb..679c07597 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1088,15 +1088,22 @@ func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope *apiScope) stri
// Creates the implementation java library
func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) {
+
+ moduleNamePtr := proptools.StringPtr(module.BaseModuleName())
+
props := struct {
- Name *string
- Visibility []string
- Instrument bool
+ Name *string
+ Visibility []string
+ Instrument bool
+ ConfigurationName *string
}{
Name: proptools.StringPtr(module.implLibraryModuleName()),
Visibility: module.sdkLibraryProperties.Impl_library_visibility,
// Set the instrument property to ensure it is instrumented when instrumentation is required.
Instrument: true,
+
+ // Make the created library behave as if it had the same name as this module.
+ ConfigurationName: moduleNamePtr,
}
properties := []interface{}{