Dont write data attrs for cc lib rules
The data attributes for cc library rules is dropped by their starlark
macros, so serves no real purpose. Furthermore, this unused dependency
proves problematic for allowlist v2, as there are many cases at HEAD
where the corner-case "requires" dependency would otherwise mark a module
as unconvertible.
Fixes: 303307456
Test: New unit test
Test: Manual verification to unblock allowlist v2 `bp2build.sh` runs in
AOSP
Change-Id: I6ca6104b958d2b428fc2ca5b3fa794106571acca
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index bc88f86..0685de1 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -5245,3 +5245,57 @@
}
runCcLibraryTestCase(t, tc)
}
+
+// Regression test for b/303307456.
+// TODO: b/202299295 - Remove this test when cc rules have proper support
+// for the `required` property
+func TestCcModules_requiredProperty(t *testing.T) {
+ runCcLibrarySharedTestCase(t, Bp2buildTestCase{
+ Description: "cc modules do not use the required property",
+ Filesystem: map[string]string{
+ "foo.c": "",
+ "bar.c": "",
+ },
+ Blueprint: soongCcLibraryPreamble + `
+cc_library {
+ name: "foo_both",
+ srcs: ["foo.c"],
+ include_build_directory: false,
+ required: ["bar"],
+}
+cc_library_shared {
+ name: "foo_shared",
+ srcs: ["foo.c"],
+ include_build_directory: false,
+ required: ["bar"],
+}
+cc_library_static {
+ name: "foo_static",
+ srcs: ["foo.c"],
+ include_build_directory: false,
+ required: ["bar"],
+}
+cc_library_static {
+ name: "bar",
+ srcs: ["bar.c"],
+ include_build_directory: false,
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo_both_bp2build_cc_library_static", AttrNameToString{
+ "srcs_c": `["foo.c"]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "foo_both", AttrNameToString{
+ "srcs_c": `["foo.c"]`,
+ }),
+ MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
+ "srcs_c": `["foo.c"]`,
+ }),
+ MakeBazelTarget("cc_library_static", "foo_static", AttrNameToString{
+ "srcs_c": `["foo.c"]`,
+ }),
+ MakeBazelTarget("cc_library_static", "bar", AttrNameToString{
+ "srcs_c": `["bar.c"]`,
+ }),
+ },
+ })
+}