Merge "Revert "Revert "Remove desugar support""" am: 38462a6881
am: 216c4c8a7a
Change-Id: I4f148400379525f68e9f116ddcdb4b4ee36910a1
This commit is contained in:
commit
7a72575d6d
5 changed files with 16 additions and 138 deletions
|
@ -627,10 +627,6 @@ func (c *config) Android64() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (c *config) UseD8Desugar() bool {
|
||||
return !c.IsEnvFalse("USE_D8_DESUGAR")
|
||||
}
|
||||
|
||||
func (c *config) UseGoma() bool {
|
||||
return Bool(c.productVariables.UseGoma)
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android.
|
|||
// ensure java does not fall back to the default bootclasspath.
|
||||
bootClasspath = `--bootclasspath ""`
|
||||
} else {
|
||||
bootClasspath = strings.Join(flags.bootClasspath.FormDesugarClasspath("--bootclasspath"), " ")
|
||||
bootClasspath = strings.Join(flags.bootClasspath.FormTurbineClasspath("--bootclasspath"), " ")
|
||||
}
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
|
@ -256,7 +256,7 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android.
|
|||
"javacFlags": flags.javacFlags,
|
||||
"bootClasspath": bootClasspath,
|
||||
"srcJars": strings.Join(srcJars.Strings(), " "),
|
||||
"classpath": strings.Join(flags.classpath.FormDesugarClasspath("--classpath"), " "),
|
||||
"classpath": strings.Join(flags.classpath.FormTurbineClasspath("--classpath"), " "),
|
||||
"outDir": android.PathForModuleOut(ctx, "turbine", "classes").String(),
|
||||
"javaVersion": flags.javaVersion,
|
||||
},
|
||||
|
@ -419,7 +419,7 @@ func (x *classpath) FormJavaSystemModulesPath(optName string, forceEmpty bool) s
|
|||
}
|
||||
}
|
||||
|
||||
func (x *classpath) FormDesugarClasspath(optName string) []string {
|
||||
func (x *classpath) FormTurbineClasspath(optName string) []string {
|
||||
if x == nil || *x == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -95,18 +95,6 @@ func init() {
|
|||
pctx.HostBinToolVariable("Zip2ZipCmd", "zip2zip")
|
||||
pctx.HostBinToolVariable("ZipSyncCmd", "zipsync")
|
||||
pctx.HostBinToolVariable("ApiCheckCmd", "apicheck")
|
||||
pctx.VariableFunc("DxCmd", func(ctx android.PackageVarContext) string {
|
||||
config := ctx.Config()
|
||||
if config.IsEnvFalse("USE_D8") {
|
||||
if config.UnbundledBuild() || config.IsPdkBuild() {
|
||||
return "prebuilts/build-tools/common/bin/dx"
|
||||
} else {
|
||||
return pctx.HostBinToolPath(ctx, "dx").String()
|
||||
}
|
||||
} else {
|
||||
return pctx.HostBinToolPath(ctx, "d8-compat-dx").String()
|
||||
}
|
||||
})
|
||||
pctx.HostBinToolVariable("D8Cmd", "d8")
|
||||
pctx.HostBinToolVariable("R8Cmd", "r8-compat-proguard")
|
||||
|
||||
|
@ -120,7 +108,6 @@ func init() {
|
|||
})
|
||||
|
||||
pctx.HostJavaToolVariable("JarjarCmd", "jarjar.jar")
|
||||
pctx.HostJavaToolVariable("DesugarJar", "desugar.jar")
|
||||
pctx.HostJavaToolVariable("JsilverJar", "jsilver.jar")
|
||||
pctx.HostJavaToolVariable("DoclavaJar", "doclava.jar")
|
||||
pctx.HostJavaToolVariable("MetalavaJar", "metalava.jar")
|
||||
|
|
|
@ -46,15 +46,8 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
|||
ctx.Strict("JAVADOC", "${JavadocCmd}")
|
||||
ctx.Strict("COMMON_JDK_FLAGS", "${CommonJdkFlags}")
|
||||
|
||||
if ctx.Config().UseD8Desugar() {
|
||||
ctx.Strict("DX", "${D8Cmd}")
|
||||
ctx.Strict("DX_COMMAND", "${D8Cmd} -JXms16M -JXmx2048M")
|
||||
ctx.Strict("USE_D8_DESUGAR", "true")
|
||||
} else {
|
||||
ctx.Strict("DX", "${DxCmd}")
|
||||
ctx.Strict("DX_COMMAND", "${DxCmd} -JXms16M -JXmx2048M")
|
||||
ctx.Strict("USE_D8_DESUGAR", "false")
|
||||
}
|
||||
ctx.Strict("DX", "${D8Cmd}")
|
||||
ctx.Strict("DX_COMMAND", "${D8Cmd} -JXms16M -JXmx2048M")
|
||||
ctx.Strict("R8_COMPAT_PROGUARD", "${R8Cmd}")
|
||||
|
||||
ctx.Strict("TURBINE", "${TurbineJar}")
|
||||
|
|
120
java/dex.go
120
java/dex.go
|
@ -22,78 +22,6 @@ import (
|
|||
"android/soong/android"
|
||||
)
|
||||
|
||||
var desugar = pctx.AndroidStaticRule("desugar",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf $dumpDir && mkdir -p $dumpDir && ` +
|
||||
`${config.JavaCmd} ` +
|
||||
`-Djdk.internal.lambda.dumpProxyClasses=$$(cd $dumpDir && pwd) ` +
|
||||
`$javaFlags ` +
|
||||
`-jar ${config.DesugarJar} $classpathFlags $desugarFlags ` +
|
||||
`-i $in -o $out`,
|
||||
CommandDeps: []string{"${config.DesugarJar}", "${config.JavaCmd}"},
|
||||
},
|
||||
"javaFlags", "classpathFlags", "desugarFlags", "dumpDir")
|
||||
|
||||
func (j *Module) desugar(ctx android.ModuleContext, flags javaBuilderFlags,
|
||||
classesJar android.Path, jarName string) android.Path {
|
||||
|
||||
desugarFlags := []string{
|
||||
"--min_sdk_version " + j.minSdkVersionNumber(ctx),
|
||||
"--desugar_try_with_resources_if_needed=false",
|
||||
"--allow_empty_bootclasspath",
|
||||
}
|
||||
|
||||
if inList("--core-library", j.deviceProperties.Dxflags) {
|
||||
desugarFlags = append(desugarFlags, "--core_library")
|
||||
}
|
||||
|
||||
desugarJar := android.PathForModuleOut(ctx, "desugar", jarName)
|
||||
dumpDir := android.PathForModuleOut(ctx, "desugar", "classes")
|
||||
|
||||
javaFlags := ""
|
||||
if ctx.Config().UseOpenJDK9() {
|
||||
javaFlags = "--add-opens java.base/java.lang.invoke=ALL-UNNAMED"
|
||||
}
|
||||
|
||||
var classpathFlags []string
|
||||
classpathFlags = append(classpathFlags, flags.bootClasspath.FormDesugarClasspath("--bootclasspath_entry")...)
|
||||
classpathFlags = append(classpathFlags, flags.classpath.FormDesugarClasspath("--classpath_entry")...)
|
||||
|
||||
var deps android.Paths
|
||||
deps = append(deps, flags.bootClasspath...)
|
||||
deps = append(deps, flags.classpath...)
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: desugar,
|
||||
Description: "desugar",
|
||||
Output: desugarJar,
|
||||
Input: classesJar,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"dumpDir": dumpDir.String(),
|
||||
"javaFlags": javaFlags,
|
||||
"classpathFlags": strings.Join(classpathFlags, " "),
|
||||
"desugarFlags": strings.Join(desugarFlags, " "),
|
||||
},
|
||||
})
|
||||
|
||||
return desugarJar
|
||||
}
|
||||
|
||||
var dx = pctx.AndroidStaticRule("dx",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
|
||||
`${config.DxCmd} --dex --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")
|
||||
|
||||
var d8 = pctx.AndroidStaticRule("d8",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
|
||||
|
@ -125,39 +53,24 @@ var r8 = pctx.AndroidStaticRule("r8",
|
|||
},
|
||||
"outDir", "outDict", "dxFlags", "r8Flags")
|
||||
|
||||
func (j *Module) dxFlags(ctx android.ModuleContext, fullD8 bool) []string {
|
||||
func (j *Module) dxFlags(ctx android.ModuleContext) []string {
|
||||
flags := j.deviceProperties.Dxflags
|
||||
if fullD8 {
|
||||
// Translate all the DX flags to D8 ones until all the build files have been migrated
|
||||
// to D8 flags. See: b/69377755
|
||||
flags = android.RemoveListFromList(flags,
|
||||
[]string{"--core-library", "--dex", "--multi-dex"})
|
||||
}
|
||||
// Translate all the DX flags to D8 ones until all the build files have been migrated
|
||||
// to D8 flags. See: b/69377755
|
||||
flags = android.RemoveListFromList(flags,
|
||||
[]string{"--core-library", "--dex", "--multi-dex"})
|
||||
|
||||
if ctx.Config().Getenv("NO_OPTIMIZE_DX") != "" {
|
||||
if fullD8 {
|
||||
flags = append(flags, "--debug")
|
||||
} else {
|
||||
flags = append(flags, "--no-optimize")
|
||||
}
|
||||
flags = append(flags, "--debug")
|
||||
}
|
||||
|
||||
if ctx.Config().Getenv("GENERATE_DEX_DEBUG") != "" {
|
||||
flags = append(flags,
|
||||
"--debug",
|
||||
"--verbose")
|
||||
if !fullD8 {
|
||||
flags = append(flags,
|
||||
"--dump-to="+android.PathForModuleOut(ctx, "classes.lst").String(),
|
||||
"--dump-width=1000")
|
||||
}
|
||||
}
|
||||
|
||||
if fullD8 {
|
||||
flags = append(flags, "--min-api "+j.minSdkVersionNumber(ctx))
|
||||
} else {
|
||||
flags = append(flags, "--min-sdk-version="+j.minSdkVersionNumber(ctx))
|
||||
}
|
||||
flags = append(flags, "--min-api "+j.minSdkVersionNumber(ctx))
|
||||
return flags
|
||||
}
|
||||
|
||||
|
@ -166,7 +79,7 @@ func (j *Module) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8F
|
|||
|
||||
// When an app contains references to APIs that are not in the SDK specified by
|
||||
// its LOCAL_SDK_VERSION for example added by support library or by runtime
|
||||
// classes added by desugar, we artifically raise the "SDK version" "linked" by
|
||||
// classes added by desugaring, we artifically raise the "SDK version" "linked" by
|
||||
// ProGuard, to
|
||||
// - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version.
|
||||
// - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version.
|
||||
|
@ -223,13 +136,8 @@ func (j *Module) compileDex(ctx android.ModuleContext, flags javaBuilderFlags,
|
|||
classesJar android.Path, jarName string) android.Path {
|
||||
|
||||
useR8 := Bool(j.deviceProperties.Optimize.Enabled)
|
||||
fullD8 := useR8 || ctx.Config().UseD8Desugar()
|
||||
|
||||
if !fullD8 {
|
||||
classesJar = j.desugar(ctx, flags, classesJar, jarName)
|
||||
}
|
||||
|
||||
dxFlags := j.dxFlags(ctx, fullD8)
|
||||
dxFlags := j.dxFlags(ctx)
|
||||
|
||||
// Compile classes.jar into classes.dex and then javalib.jar
|
||||
javalibJar := android.PathForModuleOut(ctx, "dex", jarName)
|
||||
|
@ -256,15 +164,9 @@ func (j *Module) compileDex(ctx android.ModuleContext, flags javaBuilderFlags,
|
|||
},
|
||||
})
|
||||
} else {
|
||||
rule := dx
|
||||
desc := "dx"
|
||||
if fullD8 {
|
||||
rule = d8
|
||||
desc = "d8"
|
||||
}
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: rule,
|
||||
Description: desc,
|
||||
Rule: d8,
|
||||
Description: "d8",
|
||||
Output: javalibJar,
|
||||
Input: classesJar,
|
||||
Args: map[string]string{
|
||||
|
|
Loading…
Reference in a new issue