summaryrefslogtreecommitdiff
path: root/java/builder.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2019-10-28 14:25:10 -0700
committer Colin Cross <ccross@android.com> 2019-10-29 13:35:39 -0700
commitbf3119ee353e4b5c635c030207359d89e372c446 (patch)
tree00f394925a19fc19d74d5ff5a6165b442ed5a4f6 /java/builder.go
parent1e7438524b7e28c5f58c6ab380a53777c221dc70 (diff)
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
Diffstat (limited to 'java/builder.go')
-rw-r--r--java/builder.go41
1 files changed, 31 insertions, 10 deletions
diff --git a/java/builder.go b/java/builder.go
index c67a26d69..dce33a4c0 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -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
+ }
+}