Add R8 support
Add support for R8 to optimize apps and java libraries. Test: m checkbuild Change-Id: I2afd5d7a84912d3ab613c32c599bd1ebe60562e0
This commit is contained in:
37
java/java.go
37
java/java.go
@@ -191,6 +191,32 @@ type CompilerDeviceProperties struct {
|
||||
Profile *string
|
||||
}
|
||||
|
||||
Optimize struct {
|
||||
// If false, disable all optimization. Defaults to true for apps, false for
|
||||
// libraries and tests.
|
||||
Enabled *bool
|
||||
|
||||
// If true, optimize for size by removing unused code. Defaults to true for apps,
|
||||
// false for libraries and tests.
|
||||
Shrink *bool
|
||||
|
||||
// If true, optimize bytecode. Defaults to false.
|
||||
Optimize *bool
|
||||
|
||||
// If true, obfuscate bytecode. Defaults to false.
|
||||
Obfuscate *bool
|
||||
|
||||
// If true, do not use the flag files generated by aapt that automatically keep
|
||||
// classes referenced by the app manifest. Defaults to false.
|
||||
No_aapt_flags *bool
|
||||
|
||||
// Flags to pass to proguard.
|
||||
Proguard_flags []string
|
||||
|
||||
// Specifies the locations of files containing proguard flags.
|
||||
Proguard_flags_files []string
|
||||
}
|
||||
|
||||
// When targeting 1.9, override the modules to use with --system
|
||||
System_modules *string
|
||||
}
|
||||
@@ -216,6 +242,9 @@ type Module struct {
|
||||
// output file containing uninstrumented classes that will be instrumented by jacoco
|
||||
jacocoReportClassesFile android.Path
|
||||
|
||||
// output file containing mapping of obfuscated names
|
||||
proguardDictionary android.Path
|
||||
|
||||
// output file suitable for installing or running
|
||||
outputFile android.Path
|
||||
|
||||
@@ -229,6 +258,9 @@ type Module struct {
|
||||
// list of .java files and srcjars that was passed to javac
|
||||
compiledJavaSrcs android.Paths
|
||||
compiledSrcJars android.Paths
|
||||
|
||||
// list of extra progurad flag files
|
||||
extraProguardFlagFiles android.Paths
|
||||
}
|
||||
|
||||
func (j *Module) Srcs() android.Paths {
|
||||
@@ -260,6 +292,7 @@ var (
|
||||
systemModulesTag = dependencyTag{name: "system modules"}
|
||||
frameworkResTag = dependencyTag{name: "framework-res"}
|
||||
kotlinStdlibTag = dependencyTag{name: "kotlin-stdlib"}
|
||||
proguardRaiseTag = dependencyTag{name: "proguard-raise"}
|
||||
)
|
||||
|
||||
type sdkDep struct {
|
||||
@@ -377,6 +410,10 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||
ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules)
|
||||
}
|
||||
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
|
||||
if Bool(j.deviceProperties.Optimize.Enabled) {
|
||||
ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultBootclasspathLibraries...)
|
||||
ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultLibraries...)
|
||||
}
|
||||
}
|
||||
} else if j.deviceProperties.System_modules == nil {
|
||||
ctx.PropertyErrorf("no_standard_libs",
|
||||
|
Reference in New Issue
Block a user