Create Stub targets for cc_library_(static|shared)
Fixes: 246958825
Test: Temporarily allowlist module and inspect BUILD.bazel
Change-Id: I4baeec2d873fefabd49ce77508630b82f759820a
diff --git a/bp2build/testing.go b/bp2build/testing.go
index edc5c4a..8ce8bb2 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -463,3 +463,23 @@
func (ebr ExpectedRuleTarget) String() string {
return makeBazelTargetHostOrDevice(ebr.Rule, ebr.Name, ebr.Attrs, ebr.Hod)
}
+
+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)
+}