diff --git a/java/builder.go b/java/builder.go index e1a912b2f..a48e8b1a2 100644 --- a/java/builder.go +++ b/java/builder.go @@ -148,15 +148,16 @@ func init() { } type javaBuilderFlags struct { - javacFlags string - bootClasspath classpath - classpath classpath - processorPath classpath - processor string - systemModules classpath - aidlFlags string - aidlDeps android.Paths - javaVersion string + javacFlags string + bootClasspath classpath + classpath classpath + processorPath classpath + processor string + systemModules classpath + systemModulesDeps android.Paths + aidlFlags string + aidlDeps android.Paths + javaVersion string errorProneExtraJavacFlags string errorProneProcessorPath classpath @@ -248,7 +249,7 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab var bootClasspath string if flags.javaVersion == "1.9" { - deps = append(deps, flags.systemModules...) + deps = append(deps, flags.systemModulesDeps...) bootClasspath = flags.systemModules.FormJavaSystemModulesPath("--system=", ctx.Device()) } else { deps = append(deps, flags.bootClasspath...) @@ -430,7 +431,7 @@ func (x *classpath) FormJavaSystemModulesPath(optName string, forceEmpty bool) s if len(*x) > 1 { panic("more than one system module") } else if len(*x) == 1 { - return optName + strings.TrimSuffix((*x)[0].String(), "lib/modules") + return optName + (*x)[0].String() } else if forceEmpty { return optName + "none" } else { diff --git a/java/droiddoc.go b/java/droiddoc.go index a8cf1c034..be1b28153 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -692,10 +692,11 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps { panic("Found two system module dependencies") } sm := module.(*SystemModules) - if sm.outputFile == nil { + if sm.outputDir == nil && len(sm.outputDeps) == 0 { panic("Missing directory for system module dependency") } - deps.systemModules = sm.outputFile + deps.systemModules = sm.outputDir + deps.systemModulesDeps = sm.outputDeps } }) // do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs @@ -776,6 +777,7 @@ func (j *Javadoc) GenerateAndroidBuildActions(ctx android.ModuleContext) { if deps.systemModules != nil { systemModules = append(systemModules, deps.systemModules) } + implicits = append(implicits, deps.systemModulesDeps...) bootClasspathArgs = systemModules.FormJavaSystemModulesPath("--system ", ctx.Device()) bootClasspathArgs = bootClasspathArgs + " --patch-module java.base=." } diff --git a/java/java.go b/java/java.go index 4b3845161..a2e9ab023 100644 --- a/java/java.go +++ b/java/java.go @@ -628,6 +628,7 @@ type deps struct { srcs android.Paths srcJars android.Paths systemModules android.Path + systemModulesDeps android.Paths aidlPreprocess android.OptionalPath kotlinStdlib android.Paths kotlinAnnotations android.Paths @@ -835,10 +836,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { panic("Found two system module dependencies") } sm := module.(*SystemModules) - if sm.outputFile == nil { + if sm.outputDir == nil || len(sm.outputDeps) == 0 { panic("Missing directory for system module dependency") } - deps.systemModules = sm.outputFile + deps.systemModules = sm.outputDir + deps.systemModulesDeps = sm.outputDeps } } }) @@ -968,6 +970,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB // systemModules if deps.systemModules != nil { flags.systemModules = append(flags.systemModules, deps.systemModules) + flags.systemModulesDeps = append(flags.systemModulesDeps, deps.systemModulesDeps...) } // aidl flags. diff --git a/java/sdk_test.go b/java/sdk_test.go index 915333ec9..953c3722f 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -254,7 +254,7 @@ func TestClasspath(t *testing.T) { if testcase.system == "none" { system = "--system=none" } else if testcase.system != "" { - system = "--system=" + filepath.Join(buildDir, ".intermediates", testcase.system, "android_common", "system") + "/" + system = "--system=" + filepath.Join(buildDir, ".intermediates", testcase.system, "android_common", "system") } checkClasspath := func(t *testing.T, ctx *android.TestContext) { diff --git a/java/system_modules.go b/java/system_modules.go index 5a86f3c82..f71f4523f 100644 --- a/java/system_modules.go +++ b/java/system_modules.go @@ -61,7 +61,7 @@ var ( "moduleName", "classpath", "outDir", "workDir") ) -func TransformJarsToSystemModules(ctx android.ModuleContext, moduleName string, jars android.Paths) android.WritablePath { +func TransformJarsToSystemModules(ctx android.ModuleContext, moduleName string, jars android.Paths) (android.Path, android.Paths) { outDir := android.PathForModuleOut(ctx, "system") workDir := android.PathForModuleOut(ctx, "modules") outputFile := android.PathForModuleOut(ctx, "system/lib/modules") @@ -84,7 +84,7 @@ func TransformJarsToSystemModules(ctx android.ModuleContext, moduleName string, }, }) - return outputFile + return outDir, outputs.Paths() } func SystemModulesFactory() android.Module { @@ -101,7 +101,8 @@ type SystemModules struct { properties SystemModulesProperties - outputFile android.Path + outputDir android.Path + outputDeps android.Paths } type SystemModulesProperties struct { @@ -117,7 +118,7 @@ func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleConte jars = append(jars, dep.HeaderJars()...) }) - system.outputFile = TransformJarsToSystemModules(ctx, "java.base", jars) + system.outputDir, system.outputDeps = TransformJarsToSystemModules(ctx, "java.base", jars) } func (system *SystemModules) DepsMutator(ctx android.BottomUpMutatorContext) { @@ -127,16 +128,22 @@ func (system *SystemModules) DepsMutator(ctx android.BottomUpMutatorContext) { func (system *SystemModules) AndroidMk() android.AndroidMkData { return android.AndroidMkData{ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { - makevar := "SOONG_SYSTEM_MODULES_" + name fmt.Fprintln(w) - fmt.Fprintln(w, makevar, ":=", system.outputFile.String()) - fmt.Fprintln(w, ".KATI_READONLY", ":=", makevar) + + makevar := "SOONG_SYSTEM_MODULES_" + name + fmt.Fprintln(w, makevar, ":=$=", system.outputDir.String()) + fmt.Fprintln(w) + + makevar = "SOONG_SYSTEM_MODULES_LIBS_" + name + fmt.Fprintln(w, makevar, ":=$=", strings.Join(system.properties.Libs, " ")) + fmt.Fprintln(w) + + makevar = "SOONG_SYSTEM_MODULE_DEPS_" + name + fmt.Fprintln(w, makevar, ":=$=", strings.Join(system.outputDeps.Strings(), " ")) + fmt.Fprintln(w) + fmt.Fprintln(w, name+":", "$("+makevar+")") fmt.Fprintln(w, ".PHONY:", name) - fmt.Fprintln(w) - makevar = "SOONG_SYSTEM_MODULES_LIBS_" + name - fmt.Fprintln(w, makevar, ":=", strings.Join(system.properties.Libs, " ")) - fmt.Fprintln(w, ".KATI_READONLY :=", makevar) }, } }