Merge "Link type checking for java_library"
This commit is contained in:
commit
f3c24c12ef
|
@ -175,6 +175,95 @@ func TestPlatformAPIs(t *testing.T) {
|
|||
`)
|
||||
}
|
||||
|
||||
func TestAndroidAppLinkType(t *testing.T) {
|
||||
testJava(t, `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
libs: ["bar"],
|
||||
static_libs: ["baz"],
|
||||
platform_apis: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
sdk_version: "current",
|
||||
srcs: ["b.java"],
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "baz",
|
||||
sdk_version: "system_current",
|
||||
srcs: ["c.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
libs: ["bar"],
|
||||
sdk_version: "current",
|
||||
static_libs: ["baz"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
sdk_version: "current",
|
||||
srcs: ["b.java"],
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "baz",
|
||||
sdk_version: "system_current",
|
||||
srcs: ["c.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
testJava(t, `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
libs: ["bar"],
|
||||
sdk_version: "system_current",
|
||||
static_libs: ["baz"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
sdk_version: "current",
|
||||
srcs: ["b.java"],
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "baz",
|
||||
sdk_version: "system_current",
|
||||
srcs: ["c.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
libs: ["bar"],
|
||||
sdk_version: "system_current",
|
||||
static_libs: ["baz"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
sdk_version: "current",
|
||||
srcs: ["b.java"],
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "baz",
|
||||
srcs: ["c.java"],
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestResourceDirs(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
|
|
@ -792,8 +792,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||
return
|
||||
}
|
||||
switch module.(type) {
|
||||
case *Library:
|
||||
case *AndroidLibrary:
|
||||
case *Library, *AndroidLibrary:
|
||||
if to, ok := module.(linkTypeContext); ok {
|
||||
switch tag {
|
||||
case bootClasspathTag, libTag, staticLibTag:
|
||||
|
|
|
@ -288,6 +288,94 @@ func moduleToPath(name string) string {
|
|||
}
|
||||
}
|
||||
|
||||
func TestJavaLinkType(t *testing.T) {
|
||||
testJava(t, `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
libs: ["bar"],
|
||||
static_libs: ["baz"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
sdk_version: "current",
|
||||
srcs: ["b.java"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "baz",
|
||||
sdk_version: "system_current",
|
||||
srcs: ["c.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
libs: ["bar"],
|
||||
sdk_version: "current",
|
||||
static_libs: ["baz"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
sdk_version: "current",
|
||||
srcs: ["b.java"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "baz",
|
||||
sdk_version: "system_current",
|
||||
srcs: ["c.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
testJava(t, `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
libs: ["bar"],
|
||||
sdk_version: "system_current",
|
||||
static_libs: ["baz"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
sdk_version: "current",
|
||||
srcs: ["b.java"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "baz",
|
||||
sdk_version: "system_current",
|
||||
srcs: ["c.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
libs: ["bar"],
|
||||
sdk_version: "system_current",
|
||||
static_libs: ["baz"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
sdk_version: "current",
|
||||
srcs: ["b.java"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "baz",
|
||||
srcs: ["c.java"],
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestSimple(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
java_library {
|
||||
|
|
Loading…
Reference in New Issue