Merge "Add D8 support"

This commit is contained in:
Alan Leung
2017-10-20 18:59:22 +00:00
committed by Gerrit Code Review
3 changed files with 31 additions and 6 deletions

View File

@@ -117,15 +117,23 @@ func (p AndroidPackageContext) SourcePathVariableWithEnvOverride(name, path, env
// package-scoped variable's initialization.
func (p AndroidPackageContext) HostBinToolVariable(name, path string) blueprint.Variable {
return p.VariableFunc(name, func(config interface{}) (string, error) {
ctx := &configErrorWrapper{p, config.(Config), []error{}}
p := PathForOutput(ctx, "host", ctx.config.PrebuiltOS(), "bin", path)
if len(ctx.errors) > 0 {
return "", ctx.errors[0]
po, err := p.HostBinToolPath(config, path)
if err != nil {
return "", err
}
return p.String(), nil
return po.String(), nil
})
}
func (p AndroidPackageContext) HostBinToolPath(config interface{}, path string) (Path, error) {
ctx := &configErrorWrapper{p, config.(Config), []error{}}
pa := PathForOutput(ctx, "host", ctx.config.PrebuiltOS(), "bin", path)
if len(ctx.errors) > 0 {
return nil, ctx.errors[0]
}
return pa, nil
}
// HostJavaToolVariable returns a Variable whose value is the path to a host
// tool in the frameworks directory for host targets. It may only be called
// during a Go package's initialization - either from the init() function or as

View File

@@ -77,7 +77,22 @@ func init() {
pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips")
pctx.HostBinToolVariable("DxCmd", "dx")
pctx.VariableFunc("DxCmd", func(config interface{}) (string, error) {
dexer := "dx"
if config.(android.Config).Getenv("USE_D8") == "true" {
dexer = "d8"
}
if config.(android.Config).UnbundledBuild() {
return "prebuilts/build-tools/common/bin/" + dexer, nil
} else {
path, err := pctx.HostBinToolPath(config, dexer)
if err != nil {
return "", err
}
return path.String(), nil
}
})
pctx.HostJavaToolVariable("JarjarCmd", "jarjar.jar")
pctx.HostJavaToolVariable("DesugarJar", "desugar.jar")

View File

@@ -43,6 +43,8 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("JAR_ARGS", "${JarArgsCmd}")
ctx.Strict("JAVADOC", "${JavadocCmd}")
ctx.Strict("COMMON_JDK_FLAGS", "${CommonJdkFlags}")
ctx.Strict("DX", "${DxCmd}")
ctx.Strict("DX_COMMAND", "${DxCmd} -JXms16M -JXmx2048M")
if ctx.Config().IsEnvTrue("RUN_ERROR_PRONE") {
ctx.Strict("TARGET_JAVAC", "${ErrorProneCmd}")