summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2021-02-01 19:01:34 +0000
committerPaul Duffin <paulduffin@google.com>2021-02-08 19:10:50 +0000
commit4103e92c4b8f1a30a82a32e8e22ed722ec7a866b (patch)
tree5ae0e9a3217eb4f182079267581c85c8b1ad01df /java/java.go
parent5d0572b7ebbe54e88db03c8594f6b2b4c290cb7f (diff)
Extract initHiddenAPI() from hiddenapi()
Previously, the hiddenapi() method combined both checks to determine whether a module contributed to/was modified by the hiddenapi process and logic to create ninja rules to perform those tasks. This change separates the former out into a new initHiddenAPI() method. The main purpose of this is to simplify the process of allowing the CSV generation to be separated from the encoding. That is required because when a java_import retrieves its dex file from the apex it has already been encoded. The initHiddenAPI() method is only called for java.Library (and indirectly for java.SdkLibrary) and java.Import modules which means that the hiddenapi() method does nothing for any other module type. That is consistent with the previous behaviour because while the hiddenapi() method is called for other module types they fail because the boot image jars only support java_library, java_sdk_library, and java_import at the moment. While it will need to support java_sdk_library_import once any of the libraries that are currently provided as java_sdk_library modules switches to providing prebuilts that is outside the scope of this work. Bug: 178361284 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Change-Id: Iaa91e0a8e2bffec03296dd894e9662556f4464c0
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go
index bed232b4e..cee14cc4b 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2090,6 +2090,11 @@ 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())
}
@@ -2149,6 +2154,11 @@ 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())
+
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
if !apexInfo.IsForPlatform() {
j.hideApexVariantFromMake = true
@@ -2849,6 +2859,9 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
}
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ // Initialize the hiddenapi structure.
+ j.initHiddenAPI(ctx, j.BaseModuleName())
+
if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() {
j.hideApexVariantFromMake = true
}