summaryrefslogtreecommitdiff
path: root/rust/bindgen_test.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2023-10-09 11:30:09 -0400
committer Ivan Lozano <ivanlozano@google.com> 2023-10-09 11:52:18 -0400
commit829e1e9378e710c26ea0860cca6c651da6964095 (patch)
tree8d3b6afa9658fdc892001aea4cd1e190744edd9c /rust/bindgen_test.go
parent0b6c4b7c082e13a3575aabf44e39d484694818dd (diff)
rust: Emit -x c++ for bindgen modules with cpp_std
rust_bindgen modules which defined cpp_std with a .h file were not correctly emitting the `-x c++` flag. This CL addresses that, and ensures that if either cpp_std or c_std is set then the appropriate behavior occurs no matter the file extension. Bug: 304269101 Test: Soong tests Change-Id: I71a8ae30ac0ed502d9d3fbf2f3039b0c56529d39
Diffstat (limited to 'rust/bindgen_test.go')
-rw-r--r--rust/bindgen_test.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/rust/bindgen_test.go b/rust/bindgen_test.go
index 12cdb3cb4..0ba0ff840 100644
--- a/rust/bindgen_test.go
+++ b/rust/bindgen_test.go
@@ -115,7 +115,7 @@ func TestRustBindgenStdVersions(t *testing.T) {
ctx := testRust(t, `
rust_bindgen {
name: "libbindgen_cstd",
- wrapper_src: "src/any.h",
+ wrapper_src: "src/any.hpp",
crate_name: "bindgen",
stem: "libbindgen",
source_stem: "bindings",
@@ -141,6 +141,16 @@ func TestRustBindgenStdVersions(t *testing.T) {
if !strings.Contains(libbindgen_cppstd.Args["cflags"], "-std=foo") {
t.Errorf("cpp_std value not passed in to rust_bindgen as a clang flag")
}
+
+ // Make sure specifying cpp_std emits the '-x c++' flag
+ if !strings.Contains(libbindgen_cppstd.Args["cflags"], "-x c++") {
+ t.Errorf("Setting cpp_std should cause the '-x c++' flag to be emitted")
+ }
+
+ // Make sure specifying c_std omits the '-x c++' flag
+ if strings.Contains(libbindgen_cstd.Args["cflags"], "-x c++") {
+ t.Errorf("Setting c_std should not cause the '-x c++' flag to be emitted")
+ }
}
func TestBindgenDisallowedFlags(t *testing.T) {