Skip to content

Commit

Permalink
fix(config builder): allow missing extensions for compiler executable…
Browse files Browse the repository at this point in the history
…s on windows
  • Loading branch information
WillLillis committed Nov 20, 2024
1 parent 9f28d49 commit 8e6e48e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions asm-lsp/config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,38 @@ fn is_executable(path: &Path) -> bool {
if let Some(ext) = path.extension().and_then(|s| s.to_str()) {
return extensions.contains(&ext);
}
// On Windows, it's valid to omit file extensions, i.e. `gcc` can be
// used to designate `gcc.exe`
for ext in &extensions {
let Some(path) = path.to_str() else {
continue;
};
let ext_path = PathBuf::from(format!("{path}.{ext}"));
if ext_path.exists() {
return true;
}
}
false
}
} else {
#[cfg(windows)]
{
// On Windows, it's valid to omit file extensions, i.e. `gcc` can be
// used to designate `gcc.exe`. However, this will cause `.is_file()`
// to return `false`, so we need to check for this case here rather
// than above
let extensions = ["exe", "cmd", "bat", "com"];
for ext in &extensions {
let Some(path) = path.to_str() else {
continue;
};
let ext_path = PathBuf::from(format!("{path}.{ext}"));
if ext_path.exists() && ext_path.is_file() {
println!("Warning: Extended provided path with \".{ext}\" in order to find valid compiler");
return true;
}
}
}
false
}
}
Expand Down

0 comments on commit 8e6e48e

Please sign in to comment.