Add target/os configurable string_list attrs.

Starting with copts for cc_object, with an extracted function that can
be shared with other cc_* module types.

Test: TH
Change-Id: I9025232e83a3dcd0ca243387486fafbdbd3e2d9b
This commit is contained in:
Jingwen Chen
2021-04-05 10:35:13 +00:00
parent 1a6bbbd990
commit c1c2650532
7 changed files with 209 additions and 71 deletions

View File

@@ -412,6 +412,54 @@ func TestCcObjectConfigurableAttributesBp2Build(t *testing.T) {
],
"//conditions:default": [],
}),
)`,
},
},
{
description: "cc_object setting cflags for multiple OSes",
moduleTypeUnderTest: "cc_object",
moduleTypeUnderTestFactory: cc.ObjectFactory,
moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
blueprint: `cc_object {
name: "foo",
srcs: ["base.cpp"],
target: {
android: {
cflags: ["-fPIC"],
},
windows: {
cflags: ["-fPIC"],
},
darwin: {
cflags: ["-Wall"],
},
},
bazel_module: { bp2build_available: true },
}
`,
expectedBazelTargets: []string{
`cc_object(
name = "foo",
copts = [
"-fno-addrsig",
] + select({
"//build/bazel/platforms/os:android": [
"-fPIC",
],
"//build/bazel/platforms/os:darwin": [
"-Wall",
],
"//build/bazel/platforms/os:windows": [
"-fPIC",
],
"//conditions:default": [],
}),
local_include_dirs = [
".",
],
srcs = [
"base.cpp",
],
)`,
},
},