Convert cc library with AIDL to cc_aidl_library
Change-Id: I1056b37cf09f4341bf2c2545c9069dbe49ea5ab3
Test: USE_BAZEL_ANALYSIS=1 m libbinder
Bug: 243010121
Fix: 243015050
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 2d1a7ce..024d4e0 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -2592,3 +2592,83 @@
}),
})
}
+
+func TestCcLibraryWithAidlSrcs(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library with aidl srcs",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+filegroup {
+ name: "A_aidl",
+ srcs: ["aidl/A.aidl"],
+ path: "aidl",
+}
+cc_library {
+ name: "foo",
+ srcs: [
+ ":A_aidl",
+ "B.aidl",
+ ],
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTargetNoRestrictions("aidl_library", "A_aidl", AttrNameToString{
+ "srcs": `["aidl/A.aidl"]`,
+ "strip_import_prefix": `"aidl"`,
+ }),
+ makeBazelTarget("aidl_library", "foo_aidl_library", AttrNameToString{
+ "srcs": `["B.aidl"]`,
+ }),
+ makeBazelTarget("cc_aidl_library", "foo_cc_aidl_library", AttrNameToString{
+ "deps": `[
+ ":A_aidl",
+ ":foo_aidl_library",
+ ]`,
+ }),
+ makeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "whole_archive_deps": `[":foo_cc_aidl_library"]`,
+ "local_includes": `["."]`,
+ }),
+ makeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "whole_archive_deps": `[":foo_cc_aidl_library"]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}
+
+func TestCcLibraryWithNonAdjacentAidlFilegroup(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library with non aidl filegroup",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Filesystem: map[string]string{
+ "path/to/A/Android.bp": `
+filegroup {
+ name: "A_aidl",
+ srcs: ["aidl/A.aidl"],
+ path: "aidl",
+}`,
+ },
+ Blueprint: `
+cc_library {
+ name: "foo",
+ srcs: [
+ ":A_aidl",
+ ],
+}`,
+ ExpectedBazelTargets: []string{
+ makeBazelTarget("cc_aidl_library", "foo_cc_aidl_library", AttrNameToString{
+ "deps": `["//path/to/A:A_aidl"]`,
+ }),
+ makeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "whole_archive_deps": `[":foo_cc_aidl_library"]`,
+ "local_includes": `["."]`,
+ }),
+ makeBazelTarget("cc_library_shared", "foo", AttrNameToString{
+ "whole_archive_deps": `[":foo_cc_aidl_library"]`,
+ "local_includes": `["."]`,
+ }),
+ },
+ })
+}