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
|
@ -49,7 +49,7 @@ android_library {
|
|||
},
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
static_libs: ["static_lib_dep"],
|
||||
java_version: "7",
|
||||
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"),
|
||||
}})
|
||||
}
|
||||
|
||||
|
@ -91,6 +88,7 @@ android_library {
|
|||
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{
|
||||
|
@ -134,6 +133,7 @@ android_library_import {
|
|||
":static_import_dep",
|
||||
]`,
|
||||
"exports": `[":static_import_dep"]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
},
|
||||
),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestImport"),
|
||||
|
@ -156,6 +156,7 @@ android_library {
|
|||
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"),
|
||||
}})
|
||||
|
@ -189,6 +191,7 @@ android_library {
|
|||
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"),
|
||||
}})
|
||||
|
|
|
@ -156,6 +156,7 @@ func TestAndroidAppCertIsModule(t *testing.T) {
|
|||
android_app {
|
||||
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
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -179,6 +181,7 @@ func TestAndroidAppCertIsSrcFile(t *testing.T) {
|
|||
android_app {
|
||||
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
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -202,6 +206,7 @@ func TestAndroidAppCertIsNotSrcOrModule(t *testing.T) {
|
|||
android_app {
|
||||
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",
|
||||
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",
|
||||
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
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -295,25 +298,27 @@ android_app {
|
|||
certificate: "foocert",
|
||||
manifest: "fooManifest.xml",
|
||||
libs: ["barLib"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
java_library{
|
||||
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
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
@ -333,6 +338,7 @@ android_app {
|
|||
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"`,
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
@ -58,6 +59,7 @@ java_library {
|
|||
}),
|
||||
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{
|
||||
"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"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
MakeBazelTarget("java_library", "java-lib-2", AttrNameToString{
|
||||
"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{
|
||||
|
@ -93,6 +100,7 @@ java_library {
|
|||
":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 },
|
||||
}
|
||||
|
||||
|
@ -115,24 +124,39 @@ java_library {
|
|||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"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 },
|
||||
}
|
||||
|
||||
|
@ -155,6 +180,7 @@ java_plugin {
|
|||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"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"],
|
||||
|
@ -231,6 +265,7 @@ func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledByDefault(t *testing.T
|
|||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"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,
|
||||
},
|
||||
|
@ -254,6 +290,7 @@ func TestJavaLibraryErrorproneDisabledManually(t *testing.T) {
|
|||
"-XepDisableAllChecks",
|
||||
]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
@ -273,6 +310,7 @@ func TestJavaLibraryLogTags(t *testing.T) {
|
|||
"a.logtag",
|
||||
"b.logtag",
|
||||
],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -288,6 +326,7 @@ func TestJavaLibraryLogTags(t *testing.T) {
|
|||
"b.java",
|
||||
":example_lib_logtags",
|
||||
]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
||||
}})
|
||||
|
@ -303,6 +342,7 @@ func TestJavaLibraryResources(t *testing.T) {
|
|||
"adir/Android.bp": `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resources: ["res/a.res", "res/b.res"],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
},
|
||||
|
@ -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"),
|
||||
},
|
||||
|
@ -330,6 +371,7 @@ func TestJavaLibraryResourceDirs(t *testing.T) {
|
|||
Blueprint: `java_library {
|
||||
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"),
|
||||
},
|
||||
|
@ -354,12 +397,14 @@ func TestJavaLibraryResourcesExcludeDir(t *testing.T) {
|
|||
Blueprint: `java_library {
|
||||
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"),
|
||||
},
|
||||
|
@ -376,6 +421,7 @@ func TestJavaLibraryResourcesExcludeFile(t *testing.T) {
|
|||
Blueprint: `java_library {
|
||||
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"),
|
||||
},
|
||||
|
@ -400,6 +447,7 @@ func TestJavaLibraryResourcesWithMultipleDirs(t *testing.T) {
|
|||
Blueprint: `java_library {
|
||||
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"),
|
||||
},
|
||||
|
@ -425,6 +474,7 @@ func TestJavaLibraryJavaResourcesAndResourceDirs(t *testing.T) {
|
|||
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"),
|
||||
},
|
||||
|
@ -458,6 +509,7 @@ func TestJavaLibraryAidl(t *testing.T) {
|
|||
"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"),
|
||||
}})
|
||||
|
@ -493,6 +546,7 @@ java_library {
|
|||
"a.java",
|
||||
"b.aidl",
|
||||
],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -506,6 +560,7 @@ java_library {
|
|||
"deps": `[":example_lib_java_aidl_library"]`,
|
||||
"exports": `[":example_lib_java_aidl_library"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "example_lib"),
|
||||
},
|
||||
|
@ -542,6 +597,7 @@ java_library {
|
|||
":aidl_files",
|
||||
":random_other_files",
|
||||
],
|
||||
sdk_version: "current",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -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{
|
||||
|
@ -596,6 +653,7 @@ java_library {
|
|||
srcs: [
|
||||
":A_aidl",
|
||||
],
|
||||
sdk_version: "current",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_aidl_library", "foo_java_aidl_library", AttrNameToString{
|
||||
|
@ -603,6 +661,7 @@ java_library {
|
|||
}),
|
||||
MakeBazelTarget("java_library", "foo", AttrNameToString{
|
||||
"exports": `[":foo_java_aidl_library"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "foo"),
|
||||
},
|
||||
|
@ -622,6 +681,7 @@ android_library {
|
|||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
srcs: ["lib.java"],
|
||||
sdk_version: "current",
|
||||
arch: {
|
||||
arm: {
|
||||
neon: {
|
||||
|
@ -642,6 +702,7 @@ android_library {
|
|||
})`,
|
||||
"manifest": `"manifest/AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`, // use as default
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
||||
}})
|
||||
|
@ -658,6 +719,7 @@ android_library {
|
|||
name: "TestLib",
|
||||
manifest: "manifest/AndroidManifest.xml",
|
||||
srcs: ["lib.java"],
|
||||
sdk_version: "current",
|
||||
arch: {
|
||||
x86: {
|
||||
ssse3: {
|
||||
|
@ -686,6 +748,7 @@ android_library {
|
|||
})`,
|
||||
"manifest": `"manifest/AndroidManifest.xml"`,
|
||||
"resource_files": `[]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
|
||||
}})
|
||||
|
@ -710,6 +773,7 @@ android_library {
|
|||
},
|
||||
},
|
||||
},
|
||||
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"],
|
||||
|
@ -815,14 +887,17 @@ func TestJavaLibraryArchVariantDeps(t *testing.T) {
|
|||
|
||||
java_library{
|
||||
name: "java-lib-2",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
java_library{
|
||||
name: "java-lib-3",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
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{
|
||||
|
@ -87,9 +88,11 @@ func TestJavaProto(t *testing.T) {
|
|||
javaLibraryName,
|
||||
AttrNameToString{
|
||||
"deps": `[":java-protos_proto"]`,
|
||||
"sdk_version": `"current"`,
|
||||
}),
|
||||
MakeBazelTarget("java_library", "java-protos", AttrNameToString{
|
||||
"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