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
This commit is contained in:
Chris Parsons
2023-10-04 22:27:40 +00:00
committed by Christopher Parsons
parent b7a6720611
commit 7123cc5370
3 changed files with 89 additions and 13 deletions

View File

@@ -5245,3 +5245,57 @@ versioned_ndk_headers {
}
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"]`,
}),
},
})
}