diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2016-12-11 15:38:53 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2016-12-11 15:38:53 +0100 |
commit | 8a605123675d56d95533bfa22270bee202aa42db (patch) | |
tree | 9291df6f861588dad39b995dd6dbe94f7d9ab2a9 /libbindgen/src | |
parent | aa05fdf30b0623d7d3622c7afccccbb3209629f5 (diff) |
lib: Do the path fixup inside the library, so users of the library don't have to do this themselves.
Diffstat (limited to 'libbindgen/src')
-rw-r--r-- | libbindgen/src/lib.rs | 19 |
1 files changed, 19 insertions, 0 deletions
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()) } |