Merge "Implement configured version_script." am: a412c74fc9 am: dbc77ca9d5

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

Change-Id: I15d2b94a2e1c6f4aba2d6c263fbb59f26edb86e2
This commit is contained in:
Lukács T. Berki 2021-05-12 18:47:26 +00:00 committed by Automerger Merge Worker
commit 0cb4b88e43
2 changed files with 50 additions and 2 deletions

View File

@ -350,6 +350,43 @@ cc_library {
copts = ["-Ifoo/bar"],
srcs = ["a.cpp"],
version_script = "v.map",
)`},
},
{
description: "cc_library configured version script",
moduleTypeUnderTest: "cc_library",
moduleTypeUnderTestFactory: cc.LibraryFactory,
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
dir: "foo/bar",
filesystem: map[string]string{
"foo/bar/Android.bp": `
cc_library {
name: "a",
srcs: ["a.cpp"],
arch: {
arm: {
version_script: "arm.map",
},
arm64: {
version_script: "arm64.map",
},
},
bazel_module: { bp2build_available: true },
}
`,
},
bp: soongCcLibraryPreamble,
expectedBazelTargets: []string{`cc_library(
name = "a",
copts = ["-Ifoo/bar"],
srcs = ["a.cpp"],
version_script = select({
"//build/bazel/platforms/arch:arm": "arm.map",
"//build/bazel/platforms/arch:arm64": "arm64.map",
"//conditions:default": None,
}),
)`},
},
{

View File

@ -31,8 +31,19 @@ func getStringListValues(list bazel.StringListAttribute) (reflect.Value, selects
}
func getLabelValue(label bazel.LabelAttribute) (reflect.Value, selects, selects) {
value := reflect.ValueOf(label.Value)
return value, nil, nil
var value reflect.Value
var archSelects selects
if label.HasConfigurableValues() {
archSelects = map[string]reflect.Value{}
for arch, selectKey := range bazel.PlatformArchMap {
archSelects[selectKey] = reflect.ValueOf(label.GetValueForArch(arch))
}
} else {
value = reflect.ValueOf(label.Value)
}
return value, archSelects, nil
}
func getLabelListValues(list bazel.LabelListAttribute) (reflect.Value, selects, selects) {