summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2016-12-11 15:38:53 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2016-12-11 15:38:53 +0100
commit8a605123675d56d95533bfa22270bee202aa42db (patch)
tree9291df6f861588dad39b995dd6dbe94f7d9ab2a9
parentaa05fdf30b0623d7d3622c7afccccbb3209629f5 (diff)
lib: Do the path fixup inside the library, so users of the library don't have to do this themselves.
-rw-r--r--bindgen/src/main.rs25
-rw-r--r--libbindgen/src/lib.rs19
2 files changed, 19 insertions, 25 deletions
diff --git a/bindgen/src/main.rs b/bindgen/src/main.rs
index 8cbff63b..c1dc632f 100644
--- a/bindgen/src/main.rs
+++ b/bindgen/src/main.rs
@@ -42,31 +42,6 @@ pub fn main() {
_ => {}
}
- if let Some(clang) = clang_sys::support::Clang::find(None) {
- let has_clang_args =
- bind_args.iter().rposition(|arg| *arg == "--").is_some();
- if !has_clang_args {
- bind_args.push("--".to_owned());
- }
-
- // If --target is specified, assume caller knows what they're doing and
- // don't mess with
- // include paths for them
- let has_target_arg = bind_args.iter()
- .rposition(|arg| arg.starts_with("--target"))
- .is_some();
- if !has_target_arg {
- // TODO: distinguish C and C++ paths? C++'s should be enough, I
- // guess.
- for path in clang.cpp_search_paths.into_iter() {
- if let Ok(path) = path.into_os_string().into_string() {
- bind_args.push("-isystem".to_owned());
- bind_args.push(path);
- }
- }
- }
- }
-
match builder_from_flags(bind_args.into_iter()) {
Ok((builder, output)) => {
let mut bindings = builder.generate()
diff --git a/libbindgen/src/lib.rs b/libbindgen/src/lib.rs
index 1acfd143..29580f36 100644
--- a/libbindgen/src/lib.rs
+++ b/libbindgen/src/lib.rs
@@ -509,6 +509,25 @@ impl<'ctx> Bindings<'ctx> {
-> Result<Bindings<'ctx>, ()> {
let span = span.unwrap_or(DUMMY_SP);
+ // TODO: Make this path fixup configurable?
+ if let Some(clang) = clang_sys::support::Clang::find(None) {
+ // If --target is specified, assume caller knows what they're doing
+ // and don't mess with include paths for them
+ let has_target_arg = options.clang_args.iter()
+ .rposition(|arg| arg.starts_with("--target"))
+ .is_some();
+ if !has_target_arg {
+ // TODO: distinguish C and C++ paths? C++'s should be enough, I
+ // guess.
+ for path in clang.cpp_search_paths.into_iter() {
+ if let Ok(path) = path.into_os_string().into_string() {
+ options.clang_args.push("-isystem".to_owned());
+ options.clang_args.push(path);
+ }
+ }
+ }
+ }
+
if let Some(h) = options.input_header.as_ref() {
options.clang_args.push(h.clone())
}