mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 04:58:42 +00:00
Refactor: Extract detect_alternative_targets
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
caf6f3930b
commit
ec6f81935c
1 changed files with 8 additions and 6 deletions
|
@ -91,9 +91,7 @@ pub async fn detect_targets() -> Vec<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
if v[0].contains("gnu") {
|
v.extend(windows::detect_alternative_targets(&v[0]));
|
||||||
v.push(v[0].replace("gnu", "msvc"));
|
|
||||||
}
|
|
||||||
|
|
||||||
v
|
v
|
||||||
} else {
|
} else {
|
||||||
|
@ -221,12 +219,16 @@ mod windows {
|
||||||
use super::TARGET;
|
use super::TARGET;
|
||||||
use guess_host_triple::guess_host_triple;
|
use guess_host_triple::guess_host_triple;
|
||||||
|
|
||||||
|
pub(super) fn detect_alternative_targets(target: &str) -> Option<String> {
|
||||||
|
target
|
||||||
|
.contains("gnu")
|
||||||
|
.then(|| target.replace("gnu", "msvc"))
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn detect_targets_windows() -> Vec<String> {
|
pub(super) fn detect_targets_windows() -> Vec<String> {
|
||||||
let mut targets = vec![guess_host_triple().unwrap_or(TARGET).to_string()];
|
let mut targets = vec![guess_host_triple().unwrap_or(TARGET).to_string()];
|
||||||
|
|
||||||
if targets[0].contains("gnu") {
|
targets.extend(windows::detect_alternative_targets(&targets[0]));
|
||||||
targets.push(targets[0].replace("gnu", "msvc"));
|
|
||||||
}
|
|
||||||
|
|
||||||
targets
|
targets
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue