diff options
Diffstat (limited to 'java/java.go')
-rw-r--r-- | java/java.go | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/java/java.go b/java/java.go index 5ed99f7e8..aea1ef90d 100644 --- a/java/java.go +++ b/java/java.go @@ -217,25 +217,6 @@ type CompilerDeviceProperties struct { // If set to true, compile dex regardless of installable. Defaults to false. Compile_dex *bool - Dex_preopt struct { - // If false, prevent dexpreopting and stripping the dex file from the final jar. Defaults to - // true. - Enabled *bool - - // If true, generate an app image (.art file) for this module. - App_image *bool - - // If true, use a checked-in profile to guide optimization. Defaults to false unless - // a matching profile is set or a profile is found in PRODUCT_DEX_PREOPT_PROFILE_DIR - // that matches the name of this module, in which case it is defaulted to true. - Profile_guided *bool - - // If set, provides the path to profile relative to the Android.bp file. If not set, - // defaults to searching for a file that matches the name of this module in the default - // profile location set by PRODUCT_DEX_PREOPT_PROFILE_DIR, or empty if not found. - Profile *string - } - Optimize struct { // If false, disable all optimization. Defaults to true for android_app and android_test // modules, false for java_library and java_test modules. @@ -266,6 +247,7 @@ type CompilerDeviceProperties struct { System_modules *string UncompressDex bool `blueprint:"mutated"` + IsSDKLibrary bool `blueprint:"mutated"` } // Module contains the properties and members used by all java module types @@ -295,6 +277,9 @@ type Module struct { // output file containing classes.dex and resources dexJarFile android.Path + // output file that contains classes.dex if it should be in the output file + maybeStrippedDexJarFile android.Path + // output file containing uninstrumented classes that will be instrumented by jacoco jacocoReportClassesFile android.Path @@ -327,6 +312,8 @@ type Module struct { // list of source files, collected from compiledJavaSrcs and compiledSrcJars // filter out Exclude_srcs, will be used by android.IDEInfo struct expandIDEInfoCompiledSrcs []string + + dexpreopter } func (j *Module) Srcs() android.Paths { @@ -1332,7 +1319,15 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path j.dexJarFile = dexOutputFile + dexOutputFile = j.dexpreopt(ctx, dexOutputFile) + + j.maybeStrippedDexJarFile = dexOutputFile + outputFile = dexOutputFile + + if ctx.Failed() { + return + } } else { outputFile = implementationAndResourcesJar } @@ -1486,9 +1481,17 @@ type Library struct { } func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { + j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", ctx.ModuleName()+".jar") + j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary j.compile(ctx) if Bool(j.properties.Installable) || ctx.Host() { + if j.deviceProperties.UncompressDex { + alignedOutputFile := android.PathForModuleOut(ctx, "aligned", ctx.ModuleName()+".jar") + TransformZipAlign(ctx, alignedOutputFile, j.outputFile) + j.outputFile = alignedOutputFile + } + j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile) } @@ -1504,6 +1507,7 @@ func LibraryFactory() android.Module { module.AddProperties( &module.Module.properties, &module.Module.deviceProperties, + &module.Module.dexpreoptProperties, &module.Module.protoProperties) InitJavaModule(module, android.HostAndDeviceSupported) @@ -1574,6 +1578,7 @@ func TestFactory() android.Module { module.AddProperties( &module.Module.properties, &module.Module.deviceProperties, + &module.Module.dexpreoptProperties, &module.Module.protoProperties, &module.testProperties) @@ -1670,6 +1675,7 @@ func BinaryFactory() android.Module { module.AddProperties( &module.Module.properties, &module.Module.deviceProperties, + &module.Module.dexpreoptProperties, &module.Module.protoProperties, &module.binaryProperties) @@ -1889,6 +1895,7 @@ func DefaultsFactory(props ...interface{}) android.Module { module.AddProperties( &CompilerProperties{}, &CompilerDeviceProperties{}, + &DexpreoptProperties{}, &android.ProtoProperties{}, &aaptProperties{}, &androidLibraryProperties{}, |