Refactor bp2build tests for allowlist v2
Allowlist v2 will change bp2build by automatically disabling rdeps of
unconvertible modules. Many bp2build tests create bp2build stub modules
without an implementation,
This CL changes setup of such tests to also contain a BUILD file with
"stub implementations" of equivalent targets, to keep these test targets
convertible.
To verify this change in-place, this CL removes `bp2build_available:
false` from these dependencies.
This is a test-only change for bp2build tests.
Bug: 285631638
Test: m bp2build
Change-Id: I489480cbc4158a416b7abf57c35a6e2bc2ad6173
diff --git a/bp2build/aar_conversion_test.go b/bp2build/aar_conversion_test.go
index ce20721..59aacbb 100644
--- a/bp2build/aar_conversion_test.go
+++ b/bp2build/aar_conversion_test.go
@@ -15,10 +15,10 @@
package bp2build
import (
+ "testing"
+
"android/soong/android"
"android/soong/java"
-
- "testing"
)
func TestConvertAndroidLibrary(t *testing.T) {
@@ -34,7 +34,8 @@
"res/res.png": "",
"manifest/AndroidManifest.xml": "",
},
- Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
+ StubbedBuildDefinitions: []string{"static_lib_dep"},
+ Blueprint: simpleModule("android_library", "static_lib_dep") + `
android_library {
name: "TestLib",
srcs: ["lib.java"],
@@ -81,7 +82,7 @@
"res/res.png": "",
"AndroidManifest.xml": "",
},
- Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "lib_dep") + `
+ Blueprint: simpleModule("android_library", "lib_dep") + `
android_library {
name: "TestLib",
srcs: [],
@@ -107,18 +108,24 @@
ModuleTypeUnderTestFactory: java.AARImportFactory,
Filesystem: map[string]string{
"import.aar": "",
+ "dep.aar": "",
},
+ StubbedBuildDefinitions: []string{"static_lib_dep", "prebuilt_static_import_dep"},
// Bazel's aar_import can only export *_import targets, so we expect
// only "static_import_dep" in exports, but both "static_lib_dep" and
// "static_import_dep" in deps
- Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") +
- SimpleModuleDoNotConvertBp2build("android_library_import", "static_import_dep") + `
+ Blueprint: simpleModule("android_library", "static_lib_dep") + `
android_library_import {
name: "TestImport",
aars: ["import.aar"],
static_libs: ["static_lib_dep", "static_import_dep"],
sdk_version: "current",
}
+
+// TODO: b/301007952 - This dep is needed because android_library_import must have aars set.
+android_library_import {
+ name: "static_import_dep",
+}
`,
ExpectedBazelTargets: []string{
MakeBazelTarget(
diff --git a/bp2build/android_app_conversion_test.go b/bp2build/android_app_conversion_test.go
index 0d206b0..0daa4fe 100644
--- a/bp2build/android_app_conversion_test.go
+++ b/bp2build/android_app_conversion_test.go
@@ -78,7 +78,8 @@
"manifest/AndroidManifest.xml": "",
"assets_/asset.png": "",
},
- Blueprint: SimpleModuleDoNotConvertBp2build("android_app", "static_lib_dep") + `
+ StubbedBuildDefinitions: []string{"static_lib_dep"},
+ Blueprint: simpleModule("android_app", "static_lib_dep") + `
android_app {
name: "TestApp",
srcs: ["app.java"],
@@ -177,7 +178,8 @@
ModuleTypeUnderTest: "android_app",
ModuleTypeUnderTestFactory: java.AndroidAppFactory,
Filesystem: map[string]string{},
- Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
+ StubbedBuildDefinitions: []string{"foocert"},
+ Blueprint: simpleModule("filegroup", "foocert") + `
android_app {
name: "TestApp",
certificate: ":foocert",
@@ -262,7 +264,8 @@
ModuleTypeUnderTest: "android_app",
ModuleTypeUnderTestFactory: java.AndroidAppFactory,
Filesystem: map[string]string{},
- Blueprint: SimpleModuleDoNotConvertBp2build("java_library", "barLib") + `
+ StubbedBuildDefinitions: []string{"barLib"},
+ Blueprint: simpleModule("java_library", "barLib") + `
android_app {
name: "foo",
libs: ["barLib"],
@@ -291,8 +294,9 @@
Filesystem: map[string]string{
"res/res.png": "",
},
- Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "foocert") +
- SimpleModuleDoNotConvertBp2build("java_library", "barLib") + `
+ StubbedBuildDefinitions: []string{"foocert", "barLib"},
+ Blueprint: simpleModule("filegroup", "foocert") +
+ simpleModule("java_library", "barLib") + `
android_app {
name: "foo",
srcs: ["a.java", "b.kt"],
@@ -334,6 +338,7 @@
Filesystem: map[string]string{
"res/res.png": "",
},
+ StubbedBuildDefinitions: []string{"barLib"},
Blueprint: `
android_app {
name: "foo",
@@ -348,7 +353,6 @@
}
java_library{
name: "barLib",
- bazel_module: { bp2build_available: false },
}
`,
ExpectedBazelTargets: []string{
diff --git a/bp2build/apex_conversion_test.go b/bp2build/apex_conversion_test.go
index d6db677..2a58d01 100644
--- a/bp2build/apex_conversion_test.go
+++ b/bp2build/apex_conversion_test.go
@@ -74,38 +74,34 @@
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"com.android.apogee.key", "com.android.apogee.certificate", "native_shared_lib_1", "native_shared_lib_2",
+ "prebuilt_1", "prebuilt_2", "com.android.apogee-file_contexts", "cc_binary_1", "sh_binary_2"},
Blueprint: `
apex_key {
name: "com.android.apogee.key",
public_key: "com.android.apogee.avbpubkey",
private_key: "com.android.apogee.pem",
- bazel_module: { bp2build_available: false },
}
android_app_certificate {
name: "com.android.apogee.certificate",
certificate: "com.android.apogee",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_1",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_2",
- bazel_module: { bp2build_available: false },
}
prebuilt_etc {
name: "prebuilt_1",
- bazel_module: { bp2build_available: false },
}
prebuilt_etc {
name: "prebuilt_2",
- bazel_module: { bp2build_available: false },
}
filegroup {
@@ -113,11 +109,10 @@
srcs: [
"com.android.apogee-file_contexts",
],
- bazel_module: { bp2build_available: false },
}
-cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } }
-sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } }
+cc_binary { name: "cc_binary_1"}
+sh_binary { name: "sh_binary_2"}
apex {
name: "com.android.apogee",
@@ -202,6 +197,7 @@
Description: "apex - file contexts is a module in another Android.bp",
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
+ StubbedBuildDefinitions: []string{"//a/b:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"a/b/Android.bp": `
filegroup {
@@ -209,7 +205,6 @@
srcs: [
"com.android.apogee-file_contexts",
],
- bazel_module: { bp2build_available: false },
}
`,
},
@@ -252,6 +247,7 @@
Description: "apex - file contexts is not specified",
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
@@ -259,7 +255,6 @@
srcs: [
"com.android.apogee-file_contexts",
],
- bazel_module: { bp2build_available: false },
}
`,
},
@@ -281,12 +276,12 @@
Description: "apex - example with compile_multilib=both",
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
+ StubbedBuildDefinitions: append(multilibStubNames(), "//system/sepolicy/apex:com.android.apogee-file_contexts"),
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}
`,
},
@@ -373,12 +368,12 @@
Description: "apex - example with " + compileMultiLibProp,
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
+ StubbedBuildDefinitions: append(multilibStubNames(), "//system/sepolicy/apex:com.android.apogee-file_contexts"),
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}
`,
},
@@ -393,12 +388,12 @@
Description: "apex - example with compile_multilib=32",
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
+ StubbedBuildDefinitions: append(multilibStubNames(), "//system/sepolicy/apex:com.android.apogee-file_contexts"),
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}
`,
},
@@ -425,12 +420,12 @@
Description: "apex - example with compile_multilib=64",
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
+ StubbedBuildDefinitions: append(multilibStubNames(), "//system/sepolicy/apex:com.android.apogee-file_contexts"),
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}
`,
},
@@ -458,31 +453,31 @@
}})
}
+func multilibStubNames() []string {
+ return []string{"native_shared_lib_for_both", "native_shared_lib_for_first", "native_shared_lib_for_lib32", "native_shared_lib_for_lib64",
+ "native_shared_lib_for_lib64", "unnested_native_shared_lib"}
+}
+
func createMultilibBlueprint(compile_multilib string) string {
return fmt.Sprintf(`
cc_library {
name: "native_shared_lib_for_both",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_for_first",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_for_lib32",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_for_lib64",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "unnested_native_shared_lib",
- bazel_module: { bp2build_available: false },
}
apex {
@@ -519,12 +514,12 @@
Description: "apex - default property values",
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}
`,
},
@@ -546,12 +541,12 @@
Description: "apex - has bazel module props",
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}
`,
},
@@ -575,38 +570,35 @@
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"com.android.apogee.key", "com.android.apogee.certificate", "native_shared_lib_1",
+ "native_shared_lib_2", "prebuilt_1", "prebuilt_2", "com.android.apogee-file_contexts", "cc_binary_1",
+ "sh_binary_2", "com.android.apogee", "com.google.android.apogee.key", "com.google.android.apogee.certificate"},
Blueprint: `
apex_key {
name: "com.android.apogee.key",
public_key: "com.android.apogee.avbpubkey",
private_key: "com.android.apogee.pem",
- bazel_module: { bp2build_available: false },
}
android_app_certificate {
name: "com.android.apogee.certificate",
certificate: "com.android.apogee",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_1",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_2",
- bazel_module: { bp2build_available: false },
}
prebuilt_etc {
name: "prebuilt_1",
- bazel_module: { bp2build_available: false },
}
prebuilt_etc {
name: "prebuilt_2",
- bazel_module: { bp2build_available: false },
}
filegroup {
@@ -614,11 +606,10 @@
srcs: [
"com.android.apogee-file_contexts",
],
- bazel_module: { bp2build_available: false },
}
-cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } }
-sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } }
+cc_binary { name: "cc_binary_1" }
+sh_binary { name: "sh_binary_2" }
apex {
name: "com.android.apogee",
@@ -643,20 +634,17 @@
"prebuilt_1",
"prebuilt_2",
],
- bazel_module: { bp2build_available: false },
}
apex_key {
name: "com.google.android.apogee.key",
public_key: "com.google.android.apogee.avbpubkey",
private_key: "com.google.android.apogee.pem",
- bazel_module: { bp2build_available: false },
}
android_app_certificate {
name: "com.google.android.apogee.certificate",
certificate: "com.google.android.apogee",
- bazel_module: { bp2build_available: false },
}
override_apex {
@@ -717,28 +705,27 @@
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"com.android.apogee.certificate", "native_shared_lib_1",
+ "prebuilt_1", "com.android.apogee-file_contexts", "cc_binary_1", "sh_binary_2",
+ "com.android.apogee", "com.google.android.apogee.key", "com.google.android.apogee.certificate", "com.android.apogee.key"},
Blueprint: `
apex_key {
name: "com.android.apogee.key",
public_key: "com.android.apogee.avbpubkey",
private_key: "com.android.apogee.pem",
- bazel_module: { bp2build_available: false },
}
android_app_certificate {
name: "com.android.apogee.certificate",
certificate: "com.android.apogee",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "native_shared_lib_1",
- bazel_module: { bp2build_available: false },
}
prebuilt_etc {
name: "prebuilt_1",
- bazel_module: { bp2build_available: false },
}
filegroup {
@@ -746,11 +733,10 @@
srcs: [
"com.android.apogee-file_contexts",
],
- bazel_module: { bp2build_available: false },
}
-cc_binary { name: "cc_binary_1", bazel_module: { bp2build_available: false } }
-sh_binary { name: "sh_binary_2", bazel_module: { bp2build_available: false } }
+cc_binary { name: "cc_binary_1"}
+sh_binary { name: "sh_binary_2"}
apex_test {
name: "com.android.apogee",
@@ -773,20 +759,17 @@
prebuilts: [
"prebuilt_1",
],
- bazel_module: { bp2build_available: false },
}
apex_key {
name: "com.google.android.apogee.key",
public_key: "com.google.android.apogee.avbpubkey",
private_key: "com.google.android.apogee.pem",
- bazel_module: { bp2build_available: false },
}
android_app_certificate {
name: "com.google.android.apogee.certificate",
certificate: "com.google.android.apogee",
- bazel_module: { bp2build_available: false },
}
override_apex {
@@ -835,12 +818,12 @@
Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
"a/b/Android.bp": `
apex {
@@ -869,12 +852,12 @@
Description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
"a/b/Android.bp": `
apex {
@@ -904,12 +887,12 @@
Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
},
Blueprint: `
@@ -937,12 +920,12 @@
Description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
},
Blueprint: `
@@ -971,12 +954,12 @@
Description: "override_apex - override package name",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
},
Blueprint: `
@@ -1006,24 +989,22 @@
Description: "override_apex - no override",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"prebuilt_file", "com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
},
Blueprint: `
prebuilt_etc {
name: "prebuilt_file",
- bazel_module: { bp2build_available: false },
}
apex {
name: "com.android.apogee",
- bazel_module: { bp2build_available: false },
- prebuilts: ["prebuilt_file"]
+ prebuilts: ["prebuilt_file"]
}
override_apex {
@@ -1046,35 +1027,32 @@
Description: "override_apex - ooverride",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"prebuilt_file", "prebuilt_file2", "com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
},
Blueprint: `
prebuilt_etc {
name: "prebuilt_file",
- bazel_module: { bp2build_available: false },
}
prebuilt_etc {
name: "prebuilt_file2",
- bazel_module: { bp2build_available: false },
}
apex {
name: "com.android.apogee",
- bazel_module: { bp2build_available: false },
- prebuilts: ["prebuilt_file"]
+ prebuilts: ["prebuilt_file"]
}
override_apex {
name: "com.google.android.apogee",
base: ":com.android.apogee",
- prebuilts: ["prebuilt_file2"]
+ prebuilts: ["prebuilt_file2"]
}
`,
ExpectedBazelTargets: []string{
@@ -1092,24 +1070,22 @@
Description: "override_apex - override with empty list",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"prebuilt_file", "com.android.apogee", "//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
},
Blueprint: `
prebuilt_etc {
name: "prebuilt_file",
- bazel_module: { bp2build_available: false },
}
apex {
name: "com.android.apogee",
- bazel_module: { bp2build_available: false },
- prebuilts: ["prebuilt_file"]
+ prebuilts: ["prebuilt_file"]
}
override_apex {
@@ -1133,12 +1109,12 @@
Description: "override_apex - logging_parent - no override",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
},
Blueprint: `
@@ -1168,12 +1144,12 @@
Description: "override_apex - logging_parent - override",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"//system/sepolicy/apex:com.android.apogee-file_contexts"},
Filesystem: map[string]string{
"system/sepolicy/apex/Android.bp": `
filegroup {
name: "com.android.apogee-file_contexts",
srcs: [ "apogee-file_contexts", ],
- bazel_module: { bp2build_available: false },
}`,
},
Blueprint: `
@@ -1205,11 +1181,11 @@
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"com.android.apogee.certificate", "com.android.apogee-file_contexts", "com.android.apogee"},
Blueprint: `
android_app_certificate {
name: "com.android.apogee.certificate",
certificate: "com.android.apogee",
- bazel_module: { bp2build_available: false },
}
filegroup {
@@ -1217,7 +1193,6 @@
srcs: [
"com.android.apogee-file_contexts",
],
- bazel_module: { bp2build_available: false },
}
apex {
@@ -1225,7 +1200,6 @@
manifest: "apogee_manifest.json",
file_contexts: ":com.android.apogee-file_contexts",
certificate: ":com.android.apogee.certificate",
- bazel_module: { bp2build_available: false },
}
override_apex {
@@ -1250,11 +1224,11 @@
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"com.android.apogee-file_contexts", "com.android.apogee.certificate"},
Blueprint: `
android_app_certificate {
name: "com.android.apogee.certificate",
certificate: "com.android.apogee",
- bazel_module: { bp2build_available: false },
}
apex {
@@ -1263,7 +1237,7 @@
file_contexts: ":com.android.apogee-file_contexts",
certificate: ":com.android.apogee.certificate",
}
-` + SimpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee-file_contexts"),
+` + simpleModule("filegroup", "com.android.apogee-file_contexts"),
ExpectedBazelTargets: []string{
MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
"certificate": `":com.android.apogee.certificate"`,
@@ -1279,6 +1253,7 @@
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"myapex-file_contexts"},
Blueprint: `
cc_library{
name: "foo",
@@ -1299,7 +1274,7 @@
binaries: ["bar"],
native_shared_libs: ["foo"],
}
-` + SimpleModuleDoNotConvertBp2build("filegroup", "myapex-file_contexts"),
+` + simpleModule("filegroup", "myapex-file_contexts"),
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_binary", "bar", AttrNameToString{
"local_includes": `["."]`,
@@ -1350,6 +1325,7 @@
ModuleTypeUnderTest: "apex",
ModuleTypeUnderTestFactory: apex.BundleFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"com.android.apogee-file_contexts"},
Blueprint: `
apex {
name: "com.android.apogee",
@@ -1357,7 +1333,7 @@
file_contexts: ":com.android.apogee-file_contexts",
certificate: "com.android.apogee.certificate",
}
-` + SimpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee-file_contexts"),
+` + simpleModule("filegroup", "com.android.apogee-file_contexts"),
ExpectedBazelTargets: []string{
MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{
"certificate_name": `"com.android.apogee.certificate"`,
@@ -1373,11 +1349,12 @@
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"com.android.apogee.certificate", "com.android.apogee-file_contexts",
+ "com.android.apogee", "com.google.android.apogee.certificate"},
Blueprint: `
android_app_certificate {
name: "com.android.apogee.certificate",
certificate: "com.android.apogee",
- bazel_module: { bp2build_available: false },
}
filegroup {
@@ -1385,7 +1362,6 @@
srcs: [
"com.android.apogee-file_contexts",
],
- bazel_module: { bp2build_available: false },
}
apex {
@@ -1393,13 +1369,11 @@
manifest: "apogee_manifest.json",
file_contexts: ":com.android.apogee-file_contexts",
certificate: ":com.android.apogee.certificate",
- bazel_module: { bp2build_available: false },
}
android_app_certificate {
name: "com.google.android.apogee.certificate",
certificate: "com.google.android.apogee",
- bazel_module: { bp2build_available: false },
}
override_apex {
@@ -1424,11 +1398,11 @@
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"com.android.apogee.certificate", "com.android.apogee", "com.android.apogee-file_contexts"},
Blueprint: `
android_app_certificate {
name: "com.android.apogee.certificate",
certificate: "com.android.apogee",
- bazel_module: { bp2build_available: false },
}
filegroup {
@@ -1436,7 +1410,6 @@
srcs: [
"com.android.apogee-file_contexts",
],
- bazel_module: { bp2build_available: false },
}
apex {
@@ -1469,8 +1442,9 @@
ModuleTypeUnderTest: "apex_test",
ModuleTypeUnderTestFactory: apex.TestApexBundleFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"cc_test_1"},
Blueprint: `
-cc_test { name: "cc_test_1", bazel_module: { bp2build_available: false } }
+cc_test { name: "cc_test_1"}
apex_test {
name: "test_com.android.apogee",
@@ -1497,6 +1471,7 @@
Description: "apex - overriding a module that uses product vars",
ModuleTypeUnderTest: "override_apex",
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
+ StubbedBuildDefinitions: []string{"foo-file_contexts"},
Blueprint: `
soong_config_string_variable {
name: "library_linking_strategy",
@@ -1535,7 +1510,6 @@
srcs: [
"com.android.apogee-file_contexts",
],
- bazel_module: { bp2build_available: false },
}
apex {
diff --git a/bp2build/apex_key_conversion_test.go b/bp2build/apex_key_conversion_test.go
index 8f6e843..140afb7 100644
--- a/bp2build/apex_key_conversion_test.go
+++ b/bp2build/apex_key_conversion_test.go
@@ -83,14 +83,15 @@
ModuleTypeUnderTest: "apex_key",
ModuleTypeUnderTestFactory: apex.ApexKeyFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"com.android.apogee.avbpubkey", "com.android.apogee.pem"},
Blueprint: `
apex_key {
name: "com.android.apogee.key",
public_key: ":com.android.apogee.avbpubkey",
private_key: ":com.android.apogee.pem",
}
-` + SimpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee.avbpubkey") +
- SimpleModuleDoNotConvertBp2build("filegroup", "com.android.apogee.pem"),
+` + simpleModule("filegroup", "com.android.apogee.avbpubkey") +
+ simpleModule("filegroup", "com.android.apogee.pem"),
ExpectedBazelTargets: []string{MakeBazelTargetNoRestrictions("apex_key", "com.android.apogee.key", AttrNameToString{
"private_key": `":com.android.apogee.pem"`,
"public_key": `":com.android.apogee.avbpubkey"`,
diff --git a/bp2build/build_conversion_test.go b/bp2build/build_conversion_test.go
index cefa171..23eae1d 100644
--- a/bp2build/build_conversion_test.go
+++ b/bp2build/build_conversion_test.go
@@ -1743,7 +1743,8 @@
Description: "Required into data test",
ModuleTypeUnderTest: "filegroup",
ModuleTypeUnderTestFactory: android.FileGroupFactory,
- Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
+ StubbedBuildDefinitions: []string{"reqd"},
+ Blueprint: simpleModule("filegroup", "reqd") + `
filegroup {
name: "fg_foo",
required: ["reqd"],
@@ -1759,7 +1760,8 @@
Description: "Required into data test, cyclic self reference is filtered out",
ModuleTypeUnderTest: "filegroup",
ModuleTypeUnderTestFactory: android.FileGroupFactory,
- Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
+ StubbedBuildDefinitions: []string{"reqd"},
+ Blueprint: simpleModule("filegroup", "reqd") + `
filegroup {
name: "fg_foo",
required: ["reqd", "fg_foo"],
@@ -1775,8 +1777,9 @@
Description: "Required via arch into data test",
ModuleTypeUnderTest: "python_library",
ModuleTypeUnderTestFactory: python.PythonLibraryFactory,
- Blueprint: SimpleModuleDoNotConvertBp2build("python_library", "reqdx86") +
- SimpleModuleDoNotConvertBp2build("python_library", "reqdarm") + `
+ StubbedBuildDefinitions: []string{"reqdx86", "reqdarm"},
+ Blueprint: simpleModule("python_library", "reqdx86") +
+ simpleModule("python_library", "reqdarm") + `
python_library {
name: "fg_foo",
arch: {
@@ -1809,7 +1812,8 @@
"data.bin": "",
"src.py": "",
},
- Blueprint: SimpleModuleDoNotConvertBp2build("python_library", "reqd") + `
+ StubbedBuildDefinitions: []string{"reqd"},
+ Blueprint: simpleModule("python_library", "reqd") + `
python_library {
name: "fg_foo",
data: ["data.bin"],
@@ -1831,7 +1835,8 @@
Description: "All props-to-attrs at once together test",
ModuleTypeUnderTest: "filegroup",
ModuleTypeUnderTestFactory: android.FileGroupFactory,
- Blueprint: SimpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
+ StubbedBuildDefinitions: []string{"reqd"},
+ Blueprint: simpleModule("filegroup", "reqd") + `
filegroup {
name: "fg_foo",
required: ["reqd"],
diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go
index 3d3b860..c679703 100644
--- a/bp2build/cc_binary_conversion_test.go
+++ b/bp2build/cc_binary_conversion_test.go
@@ -44,10 +44,11 @@
}
type ccBinaryBp2buildTestCase struct {
- description string
- filesystem map[string]string
- blueprint string
- targets []testBazelTarget
+ description string
+ filesystem map[string]string
+ blueprint string
+ targets []testBazelTarget
+ stubbedBuildDefinitions []string
}
func registerCcBinaryModuleTypes(ctx android.RegistrationContext) {
@@ -81,6 +82,7 @@
Description: description,
Blueprint: binaryReplacer.Replace(testCase.blueprint),
Filesystem: testCase.filesystem,
+ StubbedBuildDefinitions: testCase.stubbedBuildDefinitions,
})
})
}
@@ -97,6 +99,7 @@
Description: description,
Blueprint: hostBinaryReplacer.Replace(testCase.blueprint),
Filesystem: testCase.filesystem,
+ StubbedBuildDefinitions: testCase.stubbedBuildDefinitions,
})
})
}
@@ -107,6 +110,7 @@
filesystem: map[string]string{
soongCcVersionLibBpPath: soongCcVersionLibBp,
},
+ stubbedBuildDefinitions: []string{"//build/soong/cc/libbuildversion:libbuildversion"},
blueprint: `
{rule_name} {
name: "foo",
@@ -264,7 +268,8 @@
func TestCcBinarySplitSrcsByLang(t *testing.T) {
runCcHostBinaryTestCase(t, ccBinaryBp2buildTestCase{
- description: "split srcs by lang",
+ description: "split srcs by lang",
+ stubbedBuildDefinitions: []string{"fg_foo"},
blueprint: `
{rule_name} {
name: "foo",
@@ -276,7 +281,7 @@
],
include_build_directory: false,
}
-` + SimpleModuleDoNotConvertBp2build("filegroup", "fg_foo"),
+` + simpleModule("filegroup", "fg_foo"),
targets: []testBazelTarget{
{"cc_binary", "foo", AttrNameToString{
"srcs": `[
@@ -300,17 +305,17 @@
func TestCcBinaryDoNotDistinguishBetweenDepsAndImplementationDeps(t *testing.T) {
runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
description: "no implementation deps",
+ stubbedBuildDefinitions: []string{"generated_hdr", "export_generated_hdr", "static_dep", "implementation_static_dep",
+ "whole_static_dep", "not_explicitly_exported_whole_static_dep", "shared_dep", "implementation_shared_dep"},
blueprint: `
genrule {
name: "generated_hdr",
cmd: "nothing to see here",
- bazel_module: { bp2build_available: false },
}
genrule {
name: "export_generated_hdr",
cmd: "nothing to see here",
- bazel_module: { bp2build_available: false },
}
{rule_name} {
@@ -326,12 +331,12 @@
export_generated_headers: ["export_generated_hdr"],
}
` +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "static_dep") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "implementation_static_dep") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "whole_static_dep") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "not_explicitly_exported_whole_static_dep") +
- SimpleModuleDoNotConvertBp2build("cc_library", "shared_dep") +
- SimpleModuleDoNotConvertBp2build("cc_library", "implementation_shared_dep"),
+ simpleModule("cc_library_static", "static_dep") +
+ simpleModule("cc_library_static", "implementation_static_dep") +
+ simpleModule("cc_library_static", "whole_static_dep") +
+ simpleModule("cc_library_static", "not_explicitly_exported_whole_static_dep") +
+ simpleModule("cc_library", "shared_dep") +
+ simpleModule("cc_library", "implementation_shared_dep"),
targets: []testBazelTarget{
{"cc_binary", "foo", AttrNameToString{
"deps": `[
@@ -502,6 +507,7 @@
func TestCcBinarySharedProto(t *testing.T) {
runCcBinaryTests(t, ccBinaryBp2buildTestCase{
+ stubbedBuildDefinitions: []string{"libprotobuf-cpp-full", "libprotobuf-cpp-lite"},
blueprint: soongCcProtoLibraries + `{rule_name} {
name: "foo",
srcs: ["foo.proto"],
@@ -524,6 +530,7 @@
func TestCcBinaryStaticProto(t *testing.T) {
runCcBinaryTests(t, ccBinaryBp2buildTestCase{
+ stubbedBuildDefinitions: []string{"libprotobuf-cpp-full", "libprotobuf-cpp-lite"},
blueprint: soongCcProtoLibraries + `{rule_name} {
name: "foo",
srcs: ["foo.proto"],
@@ -1224,13 +1231,13 @@
func TestCcBinaryStatic_SystemSharedLibUsedAsDep(t *testing.T) {
runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
- description: "cc_library_static system_shared_lib empty for linux_bionic variant",
+ stubbedBuildDefinitions: []string{"libm", "libc"},
+ description: "cc_library_static system_shared_lib empty for linux_bionic variant",
blueprint: soongCcLibraryStaticPreamble +
- SimpleModuleDoNotConvertBp2build("cc_library", "libc") + `
+ simpleModule("cc_library", "libc") + `
cc_library {
name: "libm",
- bazel_module: { bp2build_available: false },
}
cc_binary {
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 76dc590..ec603c2 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -35,19 +35,16 @@
soongCcVersionLibBp = `
cc_library_static {
name: "libbuildversion",
- bazel_module: { bp2build_available: false },
}
`
soongCcProtoLibraries = `
cc_library {
name: "libprotobuf-cpp-lite",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "libprotobuf-cpp-full",
- bazel_module: { bp2build_available: false },
}`
soongCcProtoPreamble = soongCcLibraryPreamble + soongCcProtoLibraries
@@ -55,6 +52,7 @@
func runCcLibraryTestCase(t *testing.T, tc Bp2buildTestCase) {
t.Helper()
+ tc.StubbedBuildDefinitions = append(tc.StubbedBuildDefinitions, "libprotobuf-cpp-lite", "libprotobuf-cpp-full")
RunBp2BuildTestCase(t, registerCcLibraryModuleTypes, tc)
}
@@ -73,6 +71,7 @@
Description: "cc_library - simple example",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"//build/soong/cc/libbuildversion:libbuildversion", "some-headers"},
Filesystem: map[string]string{
soongCcVersionLibBpPath: soongCcVersionLibBp,
"android.cpp": "",
@@ -95,7 +94,7 @@
"foo-dir/a.h": "",
},
Blueprint: soongCcLibraryPreamble +
- SimpleModuleDoNotConvertBp2build("cc_library_headers", "some-headers") + `
+ simpleModule("cc_library_headers", "some-headers") + `
cc_library {
name: "foo-lib",
srcs: ["impl.cpp"],
@@ -169,6 +168,7 @@
Description: "cc_library - trimmed example of //bionic/linker:ld-android",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"libc_headers"},
Filesystem: map[string]string{
"ld-android.cpp": "",
"linked_list.h": "",
@@ -177,7 +177,7 @@
"linker_cfi.h": "",
},
Blueprint: soongCcLibraryPreamble +
- SimpleModuleDoNotConvertBp2build("cc_library_headers", "libc_headers") + `
+ simpleModule("cc_library_headers", "libc_headers") + `
cc_library {
name: "fake-ld-android",
srcs: ["ld_android.cpp"],
@@ -320,54 +320,49 @@
cc_library_static {
name: "static_dep_for_shared",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "static_dep_for_static",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "static_dep_for_both",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "whole_static_lib_for_shared",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "whole_static_lib_for_static",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "whole_static_lib_for_both",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "whole_and_static_lib_for_both",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "shared_dep_for_shared",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "shared_dep_for_static",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "shared_dep_for_both",
- bazel_module: { bp2build_available: false },
}
`,
+ StubbedBuildDefinitions: []string{"static_dep_for_shared", "static_dep_for_static",
+ "static_dep_for_both", "whole_static_lib_for_shared", "whole_static_lib_for_static",
+ "whole_static_lib_for_both", "whole_and_static_lib_for_both", "shared_dep_for_shared",
+ "shared_dep_for_static", "shared_dep_for_both",
+ },
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "a_bp2build_cc_library_static", AttrNameToString{
"copts": `[
@@ -458,24 +453,34 @@
},
include_build_directory: false,
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "static_dep_for_shared") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "implementation_static_dep_for_shared") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "static_dep_for_static") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "implementation_static_dep_for_static") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "static_dep_for_both") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "implementation_static_dep_for_both") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "whole_static_dep_for_shared") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "not_explicitly_exported_whole_static_dep_for_shared") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "whole_static_dep_for_static") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "not_explicitly_exported_whole_static_dep_for_static") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "whole_static_dep_for_both") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "not_explicitly_exported_whole_static_dep_for_both") +
- SimpleModuleDoNotConvertBp2build("cc_library", "shared_dep_for_shared") +
- SimpleModuleDoNotConvertBp2build("cc_library", "implementation_shared_dep_for_shared") +
- SimpleModuleDoNotConvertBp2build("cc_library", "shared_dep_for_static") +
- SimpleModuleDoNotConvertBp2build("cc_library", "implementation_shared_dep_for_static") +
- SimpleModuleDoNotConvertBp2build("cc_library", "shared_dep_for_both") +
- SimpleModuleDoNotConvertBp2build("cc_library", "implementation_shared_dep_for_both"),
+` + simpleModule("cc_library_static", "static_dep_for_shared") +
+ simpleModule("cc_library_static", "implementation_static_dep_for_shared") +
+ simpleModule("cc_library_static", "static_dep_for_static") +
+ simpleModule("cc_library_static", "implementation_static_dep_for_static") +
+ simpleModule("cc_library_static", "static_dep_for_both") +
+ simpleModule("cc_library_static", "implementation_static_dep_for_both") +
+ simpleModule("cc_library_static", "whole_static_dep_for_shared") +
+ simpleModule("cc_library_static", "not_explicitly_exported_whole_static_dep_for_shared") +
+ simpleModule("cc_library_static", "whole_static_dep_for_static") +
+ simpleModule("cc_library_static", "not_explicitly_exported_whole_static_dep_for_static") +
+ simpleModule("cc_library_static", "whole_static_dep_for_both") +
+ simpleModule("cc_library_static", "not_explicitly_exported_whole_static_dep_for_both") +
+ simpleModule("cc_library", "shared_dep_for_shared") +
+ simpleModule("cc_library", "implementation_shared_dep_for_shared") +
+ simpleModule("cc_library", "shared_dep_for_static") +
+ simpleModule("cc_library", "implementation_shared_dep_for_static") +
+ simpleModule("cc_library", "shared_dep_for_both") +
+ simpleModule("cc_library", "implementation_shared_dep_for_both"),
+ StubbedBuildDefinitions: []string{"static_dep_for_shared", "implementation_static_dep_for_shared",
+ "static_dep_for_static", "implementation_static_dep_for_static", "static_dep_for_both",
+ "implementation_static_dep_for_both", "whole_static_dep_for_shared",
+ "not_explicitly_exported_whole_static_dep_for_shared", "whole_static_dep_for_static",
+ "not_explicitly_exported_whole_static_dep_for_static", "whole_static_dep_for_both",
+ "not_explicitly_exported_whole_static_dep_for_both", "shared_dep_for_shared",
+ "implementation_shared_dep_for_shared", "shared_dep_for_static",
+ "implementation_shared_dep_for_static", "shared_dep_for_both",
+ "implementation_shared_dep_for_both",
+ },
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "a_bp2build_cc_library_static", AttrNameToString{
"copts": `[
@@ -550,6 +555,8 @@
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
Dir: "foo/bar",
+ StubbedBuildDefinitions: []string{"//foo/bar:prebuilt_whole_static_lib_for_shared", "//foo/bar:prebuilt_whole_static_lib_for_static",
+ "//foo/bar:prebuilt_whole_static_lib_for_both"},
Filesystem: map[string]string{
"foo/bar/Android.bp": `
cc_library {
@@ -666,6 +673,10 @@
cc_library_static { name: "android_dep_for_shared" }
`,
},
+ StubbedBuildDefinitions: []string{"//foo/bar:static_dep_for_shared", "//foo/bar:static_dep_for_static",
+ "//foo/bar:static_dep_for_both", "//foo/bar:arm_static_dep_for_shared", "//foo/bar:arm_whole_static_dep_for_shared",
+ "//foo/bar:arm_shared_dep_for_shared", "//foo/bar:x86_dep_for_static", "//foo/bar:android_dep_for_shared",
+ },
Blueprint: soongCcLibraryPreamble,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "a_bp2build_cc_library_static", AttrNameToString{
@@ -747,6 +758,7 @@
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
Dir: "foo/bar",
+ StubbedBuildDefinitions: []string{"//foo/bar:shared_filegroup", "//foo/bar:static_filegroup", "//foo/bar:both_filegroup"},
Filesystem: map[string]string{
"foo/bar/both_source.cpp": "",
"foo/bar/both_source.cc": "",
@@ -1018,10 +1030,10 @@
Description: "cc_library shared_libs",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"mylib"},
Blueprint: soongCcLibraryPreamble + `
cc_library {
name: "mylib",
- bazel_module: { bp2build_available: false },
}
cc_library {
@@ -1182,6 +1194,10 @@
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"arm_whole_static_lib_excludes", "malloc_not_svelte_whole_static_lib",
+ "arm_static_lib_excludes", "malloc_not_svelte_whole_static_lib_excludes", "arm_shared_lib_excludes",
+ "malloc_not_svelte_static_lib_excludes", "arm_shared_lib_excludes", "malloc_not_svelte_shared_lib",
+ },
Blueprint: soongCcLibraryStaticPreamble + `
cc_library {
name: "foo_static",
@@ -1223,37 +1239,30 @@
cc_library {
name: "arm_whole_static_lib_excludes",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "malloc_not_svelte_whole_static_lib",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "malloc_not_svelte_whole_static_lib_excludes",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "arm_static_lib_excludes",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "malloc_not_svelte_static_lib_excludes",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "arm_shared_lib_excludes",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "malloc_not_svelte_shared_lib",
- bazel_module: { bp2build_available: false },
}
`,
ExpectedBazelTargets: makeCcLibraryTargets("foo_static", AttrNameToString{
@@ -1289,6 +1298,7 @@
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"malloc_not_svelte_header_lib"},
Blueprint: soongCcLibraryStaticPreamble + `
cc_library {
name: "foo_static",
@@ -1303,7 +1313,6 @@
cc_library {
name: "malloc_not_svelte_header_lib",
- bazel_module: { bp2build_available: false },
}
`,
ExpectedBazelTargets: makeCcLibraryTargets("foo_static", AttrNameToString{
@@ -1813,10 +1822,10 @@
Description: "cc_library system_shared_libs empty for linux_bionic variant",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"libc_musl"},
Blueprint: soongCcLibraryPreamble + `
cc_library {
name: "libc_musl",
- bazel_module: { bp2build_available: false },
}
cc_library {
@@ -1844,6 +1853,7 @@
Description: "cc_library system_shared_libs empty for bionic variant",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"libc_musl"},
Blueprint: soongCcLibraryPreamble + `
cc_library {
name: "libc_musl",
@@ -1875,10 +1885,10 @@
Description: "cc_library system_shared_lib empty for musl variant",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"libc_musl"},
Blueprint: soongCcLibraryPreamble + `
cc_library {
name: "libc_musl",
- bazel_module: { bp2build_available: false },
}
cc_library {
@@ -1928,14 +1938,13 @@
Description: "cc_library system_shared_libs set for shared and root",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"libc", "libm"},
Blueprint: soongCcLibraryPreamble + `
cc_library {
name: "libc",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "libm",
- bazel_module: { bp2build_available: false },
}
cc_library {
@@ -2506,6 +2515,7 @@
runCcLibraryTestCase(t, Bp2buildTestCase{
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"//path/to/A:a_fg_proto"},
Filesystem: map[string]string{
"path/to/A/Android.bp": `
filegroup {
@@ -2549,11 +2559,12 @@
runCcLibraryTestCase(t, Bp2buildTestCase{
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"a_fg_proto", "b_protos", "c-proto-srcs", "proto-srcs-d"},
Blueprint: soongCcProtoPreamble +
- SimpleModuleDoNotConvertBp2build("filegroup", "a_fg_proto") +
- SimpleModuleDoNotConvertBp2build("filegroup", "b_protos") +
- SimpleModuleDoNotConvertBp2build("filegroup", "c-proto-srcs") +
- SimpleModuleDoNotConvertBp2build("filegroup", "proto-srcs-d") + `
+ simpleModule("filegroup", "a_fg_proto") +
+ simpleModule("filegroup", "b_protos") +
+ simpleModule("filegroup", "c-proto-srcs") +
+ simpleModule("filegroup", "proto-srcs-d") + `
cc_library {
name: "a",
srcs: [":a_fg_proto"],
@@ -2849,11 +2860,11 @@
Filesystem: map[string]string{
"bar.map.txt": "",
},
+ StubbedBuildDefinitions: []string{"barlib"},
Blueprint: `
cc_library {
name: "barlib",
stubs: { symbol_file: "bar.map.txt", versions: ["28", "29", "current"] },
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "foolib",
@@ -2884,16 +2895,15 @@
Filesystem: map[string]string{
"bar.map.txt": "",
},
- Blueprint: SimpleModuleDoNotConvertBp2build("cc_library", "bazlib") + `
+ StubbedBuildDefinitions: []string{"bazlib", "quxlib", "barlib"},
+ Blueprint: simpleModule("cc_library", "bazlib") + `
cc_library {
name: "quxlib",
stubs: { symbol_file: "bar.map.txt", versions: ["current"] },
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "barlib",
stubs: { symbol_file: "bar.map.txt", versions: ["28", "29", "current"] },
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "foolib",
@@ -3007,18 +3017,18 @@
cc_library {
name: "foo",
- runtime_libs: ["foo"],
+ runtime_libs: ["bar"],
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_shared", "bar", AttrNameToString{
"local_includes": `["."]`,
}),
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
- "runtime_deps": `[":foo"]`,
+ "runtime_deps": `[":bar"]`,
"local_includes": `["."]`,
}),
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
- "runtime_deps": `[":foo"]`,
+ "runtime_deps": `[":bar"]`,
"local_includes": `["."]`,
}),
},
@@ -3229,6 +3239,7 @@
Description: "cc_library with non aidl filegroup",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"//path/to/A:A_aidl"},
Filesystem: map[string]string{
"path/to/A/Android.bp": `
filegroup {
@@ -3518,6 +3529,7 @@
Description: "cc_aidl_library depends on libs from parent cc_library_static",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"bar-static", "baz-static", "bar-shared", "baz-shared"},
Blueprint: `
cc_library_static {
name: "foo",
@@ -3539,10 +3551,10 @@
"baz-shared",
],
}` +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "bar-static") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "baz-static") +
- SimpleModuleDoNotConvertBp2build("cc_library", "bar-shared") +
- SimpleModuleDoNotConvertBp2build("cc_library", "baz-shared"),
+ simpleModule("cc_library_static", "bar-static") +
+ simpleModule("cc_library_static", "baz-static") +
+ simpleModule("cc_library", "bar-shared") +
+ simpleModule("cc_library", "baz-shared"),
ExpectedBazelTargets: []string{
MakeBazelTarget("aidl_library", "foo_aidl_library", AttrNameToString{
"srcs": `["Foo.aidl"]`,
@@ -4086,17 +4098,16 @@
Description: "cc_library with in apex with stub shared_libs and export_shared_lib_headers",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"barlib", "bazlib"},
Blueprint: `
cc_library {
name: "barlib",
stubs: { symbol_file: "bar.map.txt", versions: ["28", "29", "current"] },
- bazel_module: { bp2build_available: false },
apex_available: ["//apex_available:platform",],
}
cc_library {
name: "bazlib",
stubs: { symbol_file: "bar.map.txt", versions: ["28", "29", "current"] },
- bazel_module: { bp2build_available: false },
apex_available: ["//apex_available:platform",],
}
cc_library {
@@ -4472,6 +4483,7 @@
Description: "cc_library is built from .y/.yy files",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ StubbedBuildDefinitions: []string{"staticlib", "sharedlib"},
Blueprint: soongCcLibraryPreamble + `cc_library {
name: "a",
srcs: [
@@ -4488,11 +4500,9 @@
}
cc_library_static {
name: "staticlib",
- bazel_module: { bp2build_available: false },
}
cc_library {
name: "sharedlib",
- bazel_module: { bp2build_available: false },
}
`,
ExpectedBazelTargets: []string{
@@ -4746,7 +4756,7 @@
canonical_path_from_root: true,
}
}
-` + SimpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite"),
+` + simpleModule("cc_library", "libprotobuf-cpp-lite"),
Filesystem: map[string]string{
"bar/Android.bp": "",
"baz/subbaz/Android.bp": "",
@@ -4814,7 +4824,7 @@
canonical_path_from_root: false,
}
}
-` + SimpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite"),
+` + simpleModule("cc_library", "libprotobuf-cpp-lite"),
Filesystem: map[string]string{
"bar/Android.bp": "",
"baz/subbaz/Android.bp": "",
@@ -4884,7 +4894,7 @@
include_dirs: ["bar"],
}
}
-` + SimpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite"),
+` + simpleModule("cc_library", "libprotobuf-cpp-lite"),
Filesystem: map[string]string{
"bar/Android.bp": "",
"bar/bar.proto": "",
@@ -4955,7 +4965,7 @@
include_dirs: ["baz"],
}
}
-` + SimpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite"),
+` + simpleModule("cc_library", "libprotobuf-cpp-lite"),
Filesystem: map[string]string{
"bar/Android.bp": "", // package boundary
"baz/Android.bp": "",
@@ -4990,7 +5000,14 @@
Description: "cc_library depends on .proto files using proto.local_include_dirs",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
- Blueprint: SimpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite"),
+ Blueprint: `
+cc_library {
+ name: "libprotobuf-cpp-lite",
+ // TODO: b/285631638 - A stubbed proto library dependency does not work as a protolib
+ // dependency of cc_library_static.
+ bazel_module: { bp2build_available: false },
+}
+`,
Filesystem: map[string]string{
"foo/Android.bp": `cc_library_static {
name: "foo",
@@ -5047,7 +5064,7 @@
Description: "proto_library generated for proto.include_dirs is compatible for all axes",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
- Blueprint: SimpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite") + `
+ Blueprint: simpleModule("cc_library", "libprotobuf-cpp-lite") + `
cc_library {
name: "foo_device",
device_supported: true, // this is the default behavior, but added explicitly here for illustration
diff --git a/bp2build/cc_library_headers_conversion_test.go b/bp2build/cc_library_headers_conversion_test.go
index 40e8451..0fa2086 100644
--- a/bp2build/cc_library_headers_conversion_test.go
+++ b/bp2build/cc_library_headers_conversion_test.go
@@ -131,30 +131,26 @@
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"android-lib", "base-lib", "darwin-lib",
+ "linux-lib", "linux_bionic-lib", "windows-lib"},
Blueprint: soongCcLibraryPreamble + `
cc_library_headers {
name: "android-lib",
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "base-lib",
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "darwin-lib",
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "linux-lib",
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "linux_bionic-lib",
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "windows-lib",
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "foo_headers",
@@ -205,14 +201,13 @@
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"android-lib", "exported-lib"},
Blueprint: soongCcLibraryPreamble + `
cc_library_headers {
name: "android-lib",
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "exported-lib",
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "foo_headers",
@@ -333,6 +328,7 @@
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
@@ -340,7 +336,7 @@
static_libs: ["foo_export", "foo_no_reexport"],
bazel_module: { bp2build_available: true },
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
+` + simpleModule("cc_library_headers", "foo_export"),
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
"deps": `[":foo_export"]`,
@@ -355,6 +351,7 @@
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
@@ -362,7 +359,7 @@
shared_libs: ["foo_export", "foo_no_reexport"],
bazel_module: { bp2build_available: true },
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
+` + simpleModule("cc_library_headers", "foo_export"),
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
"deps": `[":foo_export"]`,
@@ -377,6 +374,7 @@
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
@@ -384,7 +382,7 @@
header_libs: ["foo_export", "foo_no_reexport"],
bazel_module: { bp2build_available: true },
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
+` + simpleModule("cc_library_headers", "foo_export"),
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
"deps": `[":foo_export"]`,
@@ -399,13 +397,14 @@
ModuleTypeUnderTest: "cc_library_headers",
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"foo_export"},
Blueprint: soongCcLibraryHeadersPreamble + `
cc_library_headers {
name: "foo_headers",
whole_static_libs: ["foo_export"],
bazel_module: { bp2build_available: true },
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
+` + simpleModule("cc_library_headers", "foo_export"),
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
"deps": `[":foo_export"]`,
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index b3dd6b1..6f600da 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -38,6 +38,7 @@
func runCcLibrarySharedTestCase(t *testing.T, tc Bp2buildTestCase) {
t.Helper()
t.Parallel()
+ tc.StubbedBuildDefinitions = append(tc.StubbedBuildDefinitions, "libbuildversion", "libprotobuf-cpp-lite", "libprotobuf-cpp-full")
(&tc).ModuleTypeUnderTest = "cc_library_shared"
(&tc).ModuleTypeUnderTestFactory = cc.LibrarySharedFactory
RunBp2BuildTestCase(t, registerCcLibrarySharedModuleTypes, tc)
@@ -45,7 +46,8 @@
func TestCcLibrarySharedSimple(t *testing.T) {
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
- Description: "cc_library_shared simple overall test",
+ Description: "cc_library_shared simple overall test",
+ StubbedBuildDefinitions: []string{"header_lib_1", "header_lib_2", "whole_static_lib_1", "whole_static_lib_2", "shared_lib_1", "shared_lib_2"},
Filesystem: map[string]string{
// NOTE: include_dir headers *should not* appear in Bazel hdrs later (?)
"include_dir_1/include_dir_1_a.h": "",
@@ -70,37 +72,31 @@
cc_library_headers {
name: "header_lib_1",
export_include_dirs: ["header_lib_1"],
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "header_lib_2",
export_include_dirs: ["header_lib_2"],
- bazel_module: { bp2build_available: false },
}
cc_library_shared {
name: "shared_lib_1",
srcs: ["shared_lib_1.cc"],
- bazel_module: { bp2build_available: false },
}
cc_library_shared {
name: "shared_lib_2",
srcs: ["shared_lib_2.cc"],
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "whole_static_lib_1",
srcs: ["whole_static_lib_1.cc"],
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "whole_static_lib_2",
srcs: ["whole_static_lib_2.cc"],
- bazel_module: { bp2build_available: false },
}
cc_library_shared {
@@ -186,16 +182,15 @@
func TestCcLibrarySharedArchSpecificSharedLib(t *testing.T) {
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
- Description: "cc_library_shared arch-specific shared_libs with whole_static_libs",
- Filesystem: map[string]string{},
+ Description: "cc_library_shared arch-specific shared_libs with whole_static_libs",
+ Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"static_dep", "shared_dep"},
Blueprint: soongCcLibrarySharedPreamble + `
cc_library_static {
name: "static_dep",
- bazel_module: { bp2build_available: false },
}
cc_library_shared {
name: "shared_dep",
- bazel_module: { bp2build_available: false },
}
cc_library_shared {
name: "foo_shared",
@@ -510,6 +505,7 @@
Filesystem: map[string]string{
soongCcVersionLibBpPath: soongCcVersionLibBp,
},
+ StubbedBuildDefinitions: []string{"//build/soong/cc/libbuildversion:libbuildversion"},
Blueprint: soongCcProtoPreamble + `cc_library_shared {
name: "foo",
use_version_lib: true,
@@ -564,11 +560,11 @@
Description: "cc_library_shared stubs",
ModuleTypeUnderTest: "cc_library_shared",
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
+ StubbedBuildDefinitions: []string{"a"},
Blueprint: soongCcLibrarySharedPreamble + `
cc_library_shared {
name: "a",
stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
- bazel_module: { bp2build_available: false },
include_build_directory: false,
apex_available: ["made_up_apex"],
}
@@ -593,11 +589,11 @@
Description: "cc_library_shared stubs",
ModuleTypeUnderTest: "cc_library_shared",
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
+ StubbedBuildDefinitions: []string{"a"},
Blueprint: soongCcLibrarySharedPreamble + `
cc_library_shared {
name: "a",
stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
- bazel_module: { bp2build_available: false },
include_build_directory: false,
apex_available: ["apex_a"],
}
@@ -627,19 +623,18 @@
Description: "cc_library_shared stubs",
ModuleTypeUnderTest: "cc_library_shared",
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
+ StubbedBuildDefinitions: []string{"libplatform_stable", "libapexfoo_stable"},
Blueprint: soongCcLibrarySharedPreamble + `
cc_library_shared {
name: "libplatform_stable",
stubs: { symbol_file: "libplatform_stable.map.txt", versions: ["28", "29", "current"] },
apex_available: ["//apex_available:platform"],
- bazel_module: { bp2build_available: false },
include_build_directory: false,
}
cc_library_shared {
name: "libapexfoo_stable",
stubs: { symbol_file: "libapexfoo_stable.map.txt", versions: ["28", "29", "current"] },
apex_available: ["apexfoo"],
- bazel_module: { bp2build_available: false },
include_build_directory: false,
}
cc_library_shared {
@@ -684,11 +679,11 @@
Description: "cc_library_shared stubs",
ModuleTypeUnderTest: "cc_library_shared",
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
+ StubbedBuildDefinitions: []string{"a"},
Blueprint: soongCcLibrarySharedPreamble + `
cc_library_shared {
name: "a",
stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
- bazel_module: { bp2build_available: false },
include_build_directory: false,
apex_available: ["//apex_available:platform", "apex_a"],
}
@@ -720,11 +715,11 @@
Description: "cc_library depeends on impl for all configurations",
ModuleTypeUnderTest: "cc_library_shared",
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
+ StubbedBuildDefinitions: []string{"a"},
Blueprint: soongCcLibrarySharedPreamble + `
cc_library_shared {
name: "a",
stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
- bazel_module: { bp2build_available: false },
apex_available: ["//apex_available:platform"],
}
cc_library_shared {
@@ -747,11 +742,11 @@
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
ModuleTypeUnderTest: "cc_library_shared",
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
+ StubbedBuildDefinitions: []string{"a"},
Blueprint: soongCcLibrarySharedPreamble + `
cc_library_shared {
name: "a",
stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
- bazel_module: { bp2build_available: false },
include_build_directory: false,
apex_available: ["//apex_available:platform", "apex_a", "apex_b"],
}
@@ -929,14 +924,14 @@
cc_library_shared {
name: "foo",
- runtime_libs: ["foo"],
+ runtime_libs: ["bar"],
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_shared", "bar", AttrNameToString{
"local_includes": `["."]`,
}),
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
- "runtime_deps": `[":foo"]`,
+ "runtime_deps": `[":bar"]`,
"local_includes": `["."]`,
}),
},
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index b9508e9..0587aae 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -96,41 +96,37 @@
"implicit_include_1.h": "",
"implicit_include_2.h": "",
},
+ StubbedBuildDefinitions: []string{"header_lib_1", "header_lib_2",
+ "static_lib_1", "static_lib_2", "whole_static_lib_1", "whole_static_lib_2"},
Blueprint: soongCcLibraryStaticPreamble + `
cc_library_headers {
name: "header_lib_1",
export_include_dirs: ["header_lib_1"],
- bazel_module: { bp2build_available: false },
}
cc_library_headers {
name: "header_lib_2",
export_include_dirs: ["header_lib_2"],
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "static_lib_1",
srcs: ["static_lib_1.cc"],
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "static_lib_2",
srcs: ["static_lib_2.cc"],
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "whole_static_lib_1",
srcs: ["whole_static_lib_1.cc"],
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "whole_static_lib_2",
srcs: ["whole_static_lib_2.cc"],
- bazel_module: { bp2build_available: false },
}
cc_library_static {
@@ -392,16 +388,15 @@
func TestCcLibraryStaticArchSpecificStaticLib(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
- Description: "cc_library_static arch-specific static_libs",
- Filesystem: map[string]string{},
+ Description: "cc_library_static arch-specific static_libs",
+ Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"static_dep", "static_dep2"},
Blueprint: soongCcLibraryStaticPreamble + `
cc_library_static {
name: "static_dep",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "static_dep2",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "foo_static",
@@ -425,16 +420,15 @@
func TestCcLibraryStaticOsSpecificStaticLib(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
- Description: "cc_library_static os-specific static_libs",
- Filesystem: map[string]string{},
+ Description: "cc_library_static os-specific static_libs",
+ Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"static_dep", "static_dep2"},
Blueprint: soongCcLibraryStaticPreamble + `
cc_library_static {
name: "static_dep",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "static_dep2",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "foo_static",
@@ -460,22 +454,20 @@
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
Description: "cc_library_static base, arch and os-specific static_libs",
Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"static_dep", "static_dep2", "static_dep3",
+ "static_dep4"},
Blueprint: soongCcLibraryStaticPreamble + `
cc_library_static {
name: "static_dep",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "static_dep2",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "static_dep3",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "static_dep4",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "foo_static",
@@ -756,12 +748,12 @@
func TestCcLibraryStaticMultipleDepSameName(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
- Description: "cc_library_static multiple dep same name panic",
- Filesystem: map[string]string{},
+ Description: "cc_library_static multiple dep same name panic",
+ Filesystem: map[string]string{},
+ StubbedBuildDefinitions: []string{"static_dep"},
Blueprint: soongCcLibraryStaticPreamble + `
cc_library_static {
name: "static_dep",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
name: "foo_static",
@@ -961,17 +953,16 @@
func TestCcLibraryStaticGeneratedHeadersAllPartitions(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ StubbedBuildDefinitions: []string{"generated_hdr", "export_generated_hdr"},
Blueprint: soongCcLibraryStaticPreamble + `
genrule {
name: "generated_hdr",
cmd: "nothing to see here",
- bazel_module: { bp2build_available: false },
}
genrule {
name: "export_generated_hdr",
cmd: "nothing to see here",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
@@ -1005,19 +996,18 @@
func TestCcLibraryStaticGeneratedHeadersMultipleExports(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ StubbedBuildDefinitions: []string{"generated_hdr", "export_generated_hdr"},
Blueprint: soongCcLibraryStaticPreamble + `
genrule {
name: "generated_hdr",
cmd: "nothing to see here",
export_include_dirs: ["foo", "bar"],
- bazel_module: { bp2build_available: false },
}
genrule {
name: "export_generated_hdr",
cmd: "nothing to see here",
export_include_dirs: ["a", "b"],
- bazel_module: { bp2build_available: false },
}
cc_library_static {
@@ -1040,22 +1030,26 @@
func TestCcLibraryStaticArchSrcsExcludeSrcsGeneratedFiles(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
Description: "cc_library_static arch srcs/exclude_srcs with generated files",
+ StubbedBuildDefinitions: []string{"//dep:generated_src_other_pkg", "//dep:generated_hdr_other_pkg",
+ "//dep:generated_src_other_pkg_x86", "//dep:generated_hdr_other_pkg_x86", "//dep:generated_hdr_other_pkg_android",
+ "generated_src", "generated_src_not_x86", "generated_src_android", "generated_hdr",
+ },
Filesystem: map[string]string{
"common.cpp": "",
"for-x86.cpp": "",
"not-for-x86.cpp": "",
"not-for-everything.cpp": "",
- "dep/Android.bp": SimpleModuleDoNotConvertBp2build("genrule", "generated_src_other_pkg") +
- SimpleModuleDoNotConvertBp2build("genrule", "generated_hdr_other_pkg") +
- SimpleModuleDoNotConvertBp2build("genrule", "generated_src_other_pkg_x86") +
- SimpleModuleDoNotConvertBp2build("genrule", "generated_hdr_other_pkg_x86") +
- SimpleModuleDoNotConvertBp2build("genrule", "generated_hdr_other_pkg_android"),
+ "dep/Android.bp": simpleModule("genrule", "generated_src_other_pkg") +
+ simpleModule("genrule", "generated_hdr_other_pkg") +
+ simpleModule("genrule", "generated_src_other_pkg_x86") +
+ simpleModule("genrule", "generated_hdr_other_pkg_x86") +
+ simpleModule("genrule", "generated_hdr_other_pkg_android"),
},
Blueprint: soongCcLibraryStaticPreamble +
- SimpleModuleDoNotConvertBp2build("genrule", "generated_src") +
- SimpleModuleDoNotConvertBp2build("genrule", "generated_src_not_x86") +
- SimpleModuleDoNotConvertBp2build("genrule", "generated_src_android") +
- SimpleModuleDoNotConvertBp2build("genrule", "generated_hdr") + `
+ simpleModule("genrule", "generated_src") +
+ simpleModule("genrule", "generated_src_not_x86") +
+ simpleModule("genrule", "generated_src_android") +
+ simpleModule("genrule", "generated_hdr") + `
cc_library_static {
name: "foo_static",
srcs: ["common.cpp", "not-for-*.cpp"],
@@ -1340,11 +1334,11 @@
func TestStaticLibrary_SystemSharedLibsBionicEmpty(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
- Description: "cc_library_static system_shared_lib empty for bionic variant",
+ Description: "cc_library_static system_shared_lib empty for bionic variant",
+ StubbedBuildDefinitions: []string{"libc_musl"},
Blueprint: soongCcLibraryStaticPreamble + `
cc_library {
name: "libc_musl",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
@@ -1374,11 +1368,11 @@
// only for linux_bionic, but `android` had `["libc", "libdl", "libm"].
// b/195791252 tracks the fix.
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
- Description: "cc_library_static system_shared_lib empty for linux_bionic variant",
+ Description: "cc_library_static system_shared_lib empty for linux_bionic variant",
+ StubbedBuildDefinitions: []string{"libc_musl"},
Blueprint: soongCcLibraryStaticPreamble + `
cc_library {
name: "libc_musl",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
@@ -1458,12 +1452,12 @@
func TestStaticLibrary_SystemSharedLibsBionic(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
- Description: "cc_library_static system_shared_libs set for bionic variant",
+ Description: "cc_library_static system_shared_libs set for bionic variant",
+ StubbedBuildDefinitions: []string{"libc", "libc_musl"},
Blueprint: soongCcLibraryStaticPreamble +
- SimpleModuleDoNotConvertBp2build("cc_library", "libc") + `
+ simpleModule("cc_library", "libc") + `
cc_library {
name: "libc_musl",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
@@ -1491,13 +1485,13 @@
func TestStaticLibrary_SystemSharedLibsLinuxRootAndLinuxBionic(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
- Description: "cc_library_static system_shared_libs set for root and linux_bionic variant",
+ Description: "cc_library_static system_shared_libs set for root and linux_bionic variant",
+ StubbedBuildDefinitions: []string{"libc", "libm", "libc_musl"},
Blueprint: soongCcLibraryStaticPreamble +
- SimpleModuleDoNotConvertBp2build("cc_library", "libc") +
- SimpleModuleDoNotConvertBp2build("cc_library", "libm") + `
+ simpleModule("cc_library", "libc") +
+ simpleModule("cc_library", "libm") + `
cc_library {
name: "libc_musl",
- bazel_module: { bp2build_available: false },
}
cc_library_static {
@@ -1525,9 +1519,10 @@
func TestCcLibrarystatic_SystemSharedLibUsedAsDep(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
- Description: "cc_library_static system_shared_lib empty for linux_bionic variant",
+ Description: "cc_library_static system_shared_lib empty for linux_bionic variant",
+ StubbedBuildDefinitions: []string{"libc", "libm"},
Blueprint: soongCcLibraryStaticPreamble +
- SimpleModuleDoNotConvertBp2build("cc_library", "libc") + `
+ simpleModule("cc_library", "libc") + `
cc_library {
name: "libm",
@@ -1535,7 +1530,6 @@
symbol_file: "libm.map.txt",
versions: ["current"],
},
- bazel_module: { bp2build_available: false },
apex_available: ["com.android.runtime"],
}
@@ -1613,6 +1607,7 @@
func TestCcLibraryStaticProto(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ StubbedBuildDefinitions: []string{"libprotobuf-cpp-full", "libprotobuf-cpp-lite"},
Blueprint: soongCcProtoPreamble + `cc_library_static {
name: "foo",
srcs: ["foo.proto"],
@@ -1639,6 +1634,7 @@
Filesystem: map[string]string{
soongCcVersionLibBpPath: soongCcVersionLibBp,
},
+ StubbedBuildDefinitions: []string{"//build/soong/cc/libbuildversion:libbuildversion", "libprotobuf-cpp-full", "libprotobuf-cpp-lite"},
Blueprint: soongCcProtoPreamble + `cc_library_static {
name: "foo",
use_version_lib: true,
@@ -1658,6 +1654,8 @@
Filesystem: map[string]string{
soongCcVersionLibBpPath: soongCcVersionLibBp,
},
+ StubbedBuildDefinitions: []string{"//build/soong/cc/libbuildversion:libbuildversion", "libprotobuf-cpp-full", "libprotobuf-cpp-lite"},
+
Blueprint: soongCcProtoPreamble + `cc_library_static {
name: "foo",
use_version_lib: true,
@@ -1674,6 +1672,7 @@
func TestCcLibraryStaticStdInFlags(t *testing.T) {
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
+ StubbedBuildDefinitions: []string{"libprotobuf-cpp-full", "libprotobuf-cpp-lite"},
Blueprint: soongCcProtoPreamble + `cc_library_static {
name: "foo",
cflags: ["-std=candcpp"],
@@ -1767,14 +1766,14 @@
cc_library_static {
name: "foo",
- runtime_libs: ["foo"],
+ runtime_libs: ["bar"],
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_shared", "bar", AttrNameToString{
"local_includes": `["."]`,
}),
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
- "runtime_deps": `[":foo"]`,
+ "runtime_deps": `[":bar"]`,
"local_includes": `["."]`,
}),
},
@@ -2260,6 +2259,7 @@
Description: "cc_library with a .proto file generated from a genrule",
ModuleTypeUnderTest: "cc_library_static",
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
+ StubbedBuildDefinitions: []string{"libprotobuf-cpp-lite"},
Blueprint: soongCcLibraryPreamble + `
cc_library_static {
name: "mylib",
@@ -2269,7 +2269,7 @@
name: "myprotogen",
out: ["myproto.proto"],
}
-` + SimpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite"),
+` + simpleModule("cc_library", "libprotobuf-cpp-lite"),
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "mylib", AttrNameToString{
"local_includes": `["."]`,
diff --git a/bp2build/cc_object_conversion_test.go b/bp2build/cc_object_conversion_test.go
index ecfcb5a..e1e2f43 100644
--- a/bp2build/cc_object_conversion_test.go
+++ b/bp2build/cc_object_conversion_test.go
@@ -317,7 +317,8 @@
func TestCcObjectDepsAndLinkerScriptSelects(t *testing.T) {
runCcObjectTestCase(t, Bp2buildTestCase{
- Description: "cc_object setting deps and linker_script across archs",
+ Description: "cc_object setting deps and linker_script across archs",
+ StubbedBuildDefinitions: []string{"x86_obj", "x86_64_obj", "arm_obj"},
Blueprint: `cc_object {
name: "foo",
srcs: ["base.cpp"],
@@ -343,7 +344,6 @@
system_shared_libs: [],
srcs: ["x86.cpp"],
include_build_directory: false,
- bazel_module: { bp2build_available: false },
}
cc_object {
@@ -351,7 +351,6 @@
system_shared_libs: [],
srcs: ["x86_64.cpp"],
include_build_directory: false,
- bazel_module: { bp2build_available: false },
}
cc_object {
@@ -359,7 +358,6 @@
system_shared_libs: [],
srcs: ["arm.cpp"],
include_build_directory: false,
- bazel_module: { bp2build_available: false },
}
`,
ExpectedBazelTargets: []string{
diff --git a/bp2build/cc_test_conversion_test.go b/bp2build/cc_test_conversion_test.go
index 74a5c0d..679a364 100644
--- a/bp2build/cc_test_conversion_test.go
+++ b/bp2build/cc_test_conversion_test.go
@@ -24,10 +24,11 @@
)
type ccTestBp2buildTestCase struct {
- description string
- blueprint string
- filesystem map[string]string
- targets []testBazelTarget
+ description string
+ blueprint string
+ filesystem map[string]string
+ targets []testBazelTarget
+ stubbedBuildDefinitions []string
}
func registerCcTestModuleTypes(ctx android.RegistrationContext) {
@@ -52,6 +53,7 @@
ModuleTypeUnderTestFactory: cc.TestFactory,
Description: description,
Blueprint: testCase.blueprint,
+ StubbedBuildDefinitions: testCase.stubbedBuildDefinitions,
})
})
}
@@ -59,6 +61,8 @@
func TestBasicCcTest(t *testing.T) {
runCcTestTestCase(t, ccTestBp2buildTestCase{
description: "basic cc_test with commonly used attributes",
+ stubbedBuildDefinitions: []string{"libbuildversion", "libprotobuf-cpp-lite", "libprotobuf-cpp-full",
+ "foolib", "hostlib", "data_mod", "cc_bin", "cc_lib", "cc_test_lib2", "libgtest_main", "libgtest"},
blueprint: `
cc_test {
name: "mytest",
@@ -89,14 +93,14 @@
host_supported: true,
include_build_directory: false,
}
-` + SimpleModuleDoNotConvertBp2build("cc_library", "foolib") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "hostlib") +
- SimpleModuleDoNotConvertBp2build("genrule", "data_mod") +
- SimpleModuleDoNotConvertBp2build("cc_binary", "cc_bin") +
- SimpleModuleDoNotConvertBp2build("cc_library", "cc_lib") +
- SimpleModuleDoNotConvertBp2build("cc_test_library", "cc_test_lib2") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_main") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest"),
+` + simpleModule("cc_library", "foolib") +
+ simpleModule("cc_library_static", "hostlib") +
+ simpleModule("genrule", "data_mod") +
+ simpleModule("cc_binary", "cc_bin") +
+ simpleModule("cc_library", "cc_lib") +
+ simpleModule("cc_test_library", "cc_test_lib2") +
+ simpleModule("cc_library_static", "libgtest_main") +
+ simpleModule("cc_library_static", "libgtest"),
targets: []testBazelTarget{
{"cc_library_shared", "cc_test_lib1", AttrNameToString{}},
{"cc_library_static", "cc_test_lib1_bp2build_cc_library_static", AttrNameToString{}},
@@ -188,7 +192,8 @@
func TestCcTest_TestOptions_Tags(t *testing.T) {
runCcTestTestCase(t, ccTestBp2buildTestCase{
- description: "cc test with test_options.tags converted to tags",
+ description: "cc test with test_options.tags converted to tags",
+ stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"},
blueprint: `
cc_test {
name: "mytest",
@@ -196,8 +201,8 @@
srcs: ["test.cpp"],
test_options: { tags: ["no-remote"] },
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_main") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest"),
+` + simpleModule("cc_library_static", "libgtest_main") +
+ simpleModule("cc_library_static", "libgtest"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"tags": `["no-remote"]`,
@@ -230,14 +235,15 @@
filesystem: map[string]string{
"test_config.xml": "",
},
+ stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"},
blueprint: `
cc_test {
name: "mytest",
srcs: ["test.cpp"],
test_config: "test_config.xml",
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_main") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest"),
+` + simpleModule("cc_library_static", "libgtest_main") +
+ simpleModule("cc_library_static", "libgtest"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"local_includes": `["."]`,
@@ -269,13 +275,14 @@
"AndroidTest.xml": "",
"DynamicConfig.xml": "",
},
+ stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"},
blueprint: `
cc_test {
name: "mytest",
srcs: ["test.cpp"],
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_main") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest"),
+` + simpleModule("cc_library_static", "libgtest_main") +
+ simpleModule("cc_library_static", "libgtest"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"local_includes": `["."]`,
@@ -307,6 +314,7 @@
filesystem: map[string]string{
"test_config_template.xml": "",
},
+ stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"},
blueprint: `
cc_test {
name: "mytest",
@@ -315,8 +323,8 @@
auto_gen_config: true,
isolated: true,
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_isolated_main") +
- SimpleModuleDoNotConvertBp2build("cc_library", "liblog"),
+` + simpleModule("cc_library_static", "libgtest_isolated_main") +
+ simpleModule("cc_library", "liblog"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"auto_generate_test_config": "True",
@@ -347,15 +355,16 @@
func TestCcTest_WithExplicitGTestDepInAndroidBp(t *testing.T) {
runCcTestTestCase(t, ccTestBp2buildTestCase{
- description: "cc test that lists libgtest in Android.bp should not have dups of libgtest in BUILD file",
+ description: "cc test that lists libgtest in Android.bp should not have dups of libgtest in BUILD file",
+ stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"},
blueprint: `
cc_test {
name: "mytest",
srcs: ["test.cpp"],
static_libs: ["libgtest"],
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_main") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest"),
+` + simpleModule("cc_library_static", "libgtest_main") +
+ simpleModule("cc_library_static", "libgtest"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"local_includes": `["."]`,
@@ -382,15 +391,16 @@
func TestCcTest_WithIsolatedTurnedOn(t *testing.T) {
runCcTestTestCase(t, ccTestBp2buildTestCase{
- description: "cc test that sets `isolated: true` should run with ligtest_isolated_main instead of libgtest_main",
+ description: "cc test that sets `isolated: true` should run with ligtest_isolated_main instead of libgtest_main",
+ stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"},
blueprint: `
cc_test {
name: "mytest",
srcs: ["test.cpp"],
isolated: true,
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_isolated_main") +
- SimpleModuleDoNotConvertBp2build("cc_library", "liblog"),
+` + simpleModule("cc_library_static", "libgtest_isolated_main") +
+ simpleModule("cc_library", "liblog"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"local_includes": `["."]`,
@@ -415,7 +425,8 @@
func TestCcTest_GtestExplicitlySpecifiedInAndroidBp(t *testing.T) {
runCcTestTestCase(t, ccTestBp2buildTestCase{
- description: "If `gtest` is explicit in Android.bp, it should be explicit in BUILD files as well",
+ description: "If `gtest` is explicit in Android.bp, it should be explicit in BUILD files as well",
+ stubbedBuildDefinitions: []string{"libgtest_main", "libgtest"},
blueprint: `
cc_test {
name: "mytest_with_gtest",
@@ -425,8 +436,8 @@
name: "mytest_with_no_gtest",
gtest: false,
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_main") +
- SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest"),
+` + simpleModule("cc_library_static", "libgtest_main") +
+ simpleModule("cc_library_static", "libgtest"),
targets: []testBazelTarget{
{"cc_test", "mytest_with_gtest", AttrNameToString{
"local_includes": `["."]`,
@@ -466,7 +477,8 @@
func TestCcTest_DisableMemtagHeap(t *testing.T) {
runCcTestTestCase(t, ccTestBp2buildTestCase{
- description: "cc test that disable memtag_heap",
+ description: "cc test that disable memtag_heap",
+ stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"},
blueprint: `
cc_test {
name: "mytest",
@@ -477,8 +489,8 @@
memtag_heap: false,
},
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_isolated_main") +
- SimpleModuleDoNotConvertBp2build("cc_library", "liblog"),
+` + simpleModule("cc_library_static", "libgtest_isolated_main") +
+ simpleModule("cc_library", "liblog"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"local_includes": `["."]`,
@@ -499,7 +511,8 @@
func TestCcTest_RespectArm64MemtagHeap(t *testing.T) {
runCcTestTestCase(t, ccTestBp2buildTestCase{
- description: "cc test that disable memtag_heap",
+ description: "cc test that disable memtag_heap",
+ stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"},
blueprint: `
cc_test {
name: "mytest",
@@ -513,8 +526,8 @@
}
},
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_isolated_main") +
- SimpleModuleDoNotConvertBp2build("cc_library", "liblog"),
+` + simpleModule("cc_library_static", "libgtest_isolated_main") +
+ simpleModule("cc_library", "liblog"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"local_includes": `["."]`,
@@ -535,7 +548,8 @@
func TestCcTest_IgnoreNoneArm64MemtagHeap(t *testing.T) {
runCcTestTestCase(t, ccTestBp2buildTestCase{
- description: "cc test that disable memtag_heap",
+ description: "cc test that disable memtag_heap",
+ stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"},
blueprint: `
cc_test {
name: "mytest",
@@ -549,8 +563,8 @@
}
},
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_isolated_main") +
- SimpleModuleDoNotConvertBp2build("cc_library", "liblog"),
+` + simpleModule("cc_library_static", "libgtest_isolated_main") +
+ simpleModule("cc_library", "liblog"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"local_includes": `["."]`,
@@ -574,7 +588,8 @@
func TestCcTest_Arm64MemtagHeapOverrideNoConfigOne(t *testing.T) {
runCcTestTestCase(t, ccTestBp2buildTestCase{
- description: "cc test that disable memtag_heap",
+ description: "cc test that disable memtag_heap",
+ stubbedBuildDefinitions: []string{"libgtest_isolated_main", "liblog"},
blueprint: `
cc_test {
name: "mytest",
@@ -594,8 +609,8 @@
}
},
}
-` + SimpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_isolated_main") +
- SimpleModuleDoNotConvertBp2build("cc_library", "liblog"),
+` + simpleModule("cc_library_static", "libgtest_isolated_main") +
+ simpleModule("cc_library", "liblog"),
targets: []testBazelTarget{
{"cc_test", "mytest", AttrNameToString{
"local_includes": `["."]`,
diff --git a/bp2build/genrule_conversion_test.go b/bp2build/genrule_conversion_test.go
index 2a10a14..7e9b17b 100644
--- a/bp2build/genrule_conversion_test.go
+++ b/bp2build/genrule_conversion_test.go
@@ -93,7 +93,6 @@
out: ["foo_tool.out"],
srcs: ["foo_tool.in"],
cmd: "cp $(in) $(out)",
- bazel_module: { bp2build_available: false },
}
%s {
@@ -124,6 +123,7 @@
ModuleTypeUnderTestFactory: tc.factory,
Blueprint: fmt.Sprintf(bp, tc.moduleType, tc.moduleType),
ExpectedBazelTargets: expectedBazelTargets,
+ StubbedBuildDefinitions: []string{"foo.tool", "other.tool"},
})
})
}
@@ -262,6 +262,7 @@
Blueprint: fmt.Sprintf(bp, tc.moduleType),
ExpectedBazelTargets: expectedBazelTargets,
Filesystem: otherGenruleBp(tc.moduleType),
+ StubbedBuildDefinitions: []string{"//other:foo.tool"},
})
})
}
@@ -326,6 +327,7 @@
Blueprint: fmt.Sprintf(bp, tc.moduleType),
ExpectedBazelTargets: expectedBazelTargets,
Filesystem: otherGenruleBp(tc.moduleType),
+ StubbedBuildDefinitions: []string{"//other:foo.tool", "//other:other.tool"},
})
})
}
@@ -390,6 +392,7 @@
Blueprint: fmt.Sprintf(bp, tc.moduleType),
ExpectedBazelTargets: expectedBazelTargets,
Filesystem: otherGenruleBp(tc.moduleType),
+ StubbedBuildDefinitions: []string{"//other:foo.tool", "//other:other.tool"},
})
})
}
@@ -454,6 +457,7 @@
Blueprint: fmt.Sprintf(bp, tc.moduleType),
ExpectedBazelTargets: expectedBazelTargets,
Filesystem: otherGenruleBp(tc.moduleType),
+ StubbedBuildDefinitions: []string{"//other:foo.tool", "//other:other.tool"},
})
})
}
@@ -948,6 +952,7 @@
ModuleTypeUnderTest: "genrule",
ModuleTypeUnderTestFactory: genrule.GenRuleFactory,
ExpectedBazelTargets: expectedBazelTargets,
+ StubbedBuildDefinitions: []string{"//mynamespace/dir:mymodule"},
})
})
diff --git a/bp2build/java_binary_host_conversion_test.go b/bp2build/java_binary_host_conversion_test.go
index 39e55c4..7d8ab63 100644
--- a/bp2build/java_binary_host_conversion_test.go
+++ b/bp2build/java_binary_host_conversion_test.go
@@ -26,6 +26,7 @@
t.Helper()
(&tc).ModuleTypeUnderTest = "java_binary_host"
(&tc).ModuleTypeUnderTestFactory = java.BinaryHostFactory
+ tc.StubbedBuildDefinitions = append(tc.StubbedBuildDefinitions, "//other:jni-lib-1")
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
ctx.RegisterModuleType("cc_library_host_shared", cc.LibraryHostSharedFactory)
ctx.RegisterModuleType("java_library", java.LibraryFactory)
@@ -81,8 +82,9 @@
func TestJavaBinaryHostRuntimeDeps(t *testing.T) {
runJavaBinaryHostTestCase(t, Bp2buildTestCase{
- Description: "java_binary_host with srcs, exclude_srcs, jni_libs, javacflags, and manifest.",
- Filesystem: testFs,
+ Description: "java_binary_host with srcs, exclude_srcs, jni_libs, javacflags, and manifest.",
+ Filesystem: testFs,
+ StubbedBuildDefinitions: []string{"java-dep-1"},
Blueprint: `java_binary_host {
name: "java-binary-host-1",
static_libs: ["java-dep-1"],
@@ -93,7 +95,6 @@
java_library {
name: "java-dep-1",
srcs: ["a.java"],
- bazel_module: { bp2build_available: false },
}
`,
ExpectedBazelTargets: []string{
@@ -111,8 +112,9 @@
func TestJavaBinaryHostLibs(t *testing.T) {
runJavaBinaryHostTestCase(t, Bp2buildTestCase{
- Description: "java_binary_host with srcs, libs.",
- Filesystem: testFs,
+ Description: "java_binary_host with srcs, libs.",
+ Filesystem: testFs,
+ StubbedBuildDefinitions: []string{"prebuilt_java-lib-dep-1"},
Blueprint: `java_binary_host {
name: "java-binary-host-libs",
libs: ["java-lib-dep-1"],
@@ -123,7 +125,6 @@
java_import_host{
name: "java-lib-dep-1",
jars: ["foo.jar"],
- bazel_module: { bp2build_available: false },
}
`,
ExpectedBazelTargets: []string{
diff --git a/bp2build/java_library_conversion_test.go b/bp2build/java_library_conversion_test.go
index 3260b1e..7e4e44e 100644
--- a/bp2build/java_library_conversion_test.go
+++ b/bp2build/java_library_conversion_test.go
@@ -69,6 +69,7 @@
func TestJavaLibraryConvertsStaticLibsToDepsAndExports(t *testing.T) {
runJavaLibraryTestCase(t, Bp2buildTestCase{
+ StubbedBuildDefinitions: []string{"java-lib-2", "java-lib-3"},
Blueprint: `java_library {
name: "java-lib-1",
srcs: ["a.java"],
@@ -82,14 +83,12 @@
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{
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
@@ -108,6 +107,7 @@
func TestJavaLibraryConvertsStaticLibsToExportsIfNoSrcs(t *testing.T) {
runJavaLibraryTestCase(t, Bp2buildTestCase{
+ StubbedBuildDefinitions: []string{"java-lib-2"},
Blueprint: `java_library {
name: "java-lib-1",
static_libs: ["java-lib-2"],
@@ -118,7 +118,6 @@
java_library {
name: "java-lib-2",
srcs: ["a.java"],
- bazel_module: { bp2build_available: false },
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
@@ -144,6 +143,7 @@
func TestJavaLibraryPlugins(t *testing.T) {
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
+ StubbedBuildDefinitions: []string{"java-plugin-1"},
Blueprint: `java_library {
name: "java-lib-1",
plugins: ["java-plugin-1"],
@@ -154,7 +154,6 @@
java_plugin {
name: "java-plugin-1",
srcs: ["a.java"],
- bazel_module: { bp2build_available: false },
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
@@ -195,6 +194,7 @@
func TestJavaLibraryErrorproneEnabledManually(t *testing.T) {
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
+ StubbedBuildDefinitions: []string{"plugin2"},
Blueprint: `java_library {
name: "java-lib-1",
srcs: ["a.java"],
@@ -209,7 +209,6 @@
java_plugin {
name: "plugin2",
srcs: ["a.java"],
- bazel_module: { bp2build_available: false },
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
@@ -420,13 +419,12 @@
func TestJavaLibraryResourcesWithMultipleDirs(t *testing.T) {
runJavaLibraryTestCase(t, Bp2buildTestCase{
Filesystem: map[string]string{
- "res/a.res": "",
- "res1/b.res": "",
- "res2/b.java": "",
+ "res/a.res": "",
+ "res1/b.res": "",
},
Blueprint: `java_library {
name: "java-lib-1",
- java_resource_dirs: ["res", "res1", "res2"],
+ java_resource_dirs: ["res", "res1"],
sdk_version: "current",
}`,
ExpectedBazelTargets: []string{
@@ -619,6 +617,7 @@
Description: "java_library with non adjacent aidl filegroup",
ModuleTypeUnderTest: "java_library",
ModuleTypeUnderTestFactory: java.LibraryFactory,
+ StubbedBuildDefinitions: []string{"A_aidl"},
Filesystem: map[string]string{
"path/to/A/Android.bp": `
filegroup {
@@ -656,7 +655,7 @@
Description: "Android Library - simple arch feature",
ModuleTypeUnderTest: "android_library",
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
- Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
+ Blueprint: simpleModule("android_library", "static_lib_dep") + `
android_library {
name: "TestLib",
manifest: "manifest/AndroidManifest.xml",
@@ -694,7 +693,7 @@
Description: "Android Library - multiple arch features",
ModuleTypeUnderTest: "android_library",
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
- Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
+ Blueprint: simpleModule("android_library", "static_lib_dep") + `
android_library {
name: "TestLib",
manifest: "manifest/AndroidManifest.xml",
@@ -740,7 +739,7 @@
Description: "Android Library - exclude_srcs with arch feature",
ModuleTypeUnderTest: "android_library",
ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
- Blueprint: SimpleModuleDoNotConvertBp2build("android_library", "static_lib_dep") + `
+ Blueprint: simpleModule("android_library", "static_lib_dep") + `
android_library {
name: "TestLib",
manifest: "manifest/AndroidManifest.xml",
@@ -848,33 +847,10 @@
})
}
-func TestJavaLibraryLibsWithNoSrcs(t *testing.T) {
- runJavaLibraryTestCase(t, Bp2buildTestCase{
- Description: "java_library that has libs but no srcs",
- 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",
- bazel_module: { bp2build_available: false },
-}
-`,
- ExpectedBazelTargets: []string{
- MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
- "sdk_version": `"current"`,
- }),
- MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
- },
- })
-}
-
func TestJavaLibraryArchVariantDeps(t *testing.T) {
runJavaLibraryTestCase(t, Bp2buildTestCase{
- Description: "java_library with arch variant libs",
+ Description: "java_library with arch variant libs",
+ StubbedBuildDefinitions: []string{"java-lib-2", "java-lib-3", "java-lib-4"},
Blueprint: `java_library {
name: "java-lib-1",
srcs: ["a.java"],
@@ -891,17 +867,14 @@
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{
@@ -1050,14 +1023,3 @@
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
})
}
-
-func TestJavaSdkVersionCorePlatformDoesNotConvert(t *testing.T) {
- runJavaLibraryTestCase(t, Bp2buildTestCase{
- Blueprint: `java_library {
- name: "java-lib-1",
- sdk_version: "core_platform",
- bazel_module: { bp2build_available: true },
-}`,
- ExpectedBazelTargets: []string{},
- })
-}
diff --git a/bp2build/java_plugin_conversion_test.go b/bp2build/java_plugin_conversion_test.go
index f2b6f20..b284112 100644
--- a/bp2build/java_plugin_conversion_test.go
+++ b/bp2build/java_plugin_conversion_test.go
@@ -32,7 +32,8 @@
func TestJavaPlugin(t *testing.T) {
runJavaPluginTestCase(t, Bp2buildTestCase{
- Description: "java_plugin with srcs, libs, static_libs",
+ Description: "java_plugin with srcs, libs, static_libs",
+ StubbedBuildDefinitions: []string{"java-lib-1", "java-lib-2"},
Blueprint: `java_plugin {
name: "java-plug-1",
srcs: ["a.java", "b.java"],
@@ -45,13 +46,11 @@
java_library {
name: "java-lib-1",
srcs: ["b.java"],
- bazel_module: { bp2build_available: false },
}
java_library {
name: "java-lib-2",
srcs: ["c.java"],
- bazel_module: { bp2build_available: false },
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("java_plugin", "java-plug-1", AttrNameToString{
@@ -75,7 +74,8 @@
func TestJavaPluginNoSrcs(t *testing.T) {
runJavaPluginTestCase(t, Bp2buildTestCase{
- Description: "java_plugin without srcs converts (static) libs to deps",
+ Description: "java_plugin without srcs converts (static) libs to deps",
+ StubbedBuildDefinitions: []string{"java-lib-1", "java-lib-2"},
Blueprint: `java_plugin {
name: "java-plug-1",
libs: ["java-lib-1"],
diff --git a/bp2build/platform_compat_config_conversion_test.go b/bp2build/platform_compat_config_conversion_test.go
index 4dfcce3..d74db5d 100644
--- a/bp2build/platform_compat_config_conversion_test.go
+++ b/bp2build/platform_compat_config_conversion_test.go
@@ -37,6 +37,7 @@
name: "foo",
src: ":lib",
}`,
+ StubbedBuildDefinitions: []string{"//a/b:lib"},
Filesystem: map[string]string{
"a/b/Android.bp": `
java_library {
diff --git a/bp2build/python_binary_conversion_test.go b/bp2build/python_binary_conversion_test.go
index 4ccdba7..b69c4ea 100644
--- a/bp2build/python_binary_conversion_test.go
+++ b/bp2build/python_binary_conversion_test.go
@@ -30,6 +30,7 @@
"b/e.py": "",
"files/data.txt": "",
},
+ StubbedBuildDefinitions: []string{"bar"},
Blueprint: `python_binary_host {
name: "foo",
main: "a.py",
@@ -42,7 +43,6 @@
python_library_host {
name: "bar",
srcs: ["b/e.py"],
- bazel_module: { bp2build_available: false },
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("py_binary", "foo", AttrNameToString{
@@ -196,6 +196,7 @@
Description: "python_binary_host main label in same package",
ModuleTypeUnderTest: "python_binary_host",
ModuleTypeUnderTestFactory: python.PythonBinaryHostFactory,
+ StubbedBuildDefinitions: []string{"a"},
Blueprint: `python_binary_host {
name: "foo",
main: ":a",
@@ -204,7 +205,6 @@
genrule {
name: "a",
- bazel_module: { bp2build_available: false },
}
`,
ExpectedBazelTargets: []string{
@@ -282,6 +282,7 @@
Description: "python_binary_host duplicates in required attribute of the module and its defaults",
ModuleTypeUnderTest: "python_binary_host",
ModuleTypeUnderTestFactory: python.PythonBinaryHostFactory,
+ StubbedBuildDefinitions: []string{"r1", "r2"},
Blueprint: `python_binary_host {
name: "foo",
main: "a.py",
@@ -298,8 +299,8 @@
"r1",
"r2",
],
-}` + SimpleModuleDoNotConvertBp2build("genrule", "r1") +
- SimpleModuleDoNotConvertBp2build("genrule", "r2"),
+}` + simpleModule("genrule", "r1") +
+ simpleModule("genrule", "r2"),
ExpectedBazelTargets: []string{
MakeBazelTarget("py_binary", "foo", AttrNameToString{
diff --git a/bp2build/python_library_conversion_test.go b/bp2build/python_library_conversion_test.go
index 595acd2..497df80 100644
--- a/bp2build/python_library_conversion_test.go
+++ b/bp2build/python_library_conversion_test.go
@@ -13,12 +13,13 @@
type PythonLibBp2Build func(ctx android.TopDownMutatorContext)
type pythonLibBp2BuildTestCase struct {
- description string
- filesystem map[string]string
- blueprint string
- expectedBazelTargets []testBazelTarget
- dir string
- expectedError error
+ description string
+ filesystem map[string]string
+ blueprint string
+ expectedBazelTargets []testBazelTarget
+ dir string
+ expectedError error
+ stubbedBuildDefinitions []string
}
func convertPythonLibTestCaseToBp2build_Host(tc pythonLibBp2BuildTestCase) Bp2buildTestCase {
@@ -44,12 +45,13 @@
filesystemCopy[k] = v
}
return Bp2buildTestCase{
- Description: tc.description,
- Filesystem: filesystemCopy,
- Blueprint: tc.blueprint,
- ExpectedBazelTargets: bp2BuildTargets,
- Dir: tc.dir,
- ExpectedErr: tc.expectedError,
+ Description: tc.description,
+ Filesystem: filesystemCopy,
+ Blueprint: tc.blueprint,
+ ExpectedBazelTargets: bp2BuildTargets,
+ Dir: tc.dir,
+ ExpectedErr: tc.expectedError,
+ StubbedBuildDefinitions: tc.stubbedBuildDefinitions,
}
}
@@ -104,6 +106,7 @@
"b/e.py": "",
"files/data.txt": "",
},
+ stubbedBuildDefinitions: []string{"bar"},
blueprint: `%s {
name: "foo",
srcs: ["**/*.py"],
@@ -115,7 +118,6 @@
python_library {
name: "bar",
srcs: ["b/e.py"],
- bazel_module: { bp2build_available: false },
}`,
expectedBazelTargets: []testBazelTarget{
{
diff --git a/bp2build/python_test_conversion_test.go b/bp2build/python_test_conversion_test.go
index 4ff1fa1..fa2e485 100644
--- a/bp2build/python_test_conversion_test.go
+++ b/bp2build/python_test_conversion_test.go
@@ -15,8 +15,9 @@
package bp2build
import (
- "android/soong/python"
"testing"
+
+ "android/soong/python"
)
func TestPythonTestHostSimple(t *testing.T) {
@@ -31,6 +32,7 @@
"b/e.py": "",
"files/data.txt": "",
},
+ StubbedBuildDefinitions: []string{"bar"},
Blueprint: `python_test_host {
name: "foo",
main: "a.py",
@@ -43,7 +45,6 @@
python_library_host {
name: "bar",
srcs: ["b/e.py"],
- bazel_module: { bp2build_available: false },
}`,
ExpectedBazelTargets: []string{
MakeBazelTarget("py_test", "foo", AttrNameToString{
diff --git a/bp2build/soong_config_module_type_conversion_test.go b/bp2build/soong_config_module_type_conversion_test.go
index 8302ce8..5ec6bab 100644
--- a/bp2build/soong_config_module_type_conversion_test.go
+++ b/bp2build/soong_config_module_type_conversion_test.go
@@ -15,10 +15,11 @@
package bp2build
import (
- "android/soong/android"
- "android/soong/cc"
"fmt"
"testing"
+
+ "android/soong/android"
+ "android/soong/cc"
)
func runSoongConfigModuleTypeTest(t *testing.T, tc Bp2buildTestCase) {
@@ -364,9 +365,9 @@
}`
otherDeps := `
-cc_library_static { name: "soc_a_dep", bazel_module: { bp2build_available: false } }
-cc_library_static { name: "soc_b_dep", bazel_module: { bp2build_available: false } }
-cc_library_static { name: "soc_default_static_dep", bazel_module: { bp2build_available: false } }
+cc_library_static { name: "soc_a_dep"}
+cc_library_static { name: "soc_b_dep"}
+cc_library_static { name: "soc_default_static_dep"}
`
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
@@ -377,6 +378,7 @@
Filesystem: map[string]string{
"foo/bar/Android.bp": otherDeps,
},
+ StubbedBuildDefinitions: []string{"//foo/bar:soc_a_dep", "//foo/bar:soc_b_dep", "//foo/bar:soc_default_static_dep"},
ExpectedBazelTargets: []string{`cc_library_static(
name = "foo",
copts = select({
@@ -763,9 +765,9 @@
}`
otherDeps := `
-cc_library { name: "lib_a", bazel_module: { bp2build_available: false } }
-cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
-cc_library { name: "lib_default", bazel_module: { bp2build_available: false } }
+cc_library { name: "lib_a"}
+cc_library { name: "lib_b"}
+cc_library { name: "lib_default"}
`
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
@@ -773,6 +775,7 @@
ModuleTypeUnderTest: "cc_binary",
ModuleTypeUnderTestFactory: cc.BinaryFactory,
Blueprint: bp,
+ StubbedBuildDefinitions: []string{"//foo/bar:lib_a", "//foo/bar:lib_b", "//foo/bar:lib_default"},
Filesystem: map[string]string{
"foo/bar/Android.bp": otherDeps,
},
@@ -852,15 +855,16 @@
}`
otherDeps := `
-cc_library { name: "lib_a", bazel_module: { bp2build_available: false } }
-cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
-cc_library { name: "lib_c", bazel_module: { bp2build_available: false } }
+cc_library { name: "lib_a"}
+cc_library { name: "lib_b"}
+cc_library { name: "lib_c"}
`
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
Description: "soong config variables - generates selects for library_linking_strategy",
ModuleTypeUnderTest: "cc_binary",
ModuleTypeUnderTestFactory: cc.BinaryFactory,
+ StubbedBuildDefinitions: []string{"//foo/bar:lib_a", "//foo/bar:lib_b", "//foo/bar:lib_c"},
Blueprint: bp,
Filesystem: map[string]string{
"foo/bar/Android.bp": otherDeps,
@@ -949,9 +953,9 @@
}`
otherDeps := `
-cc_library { name: "lib_a", bazel_module: { bp2build_available: false } }
-cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
-cc_library { name: "lib_default", bazel_module: { bp2build_available: false } }
+cc_library { name: "lib_a"}
+cc_library { name: "lib_b"}
+cc_library { name: "lib_default"}
`
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
@@ -962,6 +966,7 @@
Filesystem: map[string]string{
"foo/bar/Android.bp": otherDeps,
},
+ StubbedBuildDefinitions: []string{"//foo/bar:lib_a", "//foo/bar:lib_b", "//foo/bar:lib_default"},
ExpectedBazelTargets: []string{`cc_binary(
name = "library_linking_strategy_sample_binary",
deps = select({
@@ -1031,8 +1036,8 @@
}`
otherDeps := `
-cc_library { name: "lib_a", bazel_module: { bp2build_available: false } }
-cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
+cc_library { name: "lib_a"}
+cc_library { name: "lib_b"}
`
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
@@ -1040,6 +1045,7 @@
ModuleTypeUnderTest: "cc_binary",
ModuleTypeUnderTestFactory: cc.BinaryFactory,
Blueprint: bp,
+ StubbedBuildDefinitions: []string{"//foo/bar:lib_a", "//foo/bar:lib_b"},
Filesystem: map[string]string{
"foo/bar/Android.bp": otherDeps,
},
@@ -1118,9 +1124,9 @@
}`
otherDeps := `
-cc_library { name: "lib_a", bazel_module: { bp2build_available: false } }
-cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
-cc_library { name: "lib_default", bazel_module: { bp2build_available: false } }
+cc_library { name: "lib_a"}
+cc_library { name: "lib_b"}
+cc_library { name: "lib_default"}
`
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
@@ -1131,6 +1137,7 @@
Filesystem: map[string]string{
"foo/bar/Android.bp": otherDeps,
},
+ StubbedBuildDefinitions: []string{"//foo/bar:lib_a", "//foo/bar:lib_b", "//foo/bar:lib_default"},
ExpectedBazelTargets: []string{`cc_binary(
name = "alphabet_binary",
deps = select({
diff --git a/bp2build/testing.go b/bp2build/testing.go
index 82d40cf..dbabc06 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -22,6 +22,7 @@
import (
"fmt"
"path/filepath"
+ "regexp"
"sort"
"strings"
"testing"
@@ -37,6 +38,9 @@
buildDir string
)
+var labelRegex = regexp.MustCompile(`^//([^: ]+):([^ ]+)$`)
+var simpleModuleNameRegex = regexp.MustCompile(`^[^: /]+$`)
+
func checkError(t *testing.T, errs []error, expectedErr error) bool {
t.Helper()
@@ -87,9 +91,12 @@
// in the directory under test. The BUILD file has the given contents. This BUILD file
// will also be treated as "BUILD file to keep" by the simulated bp2build environment.
AlreadyExistingBuildContents string
- // StubbedBuildDefinitions, if non-empty, adds stub definitions to an already-present source
- // BUILD file in the directory under test, for each target name given. These stub definitions
- // are added to the BUILD file given in AlreadyExistingBuildContents, if it is set.
+
+ // StubbedBuildDefinitions, if non-empty, adds stub definitions to already-present source
+ // BUILD files for each bazel label given. The BUILD files with these stub definitions
+ // are added to the BUILD file given in AlreadyExistingBuildContents.
+ // Labels may be of the form //pkg/to:target_name (which would be defined in pkg/to/BUILD.bazel)
+ // or `target_name` (which would be defined in ./BUILD.bazel).
StubbedBuildDefinitions []string
Filesystem map[string]string
@@ -120,32 +127,51 @@
func runBp2BuildTestCaseWithSetup(t *testing.T, extraPreparer android.FixturePreparer, tc Bp2buildTestCase) {
t.Helper()
+ if tc.Filesystem == nil {
+ tc.Filesystem = map[string]string{}
+ }
checkDir := "."
if tc.Dir != "" {
checkDir = tc.Dir
}
keepExistingBuildDirs := tc.KeepBuildFileForDirs
buildFilesToParse := []string{}
+
+ if len(tc.StubbedBuildDefinitions) > 0 {
+ for _, buildDef := range tc.StubbedBuildDefinitions {
+ globalLabelMatch := labelRegex.FindStringSubmatch(buildDef)
+ var dir, targetName string
+ if len(globalLabelMatch) > 0 {
+ dir = globalLabelMatch[1]
+ targetName = globalLabelMatch[2]
+ } else {
+ if !simpleModuleNameRegex.MatchString(buildDef) {
+ t.Errorf("Stubbed build definition '%s' must be either a simple module name or of global target syntax (//foo/bar:baz).", buildDef)
+ return
+ }
+ dir = "."
+ targetName = buildDef
+ }
+ buildFilePath := filepath.Join(dir, "BUILD")
+ tc.Filesystem[buildFilePath] +=
+ MakeBazelTarget(
+ "bp2build_test_stub",
+ targetName,
+ AttrNameToString{})
+ keepExistingBuildDirs = append(keepExistingBuildDirs, dir)
+ buildFilesToParse = append(buildFilesToParse, buildFilePath)
+ }
+ }
+ if len(tc.AlreadyExistingBuildContents) > 0 {
+ buildFilePath := filepath.Join(checkDir, "BUILD")
+ tc.Filesystem[buildFilePath] += tc.AlreadyExistingBuildContents
+ keepExistingBuildDirs = append(keepExistingBuildDirs, checkDir)
+ buildFilesToParse = append(buildFilesToParse, buildFilePath)
+ }
filesystem := make(map[string][]byte)
for f, content := range tc.Filesystem {
filesystem[f] = []byte(content)
}
- alreadyExistingBuildContents := tc.AlreadyExistingBuildContents
- if len(tc.StubbedBuildDefinitions) > 0 {
- for _, targetName := range tc.StubbedBuildDefinitions {
- alreadyExistingBuildContents += MakeBazelTarget(
- "bp2build_test_stub",
- targetName,
- AttrNameToString{})
- }
- }
- if len(alreadyExistingBuildContents) > 0 {
- buildFilePath := filepath.Join(checkDir, "BUILD")
- filesystem[buildFilePath] = []byte(alreadyExistingBuildContents)
- keepExistingBuildDirs = append(keepExistingBuildDirs, checkDir)
- buildFilesToParse = append(buildFilesToParse, buildFilePath)
- }
-
preparers := []android.FixturePreparer{
extraPreparer,
android.FixtureMergeMockFs(filesystem),
@@ -600,11 +626,10 @@
ctx.RegisterForBazelConversion()
}
-func SimpleModuleDoNotConvertBp2build(typ, name string) string {
+func simpleModule(typ, name string) string {
return fmt.Sprintf(`
%s {
name: "%s",
- bazel_module: { bp2build_available: false },
}`, typ, name)
}