Use system modules for turbine

turbine supports taking system modules on the command line,
now that we target Java language level 1.9 and use system modules
by default switch turbine to match javac.

Test: m javac-check
Change-Id: Ieee07502151da0d5693bb8929213d495c039106b
This commit is contained in:
Colin Cross 2019-10-28 14:25:10 -07:00
parent 1e7438524b
commit bf3119ee35
1 changed files with 31 additions and 10 deletions

View File

@ -294,18 +294,26 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android.
var deps android.Paths
deps = append(deps, srcJars...)
deps = append(deps, flags.bootClasspath...)
deps = append(deps, flags.classpath...)
var bootClasspath string
if len(flags.bootClasspath) == 0 && ctx.Device() {
// explicitly specify -bootclasspath "" if the bootclasspath is empty to
// ensure java does not fall back to the default bootclasspath.
bootClasspath = `--bootclasspath ""`
if flags.javaVersion.usesJavaModules() {
var systemModuleDeps android.Paths
bootClasspath, systemModuleDeps = flags.systemModules.FormTurbineSystemModulesPath(ctx.Device())
deps = append(deps, systemModuleDeps...)
} else {
bootClasspath = strings.Join(flags.bootClasspath.FormTurbineClasspath("--bootclasspath "), " ")
deps = append(deps, flags.bootClasspath...)
if len(flags.bootClasspath) == 0 && ctx.Device() {
// explicitly specify -bootclasspath "" if the bootclasspath is empty to
// ensure turbine does not fall back to the default bootclasspath.
bootClasspath = `--bootclasspath ""`
} else {
bootClasspath = strings.Join(flags.bootClasspath.FormTurbineClasspath("--bootclasspath "), " ")
}
}
deps = append(deps, flags.classpath...)
deps = append(deps, flags.processorPath...)
ctx.Build(pctx, android.BuildParams{
Rule: turbine,
Description: "turbine",
@ -550,9 +558,9 @@ type systemModules struct {
deps android.Paths
}
// Returns a --system argument in the form javac expects with -source 1.9. If forceEmpty is true,
// returns --system=none if the list is empty to ensure javac does not fall back to the default
// system modules.
// Returns a --system argument in the form javac expects with -source 1.9 and the list of files to
// depend on. If forceEmpty is true, returns --system=none if the list is empty to ensure javac
// does not fall back to the default system modules.
func (x *systemModules) FormJavaSystemModulesPath(forceEmpty bool) (string, android.Paths) {
if x != nil {
return "--system=" + x.dir.String(), x.deps
@ -562,3 +570,16 @@ func (x *systemModules) FormJavaSystemModulesPath(forceEmpty bool) (string, andr
return "", nil
}
}
// Returns a --system argument in the form turbine expects with -source 1.9 and the list of files to
// depend on. If forceEmpty is true, returns --bootclasspath "" if the list is empty to ensure turbine
// does not fall back to the default bootclasspath.
func (x *systemModules) FormTurbineSystemModulesPath(forceEmpty bool) (string, android.Paths) {
if x != nil {
return "--system " + x.dir.String(), x.deps
} else if forceEmpty {
return `--bootclasspath ""`, nil
} else {
return "", nil
}
}