summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/build.rs b/build.rs
index 63fcf453..13ff411d 100644
--- a/build.rs
+++ b/build.rs
@@ -4,6 +4,7 @@ use std::path::Path;
const LINUX_CLANG_DIRS: &'static [&'static str] = &["/usr/lib", "/usr/lib/llvm", "/usr/lib64/llvm", "/usr/lib/x86_64-linux-gnu"];
const MAC_CLANG_DIR: &'static str = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib";
+const WIN_CLANG_DIRS: &'static [&'static str] = &["C:\\Program Files\\LLVM\\bin", "C:\\Program Files\\LLVM\\lib"];
fn path_exists(path: &Path) -> bool {
match fs::metadata(path) {
@@ -21,16 +22,21 @@ fn main() {
LINUX_CLANG_DIRS.iter().map(ToString::to_string).collect()
} else if cfg!(target_os = "macos") {
vec![MAC_CLANG_DIR.to_string()]
+ } else if cfg!(target_os = "windows") {
+ WIN_CLANG_DIRS.iter().map(ToString::to_string).collect()
} else {
panic!("Platform not supported");
};
- let clang_lib = format!("{}clang{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX);
+ let clang_lib = if cfg!(target_os = "windows") {
+ format!("libclang{}", env::consts::DLL_SUFFIX)
+ } else {
+ format!("{}clang{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX)
+ };
let maybe_clang_dir = possible_clang_dirs.iter().filter_map(|candidate_dir| {
let clang_dir = Path::new(candidate_dir);
let clang_path = clang_dir.join(clang_lib.clone());
-
if path_exists(&*clang_path) {
Some(clang_dir)
} else {
@@ -91,7 +97,8 @@ fn main() {
}
println!("-L {} -l ncursesw -l z -l stdc++", clang_dir.to_str().unwrap());
} else{
- println!("cargo:rustc-flags=-l clang -L {}", clang_dir.to_str().unwrap());
+ println!("cargo:rustc-link-search=native={}", clang_dir.to_str().unwrap());
+ println!("cargo:rustc-link-lib=dylib=clang");
}
} else {
panic!("Unable to find {}", clang_lib);