diff options
author | Yu Liu <yudiliu@google.com> | 2023-05-24 18:41:07 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-05-24 18:41:07 +0000 |
commit | 14940daa3ec7e045bcdeacb71925a091cc6ff628 (patch) | |
tree | d37433f0e0703ba953ab0689177cf1546c479633 | |
parent | b4a1f9cc9610d66327b72916b51dd8dc030eb3de (diff) | |
parent | a62b5cdc1ab3372d5e039c09f71a9fcb80ce4fb9 (diff) | |
download | soong-14940daa3ec7e045bcdeacb71925a091cc6ff628.tar.gz |
Merge "Fix a bug where CppFlags should have been Cppflags" into udc-dev am: 2b9f3f983b am: a62b5cdc1a
Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/23353145
Change-Id: I59f599e8716b22ed34ee91a395589da29d23d25b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | bp2build/cc_library_conversion_test.go | 40 | ||||
-rw-r--r-- | cc/bp2build.go | 2 |
2 files changed, 41 insertions, 1 deletions
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go index d2c463dbb..7165ac45b 100644 --- a/bp2build/cc_library_conversion_test.go +++ b/bp2build/cc_library_conversion_test.go @@ -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"]`, + }), + }, + ) +} diff --git a/cc/bp2build.go b/cc/bp2build.go index c8f516cdc..2b92d3be5 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -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 { |