Add USE_D8_DESUGAR option in build/soong

Add an option to use D8's desugar instead of the standalone version.

USE_D8_DESUGAR=true m would trigger DCHECK in dex2oat unless
https://android-review.googlesource.com/c/platform/art/+/562595 is
patched in as well.

Bug: 69329508
Test: m && USE_D8_DESUGAR=false m

Change-Id: I864d88e257a2ba0b7f19aa5cced537301950e963
This commit is contained in:
Alan Leung
2017-11-30 15:50:39 -08:00
parent d4c03092cd
commit 9f319118e1
4 changed files with 90 additions and 15 deletions

View File

@@ -161,6 +161,20 @@ var (
},
"outDir", "dxFlags")
d8 = pctx.AndroidStaticRule("d8",
blueprint.RuleParams{
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
`${config.D8Cmd} --output $outDir $dxFlags $in && ` +
`${config.SoongZipCmd} -o $outDir/classes.dex.jar -C $outDir -D $outDir && ` +
`${config.MergeZipsCmd} -D -stripFile "*.class" $out $outDir/classes.dex.jar $in`,
CommandDeps: []string{
"${config.DxCmd}",
"${config.SoongZipCmd}",
"${config.MergeZipsCmd}",
},
},
"outDir", "dxFlags")
jarjar = pctx.AndroidStaticRule("jarjar",
blueprint.RuleParams{
Command: "${config.JavaCmd} -jar ${config.JarjarCmd} process $rulesFile $in $out",
@@ -420,9 +434,15 @@ func TransformClassesJarToDexJar(ctx android.ModuleContext, outputFile android.W
outDir := android.PathForModuleOut(ctx, "dex")
rule := dx
desc := "dx"
if ctx.AConfig().IsEnvTrue("USE_D8_DESUGAR") {
rule = d8
desc = "d8"
}
ctx.Build(pctx, android.BuildParams{
Rule: dx,
Description: "dx",
Rule: rule,
Description: desc,
Output: outputFile,
Input: classesJar,
Args: map[string]string{