diff options
author | Jyun-Yan You <jyyou.tw@gmail.com> | 2015-06-27 20:22:08 +0800 |
---|---|---|
committer | Jyun-Yan You <jyyou.tw@gmail.com> | 2015-06-27 20:22:08 +0800 |
commit | 87eed4e2e56ab44660593263973dc48480fa6cb6 (patch) | |
tree | 94e1d72a1ec6451db4e7110454b34dcc8fed86cb | |
parent | ba150d99da9f52bf75751b282ad6c9bd529409f3 (diff) | |
parent | 7bc37ecb76aaf1850e5a9b95284039fcfd29b499 (diff) |
Merge pull request #220 from 9prady9/master
Windows platform fixes
-rw-r--r-- | build.rs | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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); |