diff options
author | 2020-10-16 10:49:08 -0400 | |
---|---|---|
committer | 2020-10-16 10:52:46 -0400 | |
commit | 0a2a1154577a8df48e37388ca081c42cae8be141 (patch) | |
tree | 65fb3596ce3fb147176be987aabfb1ed8ff71b87 /rust/bindgen_test.go | |
parent | faa866c5f05fbcd5d80b5feb2111da5ed2fdf41b (diff) |
rust: Add cflag checks against -xc++ and -std.
If -x c++ is passed through a modules cflags, it will be overridden by a
-x c and -std flag added by the build system if the extension is not
.hpp/.hh and cpp_std is not set. This leads to confusing behavior.
Instead, add a helpful error message to guide developers towards the
correct way to specify when a header is a C++ header and which std
version should be used.
Bug: 171011490
Test: m nothing
Change-Id: I7e7cba504798d47ce1c753ba8699d7475a95095b
Diffstat (limited to 'rust/bindgen_test.go')
-rw-r--r-- | rust/bindgen_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/rust/bindgen_test.go b/rust/bindgen_test.go index 9cccf13be..c7ce42bb4 100644 --- a/rust/bindgen_test.go +++ b/rust/bindgen_test.go @@ -134,3 +134,29 @@ func TestRustBindgenStdVersions(t *testing.T) { t.Errorf("cpp_std value not passed in to rust_bindgen as a clang flag") } } + +func TestBindgenDisallowedFlags(t *testing.T) { + // Make sure passing '-x c++' to cflags generates an error + testRustError(t, "cflags: -x c\\+\\+ should not be specified in cflags.*", ` + rust_bindgen { + name: "libbad_flag", + wrapper_src: "src/any.h", + crate_name: "bindgen", + stem: "libbindgen", + source_stem: "bindings", + cflags: ["-x c++"] + } + `) + + // Make sure passing '-std=' to cflags generates an error + testRustError(t, "cflags: -std should not be specified in cflags.*", ` + rust_bindgen { + name: "libbad_flag", + wrapper_src: "src/any.h", + crate_name: "bindgen", + stem: "libbindgen", + source_stem: "bindings", + cflags: ["-std=foo"] + } + `) +} |