diff options
author | 2023-03-28 22:56:41 +0000 | |
---|---|---|
committer | 2023-03-28 22:56:41 +0000 | |
commit | 709dbd08a0ff03889325ca253006ea402dd44163 (patch) | |
tree | f786d8d1928a56cbf689367074fac23286fa0d70 /java/java.go | |
parent | f2571c4136d578359b0748af548f24036749f0f8 (diff) | |
parent | cb368ea88adb2b7c9b196e5e5d2c57e7b8a0f421 (diff) |
Merge "Compile stubs to .dex"
Diffstat (limited to 'java/java.go')
-rw-r--r-- | java/java.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go index c0636f716..ebd9f5ef2 100644 --- a/java/java.go +++ b/java/java.go @@ -1613,10 +1613,15 @@ type ApiLibrary struct { android.ModuleBase android.DefaultableModuleBase + hiddenAPI + dexer + properties JavaApiLibraryProperties stubsSrcJar android.WritablePath stubsJar android.WritablePath + // .dex of stubs, used for hiddenapi processing + dexJarFile OptionalDexJarPath } type JavaApiLibraryProperties struct { @@ -1794,6 +1799,20 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { Inputs(staticLibs) builder.Build("merge_zips", "merge jar files") + // compile stubs to .dex for hiddenapi processing + dexParams := &compileDexParams{ + flags: javaBuilderFlags{}, + sdkVersion: al.SdkVersion(ctx), + minSdkVersion: al.MinSdkVersion(ctx), + classesJar: al.stubsJar, + jarName: ctx.ModuleName() + ".jar", + } + dexOutputFile := al.dexer.compileDex(ctx, dexParams) + uncompressed := true + al.initHiddenAPI(ctx, makeDexJarPathFromPath(dexOutputFile), al.stubsJar, &uncompressed) + dexOutputFile = al.hiddenAPIEncodeDex(ctx, dexOutputFile) + al.dexJarFile = makeDexJarPathFromPath(dexOutputFile) + ctx.Phony(ctx.ModuleName(), al.stubsJar) ctx.SetProvider(JavaInfoProvider, JavaInfo{ @@ -1801,6 +1820,32 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { }) } +func (al *ApiLibrary) DexJarBuildPath() OptionalDexJarPath { + return al.dexJarFile +} + +func (al *ApiLibrary) DexJarInstallPath() android.Path { + return al.dexJarFile.Path() +} + +func (al *ApiLibrary) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap { + return nil +} + +// java_api_library constitutes the sdk, and does not build against one +func (al *ApiLibrary) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { + return android.SdkSpecNone +} + +// java_api_library is always at "current". Return FutureApiLevel +func (al *ApiLibrary) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel { + return android.FutureApiLevel +} + +// implement the following interfaces for hiddenapi processing +var _ hiddenAPIModule = (*ApiLibrary)(nil) +var _ UsesLibraryDependency = (*ApiLibrary)(nil) + // // Java prebuilts // |