Depend on all the files from system modules

Instead of just one of the files that we pass into javac.

Test: treehugger
Change-Id: I8478e88656487c9f667893d7c17839f0ea63c78f
This commit is contained in:
Dan Willemsen
2019-06-13 16:52:01 +00:00
parent eec8d3aee3
commit ff60a73d89
5 changed files with 40 additions and 27 deletions

View File

@@ -148,15 +148,16 @@ func init() {
} }
type javaBuilderFlags struct { type javaBuilderFlags struct {
javacFlags string javacFlags string
bootClasspath classpath bootClasspath classpath
classpath classpath classpath classpath
processorPath classpath processorPath classpath
processor string processor string
systemModules classpath systemModules classpath
aidlFlags string systemModulesDeps android.Paths
aidlDeps android.Paths aidlFlags string
javaVersion string aidlDeps android.Paths
javaVersion string
errorProneExtraJavacFlags string errorProneExtraJavacFlags string
errorProneProcessorPath classpath errorProneProcessorPath classpath
@@ -248,7 +249,7 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab
var bootClasspath string var bootClasspath string
if flags.javaVersion == "1.9" { if flags.javaVersion == "1.9" {
deps = append(deps, flags.systemModules...) deps = append(deps, flags.systemModulesDeps...)
bootClasspath = flags.systemModules.FormJavaSystemModulesPath("--system=", ctx.Device()) bootClasspath = flags.systemModules.FormJavaSystemModulesPath("--system=", ctx.Device())
} else { } else {
deps = append(deps, flags.bootClasspath...) deps = append(deps, flags.bootClasspath...)
@@ -430,7 +431,7 @@ func (x *classpath) FormJavaSystemModulesPath(optName string, forceEmpty bool) s
if len(*x) > 1 { if len(*x) > 1 {
panic("more than one system module") panic("more than one system module")
} else if len(*x) == 1 { } else if len(*x) == 1 {
return optName + strings.TrimSuffix((*x)[0].String(), "lib/modules") return optName + (*x)[0].String()
} else if forceEmpty { } else if forceEmpty {
return optName + "none" return optName + "none"
} else { } else {

View File

@@ -692,10 +692,11 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
panic("Found two system module dependencies") panic("Found two system module dependencies")
} }
sm := module.(*SystemModules) sm := module.(*SystemModules)
if sm.outputFile == nil { if sm.outputDir == nil && len(sm.outputDeps) == 0 {
panic("Missing directory for system module dependency") 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 // 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 { if deps.systemModules != nil {
systemModules = append(systemModules, deps.systemModules) systemModules = append(systemModules, deps.systemModules)
} }
implicits = append(implicits, deps.systemModulesDeps...)
bootClasspathArgs = systemModules.FormJavaSystemModulesPath("--system ", ctx.Device()) bootClasspathArgs = systemModules.FormJavaSystemModulesPath("--system ", ctx.Device())
bootClasspathArgs = bootClasspathArgs + " --patch-module java.base=." bootClasspathArgs = bootClasspathArgs + " --patch-module java.base=."
} }

View File

@@ -628,6 +628,7 @@ type deps struct {
srcs android.Paths srcs android.Paths
srcJars android.Paths srcJars android.Paths
systemModules android.Path systemModules android.Path
systemModulesDeps android.Paths
aidlPreprocess android.OptionalPath aidlPreprocess android.OptionalPath
kotlinStdlib android.Paths kotlinStdlib android.Paths
kotlinAnnotations android.Paths kotlinAnnotations android.Paths
@@ -835,10 +836,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
panic("Found two system module dependencies") panic("Found two system module dependencies")
} }
sm := module.(*SystemModules) sm := module.(*SystemModules)
if sm.outputFile == nil { if sm.outputDir == nil || len(sm.outputDeps) == 0 {
panic("Missing directory for system module dependency") 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 // systemModules
if deps.systemModules != nil { if deps.systemModules != nil {
flags.systemModules = append(flags.systemModules, deps.systemModules) flags.systemModules = append(flags.systemModules, deps.systemModules)
flags.systemModulesDeps = append(flags.systemModulesDeps, deps.systemModulesDeps...)
} }
// aidl flags. // aidl flags.

View File

@@ -254,7 +254,7 @@ func TestClasspath(t *testing.T) {
if testcase.system == "none" { if testcase.system == "none" {
system = "--system=none" system = "--system=none"
} else if testcase.system != "" { } 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) { checkClasspath := func(t *testing.T, ctx *android.TestContext) {

View File

@@ -61,7 +61,7 @@ var (
"moduleName", "classpath", "outDir", "workDir") "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") outDir := android.PathForModuleOut(ctx, "system")
workDir := android.PathForModuleOut(ctx, "modules") workDir := android.PathForModuleOut(ctx, "modules")
outputFile := android.PathForModuleOut(ctx, "system/lib/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 { func SystemModulesFactory() android.Module {
@@ -101,7 +101,8 @@ type SystemModules struct {
properties SystemModulesProperties properties SystemModulesProperties
outputFile android.Path outputDir android.Path
outputDeps android.Paths
} }
type SystemModulesProperties struct { type SystemModulesProperties struct {
@@ -117,7 +118,7 @@ func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleConte
jars = append(jars, dep.HeaderJars()...) 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) { func (system *SystemModules) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -127,16 +128,22 @@ func (system *SystemModules) DepsMutator(ctx android.BottomUpMutatorContext) {
func (system *SystemModules) AndroidMk() android.AndroidMkData { func (system *SystemModules) AndroidMk() android.AndroidMkData {
return android.AndroidMkData{ return android.AndroidMkData{
Custom: func(w io.Writer, name, prefix, moduleDir string, data 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)
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, name+":", "$("+makevar+")")
fmt.Fprintln(w, ".PHONY:", name) 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)
}, },
} }
} }