Merge "Allow java_system_modules_import to replace java_system_modules"
This commit is contained in:
@@ -547,10 +547,10 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
case bootClasspathTag:
|
case bootClasspathTag:
|
||||||
if dep, ok := module.(Dependency); ok {
|
if dep, ok := module.(Dependency); ok {
|
||||||
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars()...)
|
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars()...)
|
||||||
} else if sm, ok := module.(*SystemModules); ok {
|
} else if sm, ok := module.(SystemModulesProvider); ok {
|
||||||
// A system modules dependency has been added to the bootclasspath
|
// A system modules dependency has been added to the bootclasspath
|
||||||
// so add its libs to the bootclasspath.
|
// so add its libs to the bootclasspath.
|
||||||
deps.bootClasspath = append(deps.bootClasspath, sm.headerJars...)
|
deps.bootClasspath = append(deps.bootClasspath, sm.HeaderJars()...)
|
||||||
} else {
|
} else {
|
||||||
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
||||||
}
|
}
|
||||||
@@ -578,11 +578,9 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
if deps.systemModules != nil {
|
if deps.systemModules != nil {
|
||||||
panic("Found two system module dependencies")
|
panic("Found two system module dependencies")
|
||||||
}
|
}
|
||||||
sm := module.(*SystemModules)
|
sm := module.(SystemModulesProvider)
|
||||||
if sm.outputDir == nil && len(sm.outputDeps) == 0 {
|
outputDir, outputDeps := sm.OutputDirAndDeps()
|
||||||
panic("Missing directory for system module dependency")
|
deps.systemModules = &systemModules{outputDir, outputDeps}
|
||||||
}
|
|
||||||
deps.systemModules = &systemModules{sm.outputDir, 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
|
||||||
|
12
java/java.go
12
java/java.go
@@ -1031,18 +1031,16 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
case bootClasspathTag:
|
case bootClasspathTag:
|
||||||
// If a system modules dependency has been added to the bootclasspath
|
// If a system modules dependency has been added to the bootclasspath
|
||||||
// then add its libs to the bootclasspath.
|
// then add its libs to the bootclasspath.
|
||||||
sm := module.(*SystemModules)
|
sm := module.(SystemModulesProvider)
|
||||||
deps.bootClasspath = append(deps.bootClasspath, sm.headerJars...)
|
deps.bootClasspath = append(deps.bootClasspath, sm.HeaderJars()...)
|
||||||
|
|
||||||
case systemModulesTag:
|
case systemModulesTag:
|
||||||
if deps.systemModules != nil {
|
if deps.systemModules != nil {
|
||||||
panic("Found two system module dependencies")
|
panic("Found two system module dependencies")
|
||||||
}
|
}
|
||||||
sm := module.(*SystemModules)
|
sm := module.(SystemModulesProvider)
|
||||||
if sm.outputDir == nil || len(sm.outputDeps) == 0 {
|
outputDir, outputDeps := sm.OutputDirAndDeps()
|
||||||
panic("Missing directory for system module dependency")
|
deps.systemModules = &systemModules{outputDir, outputDeps}
|
||||||
}
|
|
||||||
deps.systemModules = &systemModules{sm.outputDir, sm.outputDeps}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -982,6 +982,65 @@ func TestDroiddoc(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDroidstubsWithSystemModules(t *testing.T) {
|
||||||
|
ctx, _ := testJava(t, `
|
||||||
|
droidstubs {
|
||||||
|
name: "stubs-source-system-modules",
|
||||||
|
srcs: [
|
||||||
|
"bar-doc/*.java",
|
||||||
|
],
|
||||||
|
sdk_version: "none",
|
||||||
|
system_modules: "source-system-modules",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "source-jar",
|
||||||
|
srcs: [
|
||||||
|
"a.java",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_system_modules {
|
||||||
|
name: "source-system-modules",
|
||||||
|
libs: ["source-jar"],
|
||||||
|
}
|
||||||
|
|
||||||
|
droidstubs {
|
||||||
|
name: "stubs-prebuilt-system-modules",
|
||||||
|
srcs: [
|
||||||
|
"bar-doc/*.java",
|
||||||
|
],
|
||||||
|
sdk_version: "none",
|
||||||
|
system_modules: "prebuilt-system-modules",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_import {
|
||||||
|
name: "prebuilt-jar",
|
||||||
|
jars: ["a.jar"],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_system_modules_import {
|
||||||
|
name: "prebuilt-system-modules",
|
||||||
|
libs: ["prebuilt-jar"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
checkSystemModulesUseByDroidstubs(t, ctx, "stubs-source-system-modules", "source-jar.jar")
|
||||||
|
|
||||||
|
checkSystemModulesUseByDroidstubs(t, ctx, "stubs-prebuilt-system-modules", "prebuilt-jar.jar")
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkSystemModulesUseByDroidstubs(t *testing.T, ctx *android.TestContext, moduleName string, systemJar string) {
|
||||||
|
metalavaRule := ctx.ModuleForTests(moduleName, "android_common").Rule("metalava")
|
||||||
|
var systemJars []string
|
||||||
|
for _, i := range metalavaRule.Implicits {
|
||||||
|
systemJars = append(systemJars, i.Base())
|
||||||
|
}
|
||||||
|
if len(systemJars) != 1 || systemJars[0] != systemJar {
|
||||||
|
t.Errorf("inputs of %q must be []string{%q}, but was %#v.", moduleName, systemJar, systemJars)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestJarGenrules(t *testing.T) {
|
func TestJarGenrules(t *testing.T) {
|
||||||
ctx, _ := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_library {
|
java_library {
|
||||||
@@ -1377,3 +1436,59 @@ func TestJavaSystemModulesImport(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestJavaLibraryWithSystemModules(t *testing.T) {
|
||||||
|
ctx, _ := testJava(t, `
|
||||||
|
java_library {
|
||||||
|
name: "lib-with-source-system-modules",
|
||||||
|
srcs: [
|
||||||
|
"a.java",
|
||||||
|
],
|
||||||
|
sdk_version: "none",
|
||||||
|
system_modules: "source-system-modules",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "source-jar",
|
||||||
|
srcs: [
|
||||||
|
"a.java",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_system_modules {
|
||||||
|
name: "source-system-modules",
|
||||||
|
libs: ["source-jar"],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "lib-with-prebuilt-system-modules",
|
||||||
|
srcs: [
|
||||||
|
"a.java",
|
||||||
|
],
|
||||||
|
sdk_version: "none",
|
||||||
|
system_modules: "prebuilt-system-modules",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_import {
|
||||||
|
name: "prebuilt-jar",
|
||||||
|
jars: ["a.jar"],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_system_modules_import {
|
||||||
|
name: "prebuilt-system-modules",
|
||||||
|
libs: ["prebuilt-jar"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
checkBootClasspathForSystemModule(t, ctx, "lib-with-source-system-modules", "/source-jar.jar")
|
||||||
|
|
||||||
|
checkBootClasspathForSystemModule(t, ctx, "lib-with-prebuilt-system-modules", "/prebuilt-jar.jar")
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkBootClasspathForSystemModule(t *testing.T, ctx *android.TestContext, moduleName string, expectedSuffix string) {
|
||||||
|
javacRule := ctx.ModuleForTests(moduleName, "android_common").Rule("javac")
|
||||||
|
bootClasspath := javacRule.Args["bootClasspath"]
|
||||||
|
if strings.HasPrefix(bootClasspath, "--system ") && strings.HasSuffix(bootClasspath, expectedSuffix) {
|
||||||
|
t.Errorf("bootclasspath of %q must start with --system and end with %q, but was %#v.", moduleName, expectedSuffix, bootClasspath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -117,6 +117,15 @@ func SystemModulesFactory() android.Module {
|
|||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SystemModulesProvider interface {
|
||||||
|
HeaderJars() android.Paths
|
||||||
|
OutputDirAndDeps() (android.Path, android.Paths)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ SystemModulesProvider = (*SystemModules)(nil)
|
||||||
|
|
||||||
|
var _ SystemModulesProvider = (*systemModulesImport)(nil)
|
||||||
|
|
||||||
type SystemModules struct {
|
type SystemModules struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
android.DefaultableModuleBase
|
android.DefaultableModuleBase
|
||||||
@@ -136,6 +145,17 @@ type SystemModulesProperties struct {
|
|||||||
Libs []string
|
Libs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (system *SystemModules) HeaderJars() android.Paths {
|
||||||
|
return system.headerJars
|
||||||
|
}
|
||||||
|
|
||||||
|
func (system *SystemModules) OutputDirAndDeps() (android.Path, android.Paths) {
|
||||||
|
if system.outputDir == nil || len(system.outputDeps) == 0 {
|
||||||
|
panic("Missing directory for system module dependency")
|
||||||
|
}
|
||||||
|
return system.outputDir, system.outputDeps
|
||||||
|
}
|
||||||
|
|
||||||
func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
var jars android.Paths
|
var jars android.Paths
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user