Add bp2build converter for cc library stubs and use the stub library target of a library while linking it in APEXs.
Bug: 231322789
Test: with this CL on internal master,
1) b build --verbose_failures //vendor/google/modules/AdbdGoogle:com.google.android.adbd --config=android_x86_64
2) adb install bazel-bin/vendor/google/modules/AdbdGoogle/com.google.android.adbd.apex, and adbd is activated successfully on cuttlefish device.
3) m mts && mts-tradefed run mts-adbd, and there is no failure with cuttlefish device
4) packages/modules/adb/test_device.py, and there is no failure with cuttlefish device.
Change-Id: I81b6f5336cacf35c68957ae2dac65f985b6eafb9
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index f6d5067..72feed5 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -1301,10 +1301,10 @@
"additional_linker_inputs": true,
"linkopts": true,
"strip": true,
- "stubs_symbol_file": true,
- "stubs_versions": true,
"inject_bssl_hash": true,
+ "has_stubs": true,
}
+
sharedAttrs := AttrNameToString{}
staticAttrs := AttrNameToString{}
for key, val := range attrs {
@@ -1321,6 +1321,26 @@
return []string{staticTarget, sharedTarget}
}
+func makeCcStubSuiteTargets(name string, attrs AttrNameToString) string {
+ if _, hasStubs := attrs["stubs_symbol_file"]; !hasStubs {
+ return ""
+ }
+ STUB_SUITE_ATTRS := map[string]string{
+ "stubs_symbol_file": "symbol_file",
+ "stubs_versions": "versions",
+ "soname": "soname",
+ "source_library": "source_library",
+ }
+
+ stubSuiteAttrs := AttrNameToString{}
+ for key, _ := range attrs {
+ if _, stubSuiteAttr := STUB_SUITE_ATTRS[key]; stubSuiteAttr {
+ stubSuiteAttrs[STUB_SUITE_ATTRS[key]] = attrs[key]
+ }
+ }
+ return makeBazelTarget("cc_stub_suite", name+"_stub_libs", stubSuiteAttrs)
+}
+
func TestCCLibraryNoLibCrtFalse(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
ModuleTypeUnderTest: "cc_library",
@@ -2424,6 +2444,19 @@
}
func TestCcLibraryStubs(t *testing.T) {
+ expectedBazelTargets := makeCcLibraryTargets("a", AttrNameToString{
+ "has_stubs": `True`,
+ })
+ expectedBazelTargets = append(expectedBazelTargets, makeCcStubSuiteTargets("a", AttrNameToString{
+ "soname": `"a.so"`,
+ "source_library": `":a"`,
+ "stubs_symbol_file": `"a.map.txt"`,
+ "stubs_versions": `[
+ "28",
+ "29",
+ "current",
+ ]`,
+ }))
runCcLibraryTestCase(t, Bp2buildTestCase{
Description: "cc_library stubs",
ModuleTypeUnderTest: "cc_library",
@@ -2439,15 +2472,8 @@
}
`,
},
- Blueprint: soongCcLibraryPreamble,
- ExpectedBazelTargets: makeCcLibraryTargets("a", AttrNameToString{
- "stubs_symbol_file": `"a.map.txt"`,
- "stubs_versions": `[
- "28",
- "29",
- "current",
- ]`,
- }),
+ Blueprint: soongCcLibraryPreamble,
+ ExpectedBazelTargets: expectedBazelTargets,
},
)
}