Merge "Escape cc ldflags in bp2build conversion" am: 9deb87e8e2 am: e2f1b14961 am: 04bf233677

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1973479

Change-Id: I8e9798fe80bcf10925f5f694e9e8e2e705b20e2e
This commit is contained in:
Treehugger Robot 2022-02-10 00:01:24 +00:00 committed by Automerger Merge Worker
commit ef3b27ec23
2 changed files with 16 additions and 1 deletions

View file

@ -2437,3 +2437,18 @@ cc_library {
},
)
}
func TestCcLibraryEscapeLdflags(t *testing.T) {
runCcLibraryTestCase(t, bp2buildTestCase{
moduleTypeUnderTest: "cc_library",
moduleTypeUnderTestFactory: cc.LibraryFactory,
blueprint: soongCcProtoPreamble + `cc_library {
name: "foo",
ldflags: ["-Wl,--rpath,${ORIGIN}"],
include_build_directory: false,
}`,
expectedBazelTargets: makeCcLibraryTargets("foo", attrNameToString{
"linkopts": `["-Wl,--rpath,$${ORIGIN}"]`,
}),
})
}

View file

@ -644,7 +644,7 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion
var linkerFlags []string
if len(props.Ldflags) > 0 {
linkerFlags = append(linkerFlags, props.Ldflags...)
linkerFlags = append(linkerFlags, proptools.NinjaEscapeList(props.Ldflags)...)
// binaries remove static flag if -shared is in the linker flags
if isBinary && android.InList("-shared", linkerFlags) {
axisFeatures = append(axisFeatures, "-static_flag")