Skip to content

Commit bbd6b2c

Browse files
author
bors-servo
authored
Auto merge of #54 - vvuk:master, r=emilio
Skip -isystem stuff if --target is specified, and don't strip leading _ on Windows The -isystem stuff fixes issue #53. Stripping leading _ on Windows is weird; it needs to not be stripped on MSVC (leading @), but on gcc at one point it needed to be. But now it no longer does. I don't know. 'cargo test' succeeds with mozjs bindings generated with these fixes.
2 parents 89e2725 + 120dacb commit bbd6b2c

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/bin/bindgen.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,16 @@ pub fn main() {
199199
bind_args.push("--".to_owned());
200200
}
201201

202-
// TODO: distinguish C and C++ paths? C++'s should be enough, I guess.
203-
for path in clang.cpp_search_paths.into_iter() {
204-
if let Ok(path) = path.into_os_string().into_string() {
205-
bind_args.push("-isystem".to_owned());
206-
bind_args.push(path);
202+
// If --target is specified, assume caller knows what they're doing and don't mess with
203+
// include paths for them
204+
let has_target_arg = bind_args.iter().rposition(|arg| arg.starts_with("--target")).is_some();
205+
if !has_target_arg {
206+
// TODO: distinguish C and C++ paths? C++'s should be enough, I guess.
207+
for path in clang.cpp_search_paths.into_iter() {
208+
if let Ok(path) = path.into_os_string().into_string() {
209+
bind_args.push("-isystem".to_owned());
210+
bind_args.push(path);
211+
}
207212
}
208213
}
209214
}

src/parser.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,10 @@ impl<'a> ClangParserCtx<'a> {
6868
}
6969
}
7070

71-
fn cursor_link_name(ctx: &mut ClangParserCtx, cursor: &Cursor) -> String {
72-
let mut mangling = cursor.mangling();
73-
71+
fn cursor_link_name(_: &mut ClangParserCtx, cursor: &Cursor) -> String {
7472
// Try to undo backend linkage munging (prepended _, generally)
75-
if cfg!(target_os = "macos") ||
76-
(cfg!(target_os = "windows") && !ctx.options.msvc_mangling)
77-
{
73+
let mut mangling = cursor.mangling();
74+
if cfg!(target_os = "macos") {
7875
mangling.remove(0);
7976
}
8077
mangling

0 commit comments

Comments
 (0)