Skip to content

Commit aa631f6

Browse files
committed
windows fixes
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
1 parent 2f16ae5 commit aa631f6

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/cargo_cmd.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ impl CargoCmd for Command {
8989
// see https://docs.rs/cc/latest/cc/#external-configuration-via-environment-variables
9090
self.env(format!("CC_{}", triplet.as_ref()), cc.as_ref());
9191
self.env("CLANG_PATH", cc.as_ref());
92+
// In windows, set LIBCLANG_PATH
93+
if let Some(parent) = cc.as_ref().parent() {
94+
if parent.join("libclang.dll").exists() {
95+
self.env("LIBCLANG_PATH", parent.join("libclang.dll"));
96+
} else if parent.join("clang.dll").exists() {
97+
self.env("LIBCLANG_PATH", parent.join("clang.dll"));
98+
}
99+
}
92100
self
93101
}
94102

@@ -163,11 +171,14 @@ impl CargoCmd for Command {
163171
return self;
164172
}
165173

174+
// For some reason we need to escape backslashes on Windows
175+
let flags = flags.as_ref().to_string_lossy().replace("\\", "\\\\");
176+
166177
let mut new_flags = get_env(self, "BINDGEN_EXTRA_CLANG_ARGS").unwrap_or_default();
167178
if !new_flags.is_empty() {
168179
new_flags.push(" ");
169180
}
170-
new_flags.push(flags.as_ref());
181+
new_flags.push(flags);
171182
self.env("BINDGEN_EXTRA_CLANG_ARGS", new_flags);
172183
self
173184
}

src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::env;
22

33
use cargo_hyperlight::cargo;
44

5-
fn main() -> ! {
5+
fn main() {
66
let args = env::args_os().enumerate().filter_map(|(i, arg)| {
77
// skip the binary name and the "hyperlight" subcommand if present
88
if i == 0 || (i == 1 && arg == "hyperlight") {
@@ -15,5 +15,6 @@ fn main() -> ! {
1515
cargo()
1616
.expect("Failed to create cargo command")
1717
.args(args)
18-
.exec()
18+
.status()
19+
.expect("Failed to execute cargo")
1920
}

0 commit comments

Comments
 (0)