Support Turbine in Soong.

If sdk jars(android_stubs_current, etc) are compiled using soong java
modules, we have to filter them when running Java build with Turbine.

TODO: provide more unit-tests.

Test: m clean && m -j32; go test java_test

Change-Id: Iad7c241b0e8b0ca760950733f513124b56c84564
This commit is contained in:
Nan Zhang
2017-10-19 13:06:22 -07:00
parent 9e07394fd0
commit ed19fc3e2c
8 changed files with 317 additions and 177 deletions

View File

@@ -141,8 +141,11 @@ func moduleToPath(name string) string {
return name
case strings.HasSuffix(name, ".jar"):
return name
default:
case name == "android_stubs_current" || name == "android_system_stubs_current" ||
name == "android_test_stubs_current":
return filepath.Join(buildDir, ".intermediates", name, "android_common", "javac", name+".jar")
default:
return filepath.Join(buildDir, ".intermediates", name, "android_common", "turbine-combined", name+".jar")
}
}
@@ -167,21 +170,22 @@ func TestSimple(t *testing.T) {
`)
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
combineJar := ctx.ModuleForTests("foo", "android_common").Rule("combineJar")
combineJar := ctx.ModuleForTests("foo", "android_common").Description("for javac")
if len(javac.Inputs) != 1 || javac.Inputs[0].String() != "a.java" {
t.Errorf(`foo inputs %v != ["a.java"]`, javac.Inputs)
}
bar := ctx.ModuleForTests("bar", "android_common").Rule("javac").Output.String()
baz := ctx.ModuleForTests("baz", "android_common").Rule("javac").Output.String()
barTurbine := filepath.Join(buildDir, ".intermediates", "bar", "android_common", "turbine-combined", "bar.jar")
bazTurbine := filepath.Join(buildDir, ".intermediates", "baz", "android_common", "turbine-combined", "baz.jar")
if !strings.Contains(javac.Args["classpath"], bar) {
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bar)
if !strings.Contains(javac.Args["classpath"], barTurbine) {
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], barTurbine)
}
if !strings.Contains(javac.Args["classpath"], baz) {
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], baz)
if !strings.Contains(javac.Args["classpath"], bazTurbine) {
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bazTurbine)
}
if len(combineJar.Inputs) != 2 || combineJar.Inputs[1].String() != baz {
@@ -421,7 +425,7 @@ func TestPrebuilts(t *testing.T) {
`)
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
combineJar := ctx.ModuleForTests("foo", "android_common").Rule("combineJar")
combineJar := ctx.ModuleForTests("foo", "android_common").Description("for javac")
bar := "a.jar"
if !strings.Contains(javac.Args["classpath"], bar) {
@@ -459,15 +463,15 @@ func TestDefaults(t *testing.T) {
`)
javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
combineJar := ctx.ModuleForTests("foo", "android_common").Rule("combineJar")
combineJar := ctx.ModuleForTests("foo", "android_common").Description("for javac")
if len(javac.Inputs) != 1 || javac.Inputs[0].String() != "a.java" {
t.Errorf(`foo inputs %v != ["a.java"]`, javac.Inputs)
}
bar := ctx.ModuleForTests("bar", "android_common").Rule("javac").Output.String()
if !strings.Contains(javac.Args["classpath"], bar) {
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bar)
barTurbine := filepath.Join(buildDir, ".intermediates", "bar", "android_common", "turbine-combined", "bar.jar")
if !strings.Contains(javac.Args["classpath"], barTurbine) {
t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], barTurbine)
}
baz := ctx.ModuleForTests("baz", "android_common").Rule("javac").Output.String()