[rust] Escape flags for bindgen
Bindgen flags and cflags should be escaped, as they may contain shell
globs or other special characters.
Test: Updated Soong test passes.
Change-Id: I3df8ef25391f53a191f0494c5ff8c641d4d4b6f8
diff --git a/rust/bindgen_test.go b/rust/bindgen_test.go
index c428348..a78bb5f 100644
--- a/rust/bindgen_test.go
+++ b/rust/bindgen_test.go
@@ -27,8 +27,8 @@
crate_name: "bindgen",
stem: "libbindgen",
source_stem: "bindings",
- bindgen_flags: ["--bindgen-flag"],
- cflags: ["--clang-flag"],
+ bindgen_flags: ["--bindgen-flag.*"],
+ cflags: ["--clang-flag()"],
shared_libs: ["libfoo_shared"],
static_libs: ["libfoo_static"],
}
@@ -42,10 +42,11 @@
}
`)
libbindgen := ctx.ModuleForTests("libbindgen", "android_arm64_armv8-a").Output("bindings.rs")
- if !strings.Contains(libbindgen.Args["flags"], "--bindgen-flag") {
+ // Ensure that the flags are present and escaped
+ if !strings.Contains(libbindgen.Args["flags"], "'--bindgen-flag.*'") {
t.Errorf("missing bindgen flags in rust_bindgen rule: flags %#v", libbindgen.Args["flags"])
}
- if !strings.Contains(libbindgen.Args["cflags"], "--clang-flag") {
+ if !strings.Contains(libbindgen.Args["cflags"], "'--clang-flag()'") {
t.Errorf("missing clang cflags in rust_bindgen rule: cflags %#v", libbindgen.Args["cflags"])
}
if !strings.Contains(libbindgen.Args["cflags"], "-Ishared_include") {