diff options
author | 2020-09-23 13:26:25 -0400 | |
---|---|---|
committer | 2020-09-24 13:45:09 -0400 | |
commit | 3d94752b34a053af3eeaf00659ccd0761e078a6a (patch) | |
tree | 4450a0550f6c38d29efc8acdebb55589eecb3d3f /rust/bindgen_test.go | |
parent | a9a99bc6d2f053cc0e66679263d610127a6bbced (diff) |
rust: Add rust_bindgen std version w/ cc defaults.
Adds the c_std and cpp_std properties to rust_bindgen, and use the
default values from cc if these are undefined.
This assumes by default that the header extension indicates whether
the header is a C or C++ header file. This default can be overridden
by setting either c_std or cpp_std.
Test: Soong tests pass, "-std=" arg included in bindgen calls
Bug: 163580541
Change-Id: I5b0d3b8eae9a54dd91d8a0aca583d7803a344f27
Diffstat (limited to 'rust/bindgen_test.go')
-rw-r--r-- | rust/bindgen_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/rust/bindgen_test.go b/rust/bindgen_test.go index 191da9b11..359f28b83 100644 --- a/rust/bindgen_test.go +++ b/rust/bindgen_test.go @@ -82,3 +82,47 @@ func TestRustBindgenCustomBindgen(t *testing.T) { libbindgen.Description) } } + +func TestRustBindgenStdVersions(t *testing.T) { + testRustError(t, "c_std and cpp_std cannot both be defined at the same time.", ` + rust_bindgen { + name: "libbindgen", + wrapper_src: "src/any.h", + crate_name: "bindgen", + stem: "libbindgen", + source_stem: "bindings", + c_std: "somevalue", + cpp_std: "somevalue", + } + `) + + ctx := testRust(t, ` + rust_bindgen { + name: "libbindgen_cstd", + wrapper_src: "src/any.h", + crate_name: "bindgen", + stem: "libbindgen", + source_stem: "bindings", + c_std: "foo" + } + rust_bindgen { + name: "libbindgen_cppstd", + wrapper_src: "src/any.h", + crate_name: "bindgen", + stem: "libbindgen", + source_stem: "bindings", + cpp_std: "foo" + } + `) + + libbindgen_cstd := ctx.ModuleForTests("libbindgen_cstd", "android_arm64_armv8-a").Output("bindings.rs") + libbindgen_cppstd := ctx.ModuleForTests("libbindgen_cppstd", "android_arm64_armv8-a").Output("bindings.rs") + + if !strings.Contains(libbindgen_cstd.Args["cflags"], "-std=foo") { + t.Errorf("c_std value not passed in to rust_bindgen as a clang flag") + } + + if !strings.Contains(libbindgen_cppstd.Args["cflags"], "-std=foo") { + t.Errorf("cpp_std value not passed in to rust_bindgen as a clang flag") + } +} |