Handle product config specific header_libs prop in cc bp2build
Product variable header_libs is able to be converted.
Since static_libs and header_libs both use implementationDeps,
also added logic to make sure they both contribute to bazel
target.
Bug: 228314770
Test: m bp2build
Test: TestCcLibraryProductVariablesHeaderLibs in cc_library_conversion_test
Change-Id: I370fc75b666b3908b6ac5ed42bca5560f957fc42
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 6c56d41..e1b7b57 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -1199,6 +1199,40 @@
)
}
+func TestCcLibraryProductVariablesHeaderLibs(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Filesystem: map[string]string{},
+ Blueprint: soongCcLibraryStaticPreamble + `
+cc_library {
+ name: "foo_static",
+ srcs: ["common.c"],
+ product_variables: {
+ malloc_not_svelte: {
+ header_libs: ["malloc_not_svelte_header_lib"],
+ },
+ },
+ include_build_directory: false,
+}
+
+cc_library {
+ name: "malloc_not_svelte_header_lib",
+ bazel_module: { bp2build_available: false },
+}
+`,
+ ExpectedBazelTargets: makeCcLibraryTargets("foo_static", AttrNameToString{
+ "implementation_deps": `select({
+ "//build/bazel/product_variables:malloc_not_svelte": [":malloc_not_svelte_header_lib"],
+ "//conditions:default": [],
+ })`,
+ "srcs_c": `["common.c"]`,
+ "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
+ }),
+ },
+ )
+}
+
func TestCCLibraryNoCrtTrue(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
Description: "cc_library - nocrt: true emits attribute",