From c5e044d561149498a95386fdb5bf28d2de6e1985 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 17 Apr 2017 18:28:51 +0900 Subject: Add Builder::clang_args (plural) Use AsRef rather than Into because &&str (what you get when iterating &[&str]) does not implement the latter. --- Cargo.lock | 2 +- Cargo.toml | 2 +- bindgen-integration/build.rs | 4 +--- src/lib.rs | 10 ++++++++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9006946e..37c8065e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "bindgen" -version = "0.23.0" +version = "0.23.1" dependencies = [ "aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "cexpr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 3c0a60fc..09f4e787 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ name = "bindgen" readme = "README.md" repository = "https://github.com/servo/rust-bindgen" documentation = "https://docs.rs/bindgen" -version = "0.23.0" +version = "0.23.1" build = "build.rs" exclude = [ diff --git a/bindgen-integration/build.rs b/bindgen-integration/build.rs index fe7ffb1f..b715486c 100644 --- a/bindgen-integration/build.rs +++ b/bindgen-integration/build.rs @@ -32,9 +32,7 @@ fn main() { .enable_cxx_namespaces() .raw_line("pub use self::root::*;") .header("cpp/Test.h") - .clang_arg("-x") - .clang_arg("c++") - .clang_arg("-std=c++11") + .clang_args(&["-x", "c++", "-std=c++11"]) .parse_callbacks(Box::new(MacroCallback {macros: macros.clone()})) .generate() .expect("Unable to generate bindings"); diff --git a/src/lib.rs b/src/lib.rs index 5960d616..993cd1c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -555,6 +555,16 @@ impl Builder { self } + /// Add arguments to be passed straight through to clang. + pub fn clang_args(mut self, iter: I) -> Builder + where I: IntoIterator, + I::Item: AsRef { + for arg in iter { + self = self.clang_arg(arg.as_ref()) + } + self + } + /// Make the generated bindings link the given shared library. pub fn link>(mut self, library: T) -> Builder { self.options.links.push((library.into(), LinkType::Default)); -- cgit v1.2.3