mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 12:38:43 +00:00
detect-targets: Add support of MacOS universal binary (#552)
* Add support for MacOS universal bin * Refactor: Extract new fn `macos::detect_alternative_targets` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
26b28dc63f
commit
62e350eba9
2 changed files with 16 additions and 8 deletions
|
@ -42,9 +42,7 @@ pub async fn detect_targets() -> Vec<String> {
|
||||||
v.push(v[0].replace("gnu", "musl"));
|
v.push(v[0].replace("gnu", "musl"));
|
||||||
}
|
}
|
||||||
} else if #[cfg(target_os = "macos")] {
|
} else if #[cfg(target_os = "macos")] {
|
||||||
if &*v[0] == macos::AARCH64 {
|
v.extend(macos::detect_alternative_targets(&v[0]));
|
||||||
v.push(macos::X86.into());
|
|
||||||
}
|
|
||||||
} else if #[cfg(target_os = "windows")] {
|
} else if #[cfg(target_os = "windows")] {
|
||||||
v.extend(windows::detect_alternative_targets(&v[0]));
|
v.extend(windows::detect_alternative_targets(&v[0]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,25 @@
|
||||||
use crate::TARGET;
|
use crate::TARGET;
|
||||||
use guess_host_triple::guess_host_triple;
|
use guess_host_triple::guess_host_triple;
|
||||||
|
|
||||||
pub(super) const AARCH64: &str = "aarch64-apple-darwin";
|
const AARCH64: &str = "aarch64-apple-darwin";
|
||||||
pub(super) const X86: &str = "x86_64-apple-darwin";
|
const X86: &str = "x86_64-apple-darwin";
|
||||||
|
const UNIVERSAL: &str = "universal-apple-darwin";
|
||||||
|
|
||||||
|
pub(super) fn detect_alternative_targets(target: &str) -> impl Iterator<Item = String> {
|
||||||
|
match target {
|
||||||
|
AARCH64 => [Some(X86), Some(UNIVERSAL)],
|
||||||
|
X86 => [Some(UNIVERSAL), None],
|
||||||
|
_ => [None, None],
|
||||||
|
}
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.map(ToString::to_string)
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn detect_targets_macos() -> Vec<String> {
|
pub(super) fn detect_targets_macos() -> 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] == AARCH64 {
|
targets.extend(detect_alternative_targets(&targets[0]));
|
||||||
targets.push(X86.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
targets
|
targets
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue