Skip to content

Commit

Permalink
Merge pull request rust-lang#242 from dimbleby/canonicalize-clang
Browse files Browse the repository at this point in the history
Make sure that we really have found clang
  • Loading branch information
crabtw committed Dec 8, 2015
2 parents 852e7a3 + cf43c80 commit aab8618
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,24 +263,24 @@ fn builder_state()

// Get the first directory in PATH that contains a file named "clang".
fn get_clang_dir() -> Option<path::PathBuf>{
match env::var_os("PATH") {
Some(paths) => {
for p in env::split_paths(&paths) {
let mut bin_path = p.clone();
bin_path.push("clang");
match fs::metadata(bin_path) {
Ok(m) => {
if m.is_file() {
return Some(p);
}
if let Some(paths) = env::var_os("PATH") {
for mut path in env::split_paths(&paths) {
path.push("clang");
if let Ok(real_path) = fs::canonicalize(&path) {
if fs::metadata(&real_path).iter().any(|m| m.is_file()) &&
real_path
.file_name()
.and_then(|f| f.to_str())
.iter()
.any(|&f| f == "clang") {
if let Some(dir) = real_path.parent() {
return Some(dir.to_path_buf())
}
_ => (),
}
}
None
}
None => None,
}
None
}

// Try to find the directory that contains clang's bundled headers. Clang itself does something
Expand Down

0 comments on commit aab8618

Please sign in to comment.