From aa05fdf30b0623d7d3622c7afccccbb3209629f5 Mon Sep 17 00:00:00 2001 From: Emilio Cobos Álvarez Date: Sun, 11 Dec 2016 09:46:49 +0100 Subject: options: Ensure to pass the clang header last to clang. --- libbindgen/src/lib.rs | 10 +++++++--- libbindgen/tests/expectations/tests/dash_language.rs | 12 ++++++++++++ libbindgen/tests/headers/dash_language.h | 6 ++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 libbindgen/tests/expectations/tests/dash_language.rs create mode 100644 libbindgen/tests/headers/dash_language.h diff --git a/libbindgen/src/lib.rs b/libbindgen/src/lib.rs index 3ced6dab..1acfd143 100644 --- a/libbindgen/src/lib.rs +++ b/libbindgen/src/lib.rs @@ -168,8 +168,8 @@ impl Builder { /// Set the input C/C++ header. pub fn header>(mut self, header: T) -> Builder { let header = header.into(); - self.options.input_header = Some(header.clone()); - self.clang_arg(header) + self.options.input_header = Some(header); + self } /// Generate a C/C++ file that includes the header and has dummy uses of @@ -504,11 +504,15 @@ impl<'ctx> Bindings<'ctx> { /// /// Deprecated - use a `Builder` instead #[deprecated] - pub fn generate(options: BindgenOptions, + pub fn generate(mut options: BindgenOptions, span: Option) -> Result, ()> { let span = span.unwrap_or(DUMMY_SP); + if let Some(h) = options.input_header.as_ref() { + options.clang_args.push(h.clone()) + } + let mut context = BindgenContext::new(options); try!(parse(&mut context)); diff --git a/libbindgen/tests/expectations/tests/dash_language.rs b/libbindgen/tests/expectations/tests/dash_language.rs new file mode 100644 index 00000000..148f9c32 --- /dev/null +++ b/libbindgen/tests/expectations/tests/dash_language.rs @@ -0,0 +1,12 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Foo { + pub bar: ::std::os::raw::c_int, + pub _phantom_0: ::std::marker::PhantomData, +} diff --git a/libbindgen/tests/headers/dash_language.h b/libbindgen/tests/headers/dash_language.h new file mode 100644 index 00000000..4c8bb58d --- /dev/null +++ b/libbindgen/tests/headers/dash_language.h @@ -0,0 +1,6 @@ +// bindgen-flags: -- -x c++ --std=c++11 + +template +struct Foo { + int bar; +}; -- cgit v1.2.3