Improve find_llvm on MacOS (#1124)
By looking for explicitly versioned Homebrew formulae for LLVM
This commit is contained in:
parent
c8254dbd0e
commit
b96e194812
@ -39,14 +39,23 @@ fn find_llvm_config_brew() -> Result<PathBuf, String> {
|
|||||||
if brew_cellar_location.is_empty() {
|
if brew_cellar_location.is_empty() {
|
||||||
return Err("Empty return from brew --cellar".to_string());
|
return Err("Empty return from brew --cellar".to_string());
|
||||||
}
|
}
|
||||||
let cellar_glob = format!("{brew_cellar_location}/llvm/*/bin/llvm-config");
|
let location_suffix = "*/bin/llvm-config";
|
||||||
let glob_results = glob(&cellar_glob).unwrap_or_else(|err| {
|
let cellar_glob = vec![
|
||||||
panic!("Could not read glob path {} ({err})", &cellar_glob);
|
// location for explicitly versioned brew formulae
|
||||||
|
format!("{brew_cellar_location}/llvm@*/{location_suffix}"),
|
||||||
|
// location for current release brew formulae
|
||||||
|
format!("{brew_cellar_location}/llvm/{location_suffix}"),
|
||||||
|
];
|
||||||
|
let glob_results = cellar_glob.iter().flat_map(|location| {
|
||||||
|
glob(location).unwrap_or_else(|err| {
|
||||||
|
panic!("Could not read glob path {location} ({err})");
|
||||||
|
})
|
||||||
});
|
});
|
||||||
match glob_results.last() {
|
match glob_results.last() {
|
||||||
Some(path) => Ok(path.unwrap()),
|
Some(path) => Ok(path.unwrap()),
|
||||||
None => Err(format!(
|
None => Err(format!(
|
||||||
"No llvm-config found in brew cellar with pattern {cellar_glob}"
|
"No llvm-config found in brew cellar with patterns {}",
|
||||||
|
cellar_glob.join(" ")
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user