Add do not convert for sdk_version unset
When sdk_version is unset, the build with fail with Bazel because private APIs are do not build with Bazel at this time. This instead prevents migrating the relevant target to Bazel in bp2build Test: go tests Change-Id: I31dabcf143de7933706d1b734ef21467a01b65e9
This commit is contained in:
parent
8bbe26cad7
commit
02914408de
7 changed files with 315 additions and 209 deletions
|
@ -37,19 +37,19 @@ func TestConvertAndroidLibrary(t *testing.T) {
|
|||
},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
srcs: ["lib.java"],
|
||||
arch: {
|
||||
arm: {
|
||||
srcs: ["arm.java"],
|
||||
},
|
||||
x86: {
|
||||
srcs: ["x86.java"],
|
||||
}
|
||||
name: "TestLib",
|
||||
srcs: ["lib.java"],
|
||||
arch: {
|
||||
arm: {
|
||||
srcs: ["arm.java"],
|
||||
},
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
static_libs: ["static_lib_dep"],
|
||||
java_version: "7",
|
||||
x86: {
|
||||
srcs: ["x86.java"],
|
||||
}
|
||||
},
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
static_libs: ["static_lib_dep"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -66,12 +66,9 @@ android_library {
|
|||
"resource_files": `["res/res.png"]`,
|
||||
"deps": `[":static_lib_dep"]`,
|
||||
"exports": `[":static_lib_dep"]`,
|
||||
"java_version": `"7"`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
MakeNeverlinkDuplicateTargetWithAttrs(
|
||||
"android_library",
|
||||
"TestLib",
|
||||
AttrNameToString{"java_version": `"7"`}),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
||||
}})
|
||||
}
|
||||
|
||||
|
@ -87,10 +84,11 @@ func TestConvertAndroidLibraryWithNoSources(t *testing.T) {
|
|||
},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("android_library", "lib_dep") + `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
srcs: [],
|
||||
manifest: "AndroidManifest.xml",
|
||||
libs: ["lib_dep"],
|
||||
name: "TestLib",
|
||||
srcs: [],
|
||||
manifest: "AndroidManifest.xml",
|
||||
libs: ["lib_dep"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedErr: fmt.Errorf("Module has direct dependencies but no sources. Bazel will not allow this."),
|
||||
|
@ -121,6 +119,7 @@ android_library_import {
|
|||
name: "TestImport",
|
||||
aars: ["import.aar"],
|
||||
static_libs: ["static_lib_dep", "static_import_dep"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -133,7 +132,8 @@ android_library_import {
|
|||
":static_lib_dep",
|
||||
":static_import_dep",
|
||||
]`,
|
||||
"exports": `[":static_import_dep"]`,
|
||||
"exports": `[":static_import_dep"]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
},
|
||||
),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestImport"),
|
||||
|
@ -153,9 +153,10 @@ func TestConvertAndroidLibraryKotlin(t *testing.T) {
|
|||
},
|
||||
Blueprint: `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
srcs: ["a.java", "b.kt"],
|
||||
common_srcs: ["c.kt"],
|
||||
name: "TestLib",
|
||||
srcs: ["a.java", "b.kt"],
|
||||
common_srcs: ["c.kt"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -170,6 +171,7 @@ android_library {
|
|||
"common_srcs": `["c.kt"]`,
|
||||
"manifest": `"AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
||||
}})
|
||||
|
@ -186,9 +188,10 @@ func TestConvertAndroidLibraryKotlinCflags(t *testing.T) {
|
|||
},
|
||||
Blueprint: `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
srcs: ["a.java", "b.kt"],
|
||||
kotlincflags: ["-flag1", "-flag2"],
|
||||
name: "TestLib",
|
||||
srcs: ["a.java", "b.kt"],
|
||||
kotlincflags: ["-flag1", "-flag2"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -206,6 +209,7 @@ android_library {
|
|||
]`,
|
||||
"manifest": `"AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
||||
}})
|
||||
|
|
|
@ -44,9 +44,9 @@ func TestMinimalAndroidApp(t *testing.T) {
|
|||
},
|
||||
Blueprint: `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
srcs: ["app.java"],
|
||||
sdk_version: "current",
|
||||
name: "TestApp",
|
||||
srcs: ["app.java"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -75,17 +75,17 @@ func TestAndroidAppAllSupportedFields(t *testing.T) {
|
|||
},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("android_app", "static_lib_dep") + `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
srcs: ["app.java"],
|
||||
sdk_version: "current",
|
||||
package_name: "com.google",
|
||||
resource_dirs: ["resa", "resb"],
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
static_libs: ["static_lib_dep"],
|
||||
java_version: "7",
|
||||
certificate: "foocert",
|
||||
required: ["static_lib_dep"],
|
||||
asset_dirs: ["assets_"],
|
||||
name: "TestApp",
|
||||
srcs: ["app.java"],
|
||||
sdk_version: "current",
|
||||
package_name: "com.google",
|
||||
resource_dirs: ["resa", "resb"],
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
static_libs: ["static_lib_dep"],
|
||||
java_version: "7",
|
||||
certificate: "foocert",
|
||||
required: ["static_lib_dep"],
|
||||
asset_dirs: ["assets_"],
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -120,16 +120,16 @@ func TestAndroidAppArchVariantSrcs(t *testing.T) {
|
|||
},
|
||||
Blueprint: `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
sdk_version: "current",
|
||||
arch: {
|
||||
arm: {
|
||||
srcs: ["arm.java"],
|
||||
},
|
||||
x86: {
|
||||
srcs: ["x86.java"],
|
||||
}
|
||||
name: "TestApp",
|
||||
sdk_version: "current",
|
||||
arch: {
|
||||
arm: {
|
||||
srcs: ["arm.java"],
|
||||
},
|
||||
x86: {
|
||||
srcs: ["x86.java"],
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -154,8 +154,9 @@ func TestAndroidAppCertIsModule(t *testing.T) {
|
|||
Filesystem: map[string]string{},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
certificate: ":foocert",
|
||||
name: "TestApp",
|
||||
certificate: ":foocert",
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -163,6 +164,7 @@ android_app {
|
|||
"certificate": `":foocert"`,
|
||||
"manifest": `"AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -177,8 +179,9 @@ func TestAndroidAppCertIsSrcFile(t *testing.T) {
|
|||
},
|
||||
Blueprint: `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
certificate: "foocert",
|
||||
name: "TestApp",
|
||||
certificate: "foocert",
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -186,6 +189,7 @@ android_app {
|
|||
"certificate": `"foocert"`,
|
||||
"manifest": `"AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -200,8 +204,9 @@ func TestAndroidAppCertIsNotSrcOrModule(t *testing.T) {
|
|||
},
|
||||
Blueprint: `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
certificate: "foocert",
|
||||
name: "TestApp",
|
||||
certificate: "foocert",
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -209,6 +214,7 @@ android_app {
|
|||
"certificate_name": `"foocert"`,
|
||||
"manifest": `"AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -219,22 +225,20 @@ func TestAndroidAppLibs(t *testing.T) {
|
|||
ModuleTypeUnderTest: "android_app",
|
||||
ModuleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") +
|
||||
simpleModuleDoNotConvertBp2build("java_library", "barLib") + `
|
||||
android_app {
|
||||
name: "foo",
|
||||
libs: ["barLib"]
|
||||
}
|
||||
java_library{
|
||||
name: "barLib",
|
||||
name: "foo",
|
||||
libs: ["barLib"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "barLib", AttrNameToString{}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "barLib"),
|
||||
MakeBazelTarget("android_binary", "foo", AttrNameToString{
|
||||
"manifest": `"AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"deps": `[":barLib-neverlink"]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -247,21 +251,18 @@ func TestAndroidAppKotlinSrcs(t *testing.T) {
|
|||
Filesystem: map[string]string{
|
||||
"res/res.png": "",
|
||||
},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") +
|
||||
simpleModuleDoNotConvertBp2build("java_library", "barLib") + `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.kt"],
|
||||
certificate: ":foocert",
|
||||
manifest: "fooManifest.xml",
|
||||
libs: ["barLib"]
|
||||
}
|
||||
java_library{
|
||||
name: "barLib",
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.kt"],
|
||||
certificate: ":foocert",
|
||||
manifest: "fooManifest.xml",
|
||||
libs: ["barLib"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "barLib", AttrNameToString{}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "barLib"),
|
||||
MakeBazelTarget("android_library", "foo_kt", AttrNameToString{
|
||||
"srcs": `[
|
||||
"a.java",
|
||||
|
@ -270,11 +271,13 @@ java_library{
|
|||
"manifest": `"fooManifest.xml"`,
|
||||
"resource_files": `["res/res.png"]`,
|
||||
"deps": `[":barLib-neverlink"]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
MakeBazelTarget("android_binary", "foo", AttrNameToString{
|
||||
"deps": `[":foo_kt"]`,
|
||||
"certificate": `":foocert"`,
|
||||
"manifest": `"fooManifest.xml"`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -289,31 +292,33 @@ func TestAndroidAppCommonSrcs(t *testing.T) {
|
|||
},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
common_srcs: ["b.kt"],
|
||||
certificate: "foocert",
|
||||
manifest: "fooManifest.xml",
|
||||
libs: ["barLib"],
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
common_srcs: ["b.kt"],
|
||||
certificate: "foocert",
|
||||
manifest: "fooManifest.xml",
|
||||
libs: ["barLib"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
java_library{
|
||||
name: "barLib",
|
||||
name: "barLib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "barLib", AttrNameToString{}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "barLib"),
|
||||
MakeBazelTarget("android_library", "foo_kt", AttrNameToString{
|
||||
"srcs": `["a.java"]`,
|
||||
"common_srcs": `["b.kt"]`,
|
||||
"manifest": `"fooManifest.xml"`,
|
||||
"resource_files": `["res/res.png"]`,
|
||||
"deps": `[":barLib-neverlink"]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
MakeBazelTarget("android_binary", "foo", AttrNameToString{
|
||||
"deps": `[":foo_kt"]`,
|
||||
"certificate_name": `"foocert"`,
|
||||
"manifest": `"fooManifest.xml"`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -328,11 +333,12 @@ func TestAndroidAppKotlinCflags(t *testing.T) {
|
|||
},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
|
||||
android_app {
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.kt"],
|
||||
certificate: ":foocert",
|
||||
manifest: "fooManifest.xml",
|
||||
kotlincflags: ["-flag1", "-flag2"],
|
||||
name: "foo",
|
||||
srcs: ["a.java", "b.kt"],
|
||||
certificate: ":foocert",
|
||||
manifest: "fooManifest.xml",
|
||||
kotlincflags: ["-flag1", "-flag2"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -347,11 +353,13 @@ android_app {
|
|||
"-flag1",
|
||||
"-flag2",
|
||||
]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
MakeBazelTarget("android_binary", "foo", AttrNameToString{
|
||||
"deps": `[":foo_kt"]`,
|
||||
"certificate": `":foocert"`,
|
||||
"manifest": `"fooManifest.xml"`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -364,11 +372,11 @@ func TestAndroidAppManifestSdkVersionsProvided(t *testing.T) {
|
|||
Filesystem: map[string]string{},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
|
||||
android_app {
|
||||
name: "foo",
|
||||
sdk_version: "current",
|
||||
min_sdk_version: "24",
|
||||
max_sdk_version: "30",
|
||||
target_sdk_version: "29",
|
||||
name: "foo",
|
||||
sdk_version: "current",
|
||||
min_sdk_version: "24",
|
||||
max_sdk_version: "30",
|
||||
target_sdk_version: "29",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -393,8 +401,8 @@ func TestAndroidAppMinAndTargetSdkDefaultToSdkVersion(t *testing.T) {
|
|||
Filesystem: map[string]string{},
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
|
||||
android_app {
|
||||
name: "foo",
|
||||
sdk_version: "30",
|
||||
name: "foo",
|
||||
sdk_version: "30",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
|
|
@ -48,6 +48,7 @@ java_library {
|
|||
name: "java-lib-2",
|
||||
srcs: ["b.java"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
sdk_version: "current",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_host_for_device", "java-lib-1", AttrNameToString{
|
||||
|
@ -57,7 +58,8 @@ java_library {
|
|||
"sdk_version": `"none"`,
|
||||
}),
|
||||
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{
|
||||
"srcs": `["b.java"]`,
|
||||
"srcs": `["b.java"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-2"),
|
||||
},
|
||||
|
|
|
@ -42,22 +42,26 @@ func TestJavaLibrary(t *testing.T) {
|
|||
srcs: ["a.java", "b.java"],
|
||||
exclude_srcs: ["b.java"],
|
||||
libs: ["java-lib-2"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "java-lib-2",
|
||||
srcs: ["b.java"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"srcs": `["a.java"]`,
|
||||
"deps": `[":java-lib-2-neverlink"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"deps": `[":java-lib-2-neverlink"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{
|
||||
"srcs": `["b.java"]`,
|
||||
"srcs": `["b.java"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-2"),
|
||||
},
|
||||
|
@ -71,18 +75,21 @@ func TestJavaLibraryConvertsStaticLibsToDepsAndExports(t *testing.T) {
|
|||
srcs: ["a.java"],
|
||||
libs: ["java-lib-2"],
|
||||
static_libs: ["java-lib-3"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "java-lib-2",
|
||||
srcs: ["b.java"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "java-lib-3",
|
||||
srcs: ["c.java"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -92,7 +99,8 @@ java_library {
|
|||
":java-lib-2-neverlink",
|
||||
":java-lib-3",
|
||||
]`,
|
||||
"exports": `[":java-lib-3"]`,
|
||||
"exports": `[":java-lib-3"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -104,6 +112,7 @@ func TestJavaLibraryConvertsStaticLibsToExportsIfNoSrcs(t *testing.T) {
|
|||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
static_libs: ["java-lib-2"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
|
@ -114,25 +123,40 @@ java_library {
|
|||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"exports": `[":java-lib-2"]`,
|
||||
"exports": `[":java-lib-2"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryFailsToConvertNoSdkVersion(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: `
|
||||
java_library {
|
||||
name: "lib",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{}, // no targets expected because sdk_version is not set
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryFailsToConvertLibsWithNoSrcs(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
ExpectedErr: fmt.Errorf("Module has direct dependencies but no sources. Bazel will not allow this."),
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
libs: ["java-lib-2"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "java-lib-2",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{},
|
||||
|
@ -144,6 +168,7 @@ func TestJavaLibraryPlugins(t *testing.T) {
|
|||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
plugins: ["java-plugin-1"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
|
@ -154,7 +179,8 @@ java_plugin {
|
|||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"plugins": `[":java-plugin-1"]`,
|
||||
"plugins": `[":java-plugin-1"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -169,16 +195,21 @@ func TestJavaLibraryJavaVersion(t *testing.T) {
|
|||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
java_version: "11",
|
||||
sdk_version: "current",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"srcs": `["a.java"]`,
|
||||
"java_version": `"11"`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTargetWithAttrs(
|
||||
"java_library",
|
||||
"java-lib-1",
|
||||
AttrNameToString{"java_version": `"11"`}),
|
||||
AttrNameToString{
|
||||
"java_version": `"11"`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -189,6 +220,7 @@ func TestJavaLibraryErrorproneEnabledManually(t *testing.T) {
|
|||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
javacflags: ["-Xsuper-fast"],
|
||||
sdk_version: "current",
|
||||
errorprone: {
|
||||
enabled: true,
|
||||
javacflags: ["-Xep:SpeedLimit:OFF"],
|
||||
|
@ -209,6 +241,7 @@ java_plugin {
|
|||
"plugins": `[":plugin2"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"errorprone_force_enable": `True`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -222,6 +255,7 @@ func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledByDefault(t *testing.T
|
|||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
javacflags: ["-Xsuper-fast"],
|
||||
errorprone: {
|
||||
javacflags: ["-Xep:SpeedLimit:OFF"],
|
||||
|
@ -229,8 +263,9 @@ func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledByDefault(t *testing.T
|
|||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"javacopts": `["-Xsuper-fast"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"javacopts": `["-Xsuper-fast"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -243,6 +278,7 @@ func TestJavaLibraryErrorproneDisabledManually(t *testing.T) {
|
|||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
javacflags: ["-Xsuper-fast"],
|
||||
sdk_version: "current",
|
||||
errorprone: {
|
||||
enabled: false,
|
||||
},
|
||||
|
@ -253,7 +289,8 @@ func TestJavaLibraryErrorproneDisabledManually(t *testing.T) {
|
|||
"-Xsuper-fast",
|
||||
"-XepDisableAllChecks",
|
||||
]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -266,14 +303,15 @@ func TestJavaLibraryLogTags(t *testing.T) {
|
|||
ModuleTypeUnderTest: "java_library",
|
||||
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
||||
Blueprint: `java_library {
|
||||
name: "example_lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
"b.java",
|
||||
"a.logtag",
|
||||
"b.logtag",
|
||||
],
|
||||
bazel_module: { bp2build_available: true },
|
||||
name: "example_lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
"b.java",
|
||||
"a.logtag",
|
||||
"b.logtag",
|
||||
],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("event_log_tags", "example_lib_logtags", AttrNameToString{
|
||||
|
@ -288,6 +326,7 @@ func TestJavaLibraryLogTags(t *testing.T) {
|
|||
"b.java",
|
||||
":example_lib_logtags",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
||||
}})
|
||||
|
@ -301,9 +340,10 @@ func TestJavaLibraryResources(t *testing.T) {
|
|||
"adir/res/b.res": "",
|
||||
"adir/res/dir1/b.res": "",
|
||||
"adir/Android.bp": `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resources: ["res/a.res", "res/b.res"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
name: "java-lib-1",
|
||||
java_resources: ["res/a.res", "res/b.res"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
},
|
||||
Blueprint: "",
|
||||
|
@ -314,6 +354,7 @@ func TestJavaLibraryResources(t *testing.T) {
|
|||
"res/b.res",
|
||||
]`,
|
||||
"resource_strip_prefix": `"adir"`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -328,8 +369,9 @@ func TestJavaLibraryResourceDirs(t *testing.T) {
|
|||
"res/dir1/b.res": "",
|
||||
},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
name: "java-lib-1",
|
||||
java_resource_dirs: ["res"],
|
||||
sdk_version: "current",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
|
@ -339,6 +381,7 @@ func TestJavaLibraryResourceDirs(t *testing.T) {
|
|||
"res/b.res",
|
||||
"res/dir1/b.res",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -352,14 +395,16 @@ func TestJavaLibraryResourcesExcludeDir(t *testing.T) {
|
|||
"res/exclude/b.res": "",
|
||||
},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
name: "java-lib-1",
|
||||
java_resource_dirs: ["res"],
|
||||
sdk_version: "current",
|
||||
exclude_java_resource_dirs: ["res/exclude"],
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"resource_strip_prefix": `"res"`,
|
||||
"resources": `["res/a.res"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -374,8 +419,9 @@ func TestJavaLibraryResourcesExcludeFile(t *testing.T) {
|
|||
"res/dir1/exclude.res": "",
|
||||
},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
name: "java-lib-1",
|
||||
java_resource_dirs: ["res"],
|
||||
sdk_version: "current",
|
||||
exclude_java_resources: ["res/dir1/exclude.res"],
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -385,6 +431,7 @@ func TestJavaLibraryResourcesExcludeFile(t *testing.T) {
|
|||
"res/a.res",
|
||||
"res/dir1/b.res",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -398,8 +445,9 @@ func TestJavaLibraryResourcesWithMultipleDirs(t *testing.T) {
|
|||
"res1/b.res": "",
|
||||
},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
name: "java-lib-1",
|
||||
java_resource_dirs: ["res", "res1"],
|
||||
sdk_version: "current",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_resources", "java-lib-1_resource_dir_res1", AttrNameToString{
|
||||
|
@ -410,6 +458,7 @@ func TestJavaLibraryResourcesWithMultipleDirs(t *testing.T) {
|
|||
"additional_resources": `["java-lib-1_resource_dir_res1"]`,
|
||||
"resources": `["res/a.res"]`,
|
||||
"resource_strip_prefix": `"res"`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -422,9 +471,10 @@ func TestJavaLibraryJavaResourcesAndResourceDirs(t *testing.T) {
|
|||
"resdir/a.res": "",
|
||||
},
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resources: ["res1", "res2"],
|
||||
java_resource_dirs: ["resdir"],
|
||||
name: "java-lib-1",
|
||||
java_resources: ["res1", "res2"],
|
||||
java_resource_dirs: ["resdir"],
|
||||
sdk_version: "current",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_resources", "java-lib-1_resource_dir_resdir", AttrNameToString{
|
||||
|
@ -438,6 +488,7 @@ func TestJavaLibraryJavaResourcesAndResourceDirs(t *testing.T) {
|
|||
"res1",
|
||||
"res2",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -450,14 +501,15 @@ func TestJavaLibraryAidl(t *testing.T) {
|
|||
ModuleTypeUnderTest: "java_library",
|
||||
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
||||
Blueprint: `java_library {
|
||||
name: "example_lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
"b.java",
|
||||
"a.aidl",
|
||||
"b.aidl",
|
||||
],
|
||||
bazel_module: { bp2build_available: true },
|
||||
name: "example_lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
"b.java",
|
||||
"a.aidl",
|
||||
"b.aidl",
|
||||
],
|
||||
bazel_module: { bp2build_available: true },
|
||||
sdk_version: "current",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("aidl_library", "example_lib_aidl_library", AttrNameToString{
|
||||
|
@ -476,6 +528,7 @@ func TestJavaLibraryAidl(t *testing.T) {
|
|||
"a.java",
|
||||
"b.java",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
||||
}})
|
||||
|
@ -488,12 +541,13 @@ func TestJavaLibraryAidlSrcsNoFileGroup(t *testing.T) {
|
|||
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
||||
Blueprint: `
|
||||
java_library {
|
||||
name: "example_lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
"b.aidl",
|
||||
],
|
||||
bazel_module: { bp2build_available: true },
|
||||
name: "example_lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
"b.aidl",
|
||||
],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("aidl_library", "example_lib_aidl_library", AttrNameToString{
|
||||
|
@ -503,9 +557,10 @@ java_library {
|
|||
"deps": `[":example_lib_aidl_library"]`,
|
||||
}),
|
||||
MakeBazelTarget("java_library", "example_lib", AttrNameToString{
|
||||
"deps": `[":example_lib_java_aidl_library"]`,
|
||||
"exports": `[":example_lib_java_aidl_library"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"deps": `[":example_lib_java_aidl_library"]`,
|
||||
"exports": `[":example_lib_java_aidl_library"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
||||
},
|
||||
|
@ -535,14 +590,15 @@ filegroup {
|
|||
],
|
||||
}
|
||||
java_library {
|
||||
name: "example_lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
"b.java",
|
||||
":aidl_files",
|
||||
":random_other_files",
|
||||
],
|
||||
bazel_module: { bp2build_available: true },
|
||||
name: "example_lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
"b.java",
|
||||
":aidl_files",
|
||||
":random_other_files",
|
||||
],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("aidl_library", "aidl_files", AttrNameToString{
|
||||
|
@ -563,6 +619,7 @@ java_library {
|
|||
"b.java",
|
||||
":random_other_files",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
||||
MakeBazelTargetNoRestrictions("filegroup", "random_other_files", AttrNameToString{
|
||||
|
@ -585,24 +642,26 @@ func TestJavaLibraryAidlNonAdjacentAidlFilegroup(t *testing.T) {
|
|||
Filesystem: map[string]string{
|
||||
"path/to/A/Android.bp": `
|
||||
filegroup {
|
||||
name: "A_aidl",
|
||||
srcs: ["aidl/A.aidl"],
|
||||
path: "aidl",
|
||||
name: "A_aidl",
|
||||
srcs: ["aidl/A.aidl"],
|
||||
path: "aidl",
|
||||
}`,
|
||||
},
|
||||
Blueprint: `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: [
|
||||
":A_aidl",
|
||||
],
|
||||
name: "foo",
|
||||
srcs: [
|
||||
":A_aidl",
|
||||
],
|
||||
sdk_version: "current",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_aidl_library", "foo_java_aidl_library", AttrNameToString{
|
||||
"deps": `["//path/to/A:A_aidl"]`,
|
||||
}),
|
||||
MakeBazelTarget("java_library", "foo", AttrNameToString{
|
||||
"exports": `[":foo_java_aidl_library"]`,
|
||||
"exports": `[":foo_java_aidl_library"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "foo"),
|
||||
},
|
||||
|
@ -619,16 +678,17 @@ func TestConvertArmNeonVariant(t *testing.T) {
|
|||
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
srcs: ["lib.java"],
|
||||
arch: {
|
||||
arm: {
|
||||
neon: {
|
||||
srcs: ["arm_neon.java"],
|
||||
},
|
||||
},
|
||||
},
|
||||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
srcs: ["lib.java"],
|
||||
sdk_version: "current",
|
||||
arch: {
|
||||
arm: {
|
||||
neon: {
|
||||
srcs: ["arm_neon.java"],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -642,6 +702,7 @@ android_library {
|
|||
})`,
|
||||
"manifest": `"manifest/AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
||||
}})
|
||||
|
@ -655,19 +716,20 @@ func TestConvertMultipleArchFeatures(t *testing.T) {
|
|||
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
srcs: ["lib.java"],
|
||||
arch: {
|
||||
x86: {
|
||||
ssse3: {
|
||||
srcs: ["ssse3.java"],
|
||||
},
|
||||
sse4_1: {
|
||||
srcs: ["sse4_1.java"],
|
||||
},
|
||||
},
|
||||
},
|
||||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
srcs: ["lib.java"],
|
||||
sdk_version: "current",
|
||||
arch: {
|
||||
x86: {
|
||||
ssse3: {
|
||||
srcs: ["ssse3.java"],
|
||||
},
|
||||
sse4_1: {
|
||||
srcs: ["sse4_1.java"],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -686,6 +748,7 @@ android_library {
|
|||
})`,
|
||||
"manifest": `"manifest/AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
||||
}})
|
||||
|
@ -699,17 +762,18 @@ func TestConvertExcludeSrcsArchFeature(t *testing.T) {
|
|||
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
|
||||
android_library {
|
||||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
srcs: ["lib.java"],
|
||||
arch: {
|
||||
arm: {
|
||||
srcs: ["arm_non_neon.java"],
|
||||
neon: {
|
||||
exclude_srcs: ["arm_non_neon.java"],
|
||||
},
|
||||
},
|
||||
},
|
||||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
srcs: ["lib.java"],
|
||||
arch: {
|
||||
arm: {
|
||||
srcs: ["arm_non_neon.java"],
|
||||
neon: {
|
||||
exclude_srcs: ["arm_non_neon.java"],
|
||||
},
|
||||
},
|
||||
},
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -724,6 +788,7 @@ android_library {
|
|||
})`,
|
||||
"manifest": `"manifest/AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
||||
}})
|
||||
|
@ -736,6 +801,7 @@ func TestJavaLibraryKotlinSrcs(t *testing.T) {
|
|||
name: "java-lib-1",
|
||||
srcs: ["a.java", "b.java", "c.kt"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -745,6 +811,7 @@ func TestJavaLibraryKotlinSrcs(t *testing.T) {
|
|||
"b.java",
|
||||
"c.kt",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("kt_jvm_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -759,6 +826,7 @@ func TestJavaLibraryKotlincflags(t *testing.T) {
|
|||
srcs: [ "a.kt"],
|
||||
kotlincflags: ["-flag1", "-flag2"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -768,6 +836,7 @@ func TestJavaLibraryKotlincflags(t *testing.T) {
|
|||
"-flag1",
|
||||
"-flag2",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("kt_jvm_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -782,6 +851,7 @@ func TestJavaLibraryKotlinCommonSrcs(t *testing.T) {
|
|||
srcs: ["a.java", "b.java"],
|
||||
common_srcs: ["c.kt"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -791,6 +861,7 @@ func TestJavaLibraryKotlinCommonSrcs(t *testing.T) {
|
|||
"b.java",
|
||||
]`,
|
||||
"common_srcs": `["c.kt"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("kt_jvm_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -804,6 +875,7 @@ func TestJavaLibraryArchVariantDeps(t *testing.T) {
|
|||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
libs: ["java-lib-2"],
|
||||
sdk_version: "current",
|
||||
target: {
|
||||
android: {
|
||||
libs: ["java-lib-3"],
|
||||
|
@ -813,16 +885,19 @@ func TestJavaLibraryArchVariantDeps(t *testing.T) {
|
|||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
java_library{
|
||||
name: "java-lib-2",
|
||||
java_library{
|
||||
name: "java-lib-2",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
java_library{
|
||||
name: "java-lib-3",
|
||||
java_library{
|
||||
name: "java-lib-3",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
java_library{
|
||||
name: "java-lib-4",
|
||||
java_library{
|
||||
name: "java-lib-4",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -839,14 +914,9 @@ func TestJavaLibraryArchVariantDeps(t *testing.T) {
|
|||
],
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-2"),
|
||||
MakeBazelTarget("java_library", "java-lib-3", AttrNameToString{}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-3"),
|
||||
MakeBazelTarget("java_library", "java-lib-4", AttrNameToString{}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-4"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -857,6 +927,7 @@ func TestJavaLibraryArchVariantSrcsWithExcludes(t *testing.T) {
|
|||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java", "b.java"],
|
||||
sdk_version: "current",
|
||||
target: {
|
||||
android: {
|
||||
exclude_srcs: ["a.java"],
|
||||
|
@ -871,6 +942,7 @@ func TestJavaLibraryArchVariantSrcsWithExcludes(t *testing.T) {
|
|||
"//build/bazel/platforms/os:android": [],
|
||||
"//conditions:default": ["a.java"],
|
||||
})`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -888,6 +960,7 @@ func TestJavaLibraryJavaResourcesSingleFilegroup(t *testing.T) {
|
|||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
java_resources: [":filegroup1"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
@ -904,6 +977,7 @@ filegroup {
|
|||
"srcs": `["a.java"]`,
|
||||
"resources": `[":filegroup1"]`,
|
||||
"resource_strip_prefix": `"foo"`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
MakeBazelTargetNoRestrictions("filegroup", "filegroup1", AttrNameToString{
|
||||
|
@ -927,6 +1001,7 @@ func TestJavaLibraryJavaResourcesMultipleFilegroup(t *testing.T) {
|
|||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
java_resources: ["a.res", ":filegroup1", ":filegroup2"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
|
@ -959,6 +1034,7 @@ filegroup {
|
|||
"java-lib-1_filegroup_resources_filegroup1",
|
||||
"java-lib-1_filegroup_resources_filegroup2",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
MakeBazelTargetNoRestrictions("filegroup", "filegroup1", AttrNameToString{
|
||||
|
|
|
@ -68,6 +68,7 @@ func TestJavaProto(t *testing.T) {
|
|||
type: "%s",
|
||||
},
|
||||
srcs: ["a.proto"],
|
||||
sdk_version: "current",
|
||||
}`
|
||||
|
||||
protoLibrary := MakeBazelTarget("proto_library", "java-protos_proto", AttrNameToString{
|
||||
|
@ -86,10 +87,12 @@ func TestJavaProto(t *testing.T) {
|
|||
tc.javaLibraryType,
|
||||
javaLibraryName,
|
||||
AttrNameToString{
|
||||
"deps": `[":java-protos_proto"]`,
|
||||
"deps": `[":java-protos_proto"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeBazelTarget("java_library", "java-protos", AttrNameToString{
|
||||
"exports": fmt.Sprintf(`[":%s"]`, javaLibraryName),
|
||||
"exports": fmt.Sprintf(`[":%s"]`, javaLibraryName),
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-protos"),
|
||||
},
|
||||
|
@ -104,6 +107,7 @@ func TestJavaProtoDefault(t *testing.T) {
|
|||
name: "java-protos",
|
||||
srcs: ["a.proto"],
|
||||
java_version: "7",
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -116,15 +120,20 @@ func TestJavaProtoDefault(t *testing.T) {
|
|||
AttrNameToString{
|
||||
"deps": `[":java-protos_proto"]`,
|
||||
"java_version": `"7"`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeBazelTarget("java_library", "java-protos", AttrNameToString{
|
||||
"exports": `[":java-protos_java_proto_lite"]`,
|
||||
"java_version": `"7"`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTargetWithAttrs(
|
||||
"java_library",
|
||||
"java-protos",
|
||||
AttrNameToString{"java_version": `"7"`}),
|
||||
AttrNameToString{
|
||||
"java_version": `"7"`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -688,7 +688,9 @@ func makeCcStubSuiteTargets(name string, attrs AttrNameToString) string {
|
|||
}
|
||||
|
||||
func MakeNeverlinkDuplicateTarget(moduleType string, name string) string {
|
||||
return MakeNeverlinkDuplicateTargetWithAttrs(moduleType, name, AttrNameToString{})
|
||||
return MakeNeverlinkDuplicateTargetWithAttrs(moduleType, name, AttrNameToString{
|
||||
"sdk_version": `"current"`, // use as default
|
||||
})
|
||||
}
|
||||
|
||||
func MakeNeverlinkDuplicateTargetWithAttrs(moduleType string, name string, extraAttrs AttrNameToString) string {
|
||||
|
|
|
@ -2905,6 +2905,11 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
|||
var deps bazel.LabelListAttribute
|
||||
var staticDeps bazel.LabelListAttribute
|
||||
|
||||
if proptools.String(m.deviceProperties.Sdk_version) == "" && m.DeviceSupported() {
|
||||
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "sdk_version unset")
|
||||
return &javaCommonAttributes{}, &bp2BuildJavaInfo{}, false
|
||||
}
|
||||
|
||||
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
|
||||
for axis, configToProps := range archVariantProps {
|
||||
for config, _props := range configToProps {
|
||||
|
|
Loading…
Reference in a new issue