Merge "Split ldflags in bp2build"

This commit is contained in:
Trevor Radcliffe
2022-10-07 17:31:29 +00:00
committed by Gerrit Code Review
4 changed files with 121 additions and 16 deletions

View File

@@ -961,6 +961,46 @@ cc_library {
)
}
func TestCcLibraryLdflagsSplitBySpaceExceptSoongAdded(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
Description: "ldflags are split by spaces except for the ones added by soong (version script and dynamic list)",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
Filesystem: map[string]string{
"version_script": "",
"dynamic.list": "",
},
Blueprint: `
cc_library {
name: "foo",
ldflags: [
"--nospace_flag",
"-z spaceflag",
],
version_script: "version_script",
dynamic_list: "dynamic.list",
include_build_directory: false,
}
`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{}),
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
"additional_linker_inputs": `[
"version_script",
"dynamic.list",
]`,
"linkopts": `[
"--nospace_flag",
"-z",
"spaceflag",
"-Wl,--version-script,$(location version_script)",
"-Wl,--dynamic-list,$(location dynamic.list)",
]`,
}),
},
})
}
func TestCcLibrarySharedLibs(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
Description: "cc_library shared_libs",