Handle arch/os-specific product variables
Bug: 183595873 Test: go test bp2build tests Change-Id: I36e93ae1eb2943555dd304d5bdf62d995e77b437
This commit is contained in:
@@ -1187,14 +1187,86 @@ cc_library_static {
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
] + select({
|
||||
"//build/bazel/product_variables:binder32bit": ["-Wbinder32bit"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"//build/bazel/product_variables:malloc_not_svelte": ["-Wmalloc_not_svelte"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"//build/bazel/product_variables:malloc_zero_contents": ["-Wmalloc_zero_contents"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"//build/bazel/product_variables:binder32bit": ["-Wbinder32bit"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
linkstatic = True,
|
||||
srcs = ["common.c"],
|
||||
)`},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryStaticProductVariableArchSpecificSelects(t *testing.T) {
|
||||
runCcLibraryStaticTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_static arch-specific product variable selects",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
||||
depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryStaticPreamble + `
|
||||
cc_library_static {
|
||||
name: "foo_static",
|
||||
srcs: ["common.c"],
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Wmalloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
arch: {
|
||||
arm64: {
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Warm64_malloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
multilib: {
|
||||
lib32: {
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Wlib32_malloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
android: {
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Wandroid_malloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
} `,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
] + select({
|
||||
"//build/bazel/product_variables:malloc_not_svelte": ["-Wmalloc_not_svelte"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"//build/bazel/product_variables:malloc_not_svelte-android": ["-Wandroid_malloc_not_svelte"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"//build/bazel/product_variables:malloc_not_svelte-arm": ["-Wlib32_malloc_not_svelte"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"//build/bazel/product_variables:malloc_not_svelte-arm64": ["-Warm64_malloc_not_svelte"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"//build/bazel/product_variables:malloc_not_svelte-x86": ["-Wlib32_malloc_not_svelte"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
linkstatic = True,
|
||||
srcs = ["common.c"],
|
||||
|
@@ -34,7 +34,7 @@ func getStringListValues(list bazel.StringListAttribute) (reflect.Value, []selec
|
||||
selectValues = append(selectValues, osSelects)
|
||||
}
|
||||
|
||||
for _, pv := range list.ProductValues {
|
||||
for _, pv := range list.SortedProductVariables() {
|
||||
s := make(selects)
|
||||
if len(pv.Values) > 0 {
|
||||
s[pv.SelectKey()] = reflect.ValueOf(pv.Values)
|
||||
|
Reference in New Issue
Block a user