diff --git a/java/config/config.go b/java/config/config.go index 7cc249cbc..e607b1d55 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -61,6 +61,7 @@ func init() { pctx.StaticVariable("JavacHeapSize", "2048M") pctx.StaticVariable("JavacHeapFlags", "-J-Xmx${JavacHeapSize}") + pctx.StaticVariable("DexFlags", "-JXX:+TieredCompilation -JXX:TieredStopAtLevel=1") pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{ `-Xmaxerrs 9999999`, diff --git a/java/config/makevars.go b/java/config/makevars.go index 156ee2638..30552da06 100644 --- a/java/config/makevars.go +++ b/java/config/makevars.go @@ -81,4 +81,6 @@ func makeVarsProvider(ctx android.MakeVarsContext) { ctx.Strict("CLASS2GREYLIST", "${Class2Greylist}") ctx.Strict("HIDDENAPI", "${HiddenAPI}") + + ctx.Strict("DEX_FLAGS", "${DexFlags}") } diff --git a/java/dex.go b/java/dex.go index 54b7bfcfb..987129ee7 100644 --- a/java/dex.go +++ b/java/dex.go @@ -25,7 +25,7 @@ import ( var d8 = pctx.AndroidStaticRule("d8", blueprint.RuleParams{ Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` + - `${config.D8Cmd} --output $outDir $d8Flags $in && ` + + `${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $in && ` + `${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` + `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`, CommandDeps: []string{ @@ -40,7 +40,7 @@ var r8 = pctx.AndroidStaticRule("r8", blueprint.RuleParams{ Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` + `rm -f "$outDict" && ` + - `${config.R8Cmd} -injars $in --output $outDir ` + + `${config.R8Cmd} ${config.DexFlags} -injars $in --output $outDir ` + `--force-proguard-compatibility ` + `--no-data-resources ` + `-printmapping $outDict ` +