Create bp2build converter for versioned_ndk_headers
This module type is used by a single soong module - `common_libc` in
bionic/libc
Implementation details
- Convert this module type to ndk_headers rule. Bazel's ndk_headers rule
will have a boolean attribute `run_versioner` to determine if
verioner should be run on the headers
- Add this module type to the alwaysConvert bp2build list
- Add the converted target for `common_libc` to the deps of
`ndk_sysroot`. This ensures that unbundled apps link against the
versioned NDK headers of libc
Test: go test ./bp2build
Test: b build //bionic/libc:common_libc --config=android
Test: for f in $(find bazel-bin/bionic/libc/common_libc.versioned -type f); do cmp $f ${f/bazel-bin\/bionic\/libc\/common_libc.versioned/out\/soong\/ndk\/sysroot\/usr\/include}; done # no diff
Bug: 301169067
Change-Id: I55be202f0589db9bdc743c8be41c9c5afd74c352
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index c2b65a1..f1020ed 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -5198,7 +5198,7 @@
name: "libfoo_headers",
from: "from",
to: "to",
- srcs: ["foo.h", "foo_other.h"]
+ srcs: ["from/foo.h", "from/foo_other.h"]
}
`,
ExpectedBazelTargets: []string{
@@ -5206,11 +5206,42 @@
"strip_import_prefix": `"from"`,
"import_prefix": `"to"`,
"hdrs": `[
- "foo.h",
- "foo_other.h",
+ "from/foo.h",
+ "from/foo_other.h",
]`,
}),
},
}
runCcLibraryTestCase(t, tc)
}
+
+func TestVersionedNdkHeadersConversion(t *testing.T) {
+ tc := Bp2buildTestCase{
+ Description: "versioned_ndk_headers conversion",
+ ModuleTypeUnderTest: "versioned_ndk_headers",
+ ModuleTypeUnderTestFactory: cc.VersionedNdkHeadersFactory,
+ Blueprint: `
+versioned_ndk_headers {
+ name: "libfoo_headers",
+ from: "from",
+ to: "to",
+}
+`,
+ Filesystem: map[string]string{
+ "from/foo.h": "",
+ "from/foo_other.h": "",
+ },
+ ExpectedBazelTargets: []string{
+ MakeBazelTargetNoRestrictions("ndk_headers", "libfoo_headers", AttrNameToString{
+ "strip_import_prefix": `"from"`,
+ "import_prefix": `"to"`,
+ "hdrs": `[
+ "from/foo.h",
+ "from/foo_other.h",
+ ]`,
+ "run_versioner": "True",
+ }),
+ },
+ }
+ runCcLibraryTestCase(t, tc)
+}