Merge "Escape cc ldflags in bp2build conversion"

This commit is contained in:
Treehugger Robot
2022-02-09 23:05:01 +00:00
committed by Gerrit Code Review
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")