Update version_script to be handled as linkopt

This allows us to handle this consistently between cc_binary and
cc_library* types.

Test: build/bazel/ci/bp2build.sh
Change-Id: I996f42bbe591215217c3d561662e775925b871ff
This commit is contained in:
Liz Kammer
2021-10-04 13:54:37 -04:00
parent 06f00c33a7
commit d2871189b1
4 changed files with 40 additions and 61 deletions

View File

@@ -803,8 +803,9 @@ cc_library {
blueprint: soongCcLibraryPreamble,
expectedBazelTargets: []string{`cc_library(
name = "a",
additional_linker_inputs = ["v.map"],
linkopts = ["-Wl,--version-script,$(location v.map)"],
srcs = ["a.cpp"],
version_script = "v.map",
)`},
})
}
@@ -838,12 +839,17 @@ cc_library {
blueprint: soongCcLibraryPreamble,
expectedBazelTargets: []string{`cc_library(
name = "a",
srcs = ["a.cpp"],
version_script = select({
"//build/bazel/platforms/arch:arm": "arm.map",
"//build/bazel/platforms/arch:arm64": "arm64.map",
"//conditions:default": None,
additional_linker_inputs = select({
"//build/bazel/platforms/arch:arm": ["arm.map"],
"//build/bazel/platforms/arch:arm64": ["arm64.map"],
"//conditions:default": [],
}),
linkopts = select({
"//build/bazel/platforms/arch:arm": ["-Wl,--version-script,$(location arm.map)"],
"//build/bazel/platforms/arch:arm64": ["-Wl,--version-script,$(location arm64.map)"],
"//conditions:default": [],
}),
srcs = ["a.cpp"],
)`},
})
}
@@ -1010,39 +1016,6 @@ func TestCcLibraryCppFlagsGoesIntoCopts(t *testing.T) {
})
}
func TestCcLibraryLabelAttributeGetTargetProperties(t *testing.T) {
runCcLibraryTestCase(t, bp2buildTestCase{
description: "cc_library GetTargetProperties on a LabelAttribute",
moduleTypeUnderTest: "cc_library",
moduleTypeUnderTestFactory: cc.LibraryFactory,
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
blueprint: soongCcLibraryPreamble + `
cc_library {
name: "a",
srcs: ["a.cpp"],
target: {
android_arm: {
version_script: "android_arm.map",
},
linux_bionic_arm64: {
version_script: "linux_bionic_arm64.map",
},
},
include_build_directory: false,
}
`,
expectedBazelTargets: []string{`cc_library(
name = "a",
srcs = ["a.cpp"],
version_script = select({
"//build/bazel/platforms/os_arch:android_arm": "android_arm.map",
"//build/bazel/platforms/os_arch:linux_bionic_arm64": "linux_bionic_arm64.map",
"//conditions:default": None,
}),
)`},
})
}
func TestCcLibraryExcludeLibs(t *testing.T) {
runCcLibraryTestCase(t, bp2buildTestCase{
moduleTypeUnderTest: "cc_library",