Skip to content

Commit c5182f0

Browse files
committed
Add Builder::clang_args (plural)
Use AsRef<str> rather than Into<String> because &&str (what you get when iterating &[&str]) does not implement the latter.
1 parent 8b1f7c0 commit c5182f0

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ name = "bindgen"
1313
readme = "README.md"
1414
repository = "https://github.com/servo/rust-bindgen"
1515
documentation = "https://docs.rs/bindgen"
16-
version = "0.23.0"
16+
version = "0.23.1"
1717
build = "build.rs"
1818

1919
exclude = [

bindgen-integration/build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ fn main() {
3232
.enable_cxx_namespaces()
3333
.raw_line("pub use self::root::*;")
3434
.header("cpp/Test.h")
35-
.clang_arg("-x")
36-
.clang_arg("c++")
37-
.clang_arg("-std=c++11")
35+
.clang_args(&["-x", "c++", "-std=c++11"])
3836
.parse_callbacks(Box::new(MacroCallback {macros: macros.clone()}))
3937
.generate()
4038
.expect("Unable to generate bindings");

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,15 @@ impl Builder {
555555
self
556556
}
557557

558+
/// Add arguments to be passed straight through to clang.
559+
pub fn clang_args<I>(mut self, iter: I) -> Builder
560+
where I: IntoIterator, I::Item: AsRef<str> {
561+
for arg in iter {
562+
self.options.clang_args.push(arg.as_ref().into());
563+
}
564+
self
565+
}
566+
558567
/// Make the generated bindings link the given shared library.
559568
pub fn link<T: Into<String>>(mut self, library: T) -> Builder {
560569
self.options.links.push((library.into(), LinkType::Default));

0 commit comments

Comments
 (0)