Merge "Fix a bug where CppFlags should have been Cppflags" into udc-dev am: 2b9f3f983b

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

Change-Id: I17430cc5ae45f4cae64b5d4f0c5fb0cfdb67fc92
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Yu Liu
2023-05-24 17:57:08 +00:00
committed by Automerger Merge Worker
2 changed files with 41 additions and 1 deletions

View File

@@ -4350,3 +4350,43 @@ cc_library {
},
})
}
func TestCcLibraryCppFlagsInProductVariables(t *testing.T) {
runCcLibraryTestCase(t, Bp2buildTestCase{
Description: "cc_library cppflags in product variables",
ModuleTypeUnderTest: "cc_library",
ModuleTypeUnderTestFactory: cc.LibraryFactory,
Blueprint: soongCcLibraryPreamble + `cc_library {
name: "a",
srcs: ["a.cpp"],
cppflags: [
"-Wextra",
"-DDEBUG_ONLY_CODE=0",
],
product_variables: {
eng: {
cppflags: [
"-UDEBUG_ONLY_CODE",
"-DDEBUG_ONLY_CODE=1",
],
},
},
include_build_directory: false,
}
`,
ExpectedBazelTargets: makeCcLibraryTargets("a", AttrNameToString{
"cppflags": `[
"-Wextra",
"-DDEBUG_ONLY_CODE=0",
] + select({
"//build/bazel/product_variables:eng": [
"-UDEBUG_ONLY_CODE",
"-DDEBUG_ONLY_CODE=1",
],
"//conditions:default": [],
})`,
"srcs": `["a.cpp"]`,
}),
},
)
}

View File

@@ -517,7 +517,7 @@ func (ca *compilerAttributes) convertProductVariables(ctx android.BazelConversio
productVarPropNameToAttribute := map[string]*bazel.StringListAttribute{
"Cflags": &ca.copts,
"Asflags": &ca.asFlags,
"CppFlags": &ca.cppFlags,
"Cppflags": &ca.cppFlags,
}
for propName, attr := range productVarPropNameToAttribute {
if productConfigProps, exists := productVariableProps[propName]; exists {