bp2build converter for cc libraries containing yacc

For cc_libraries containing .y/.yy srcs, we will generate an additional
cc_yacc_static_library target. This target will produce an .a file that
will be statically linked to the parent target.

Test: go test ./bp2build
Bug: 281546029
Change-Id: I094ba56f0a95869e5bc1e1d38b83c777192b7ddd
This commit is contained in:
Spandan Das
2023-05-09 23:58:52 +00:00
parent 9241da9662
commit df4c2134ea
2 changed files with 123 additions and 0 deletions

View File

@@ -4523,3 +4523,59 @@ func TestCcLibraryCppFlagsInProductVariables(t *testing.T) {
},
)
}
func TestCcLibraryYaccConversion(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
Description: "cc_library is built from .y/.yy files",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
Blueprint: soongCcLibraryPreamble + `cc_library {
name: "a",
srcs: [
"a.cpp",
"a.yy",
],
shared_libs: ["sharedlib"],
static_libs: ["staticlib"],
yacc: {
flags: ["someYaccFlag"],
gen_location_hh: true,
gen_position_hh: true,
},
}
cc_library_static {
name: "staticlib",
bazel_module: { bp2build_available: false },
}
cc_library {
name: "sharedlib",
bazel_module: { bp2build_available: false },
}
`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_yacc_static_library", "a_yacc", AttrNameToString{
"src": `"a.yy"`,
"implementation_deps": `[":staticlib"]`,
"implementation_dynamic_deps": `[":sharedlib"]`,
"flags": `["someYaccFlag"]`,
"gen_location_hh": "True",
"gen_position_hh": "True",
"local_includes": `["."]`,
}),
MakeBazelTarget("cc_library_shared", "a", AttrNameToString{
"srcs": `["a.cpp"]`,
"implementation_deps": `[":staticlib"]`,
"implementation_dynamic_deps": `[":sharedlib"]`,
"implementation_whole_archive_deps": `[":a_yacc"]`,
"local_includes": `["."]`,
}),
MakeBazelTarget("cc_library_static", "a_bp2build_cc_library_static", AttrNameToString{
"srcs": `["a.cpp"]`,
"implementation_deps": `[":staticlib"]`,
"implementation_dynamic_deps": `[":sharedlib"]`,
"implementation_whole_archive_deps": `[":a_yacc"]`,
"local_includes": `["."]`,
}),
},
})
}