Merge pull request #199 from NobodyXu/fix-and-improve-windows-target-detection

This commit is contained in:
Félix Saparelli 2022-07-05 21:49:35 +12:00 committed by GitHub
commit f056978858
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -91,9 +91,7 @@ pub async fn detect_targets() -> Vec<String> {
}
#[cfg(target_os = "windows")]
if v[0].contains("gnu") {
v.push(v[0].replace("gnu", "msvc"));
}
v.extend(windows::detect_alternative_targets(&v[0]));
v
} else {
@ -221,12 +219,17 @@ mod windows {
use super::TARGET;
use guess_host_triple::guess_host_triple;
pub(super) fn detect_alternative_targets(target: &str) -> Option<String> {
let (prefix, abi) = target.rsplit_once('-').expect("Invalid target triple");
// detect abi in ["gnu", "gnullvm", ...]
(abi != "msvc").then(|| format!("{prefix}-msvc"))
}
pub(super) fn detect_targets_windows() -> Vec<String> {
let mut targets = vec![guess_host_triple().unwrap_or(TARGET).to_string()];
if targets[0].contains("gnu") {
targets.push(targets[0].replace("gnu", "msvc"));
}
targets.extend(detect_alternative_targets(&targets[0]));
targets
}