mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 14:28:42 +00:00
Fix x86_64 fallback for aarch64 MacOS (#875)
This commit is contained in:
parent
9c617c2f8a
commit
a22cb3a332
2 changed files with 23 additions and 3 deletions
|
@ -61,7 +61,7 @@ pub async fn detect_targets() -> Vec<String> {
|
|||
|
||||
cfg_if! {
|
||||
if #[cfg(target_os = "macos")] {
|
||||
targets.extend(macos::detect_alternative_targets(&targets[0]));
|
||||
targets.extend(macos::detect_alternative_targets(&targets[0]).await);
|
||||
} else if #[cfg(target_os = "windows")] {
|
||||
targets.extend(windows::detect_alternative_targets(&targets[0]));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,30 @@
|
|||
use std::{io, process::Stdio};
|
||||
|
||||
use tokio::process::Command;
|
||||
|
||||
const AARCH64: &str = "aarch64-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> {
|
||||
async fn is_x86_64_supported() -> io::Result<bool> {
|
||||
let exit_status = Command::new("arch")
|
||||
.args(["-arch", "x86_64", "/usr/bin/true"])
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()?
|
||||
.wait()
|
||||
.await?;
|
||||
|
||||
Ok(exit_status.success())
|
||||
}
|
||||
|
||||
pub(super) async fn detect_alternative_targets(target: &str) -> impl Iterator<Item = String> {
|
||||
match target {
|
||||
AARCH64 => [Some(X86), Some(UNIVERSAL)],
|
||||
AARCH64 => [
|
||||
is_x86_64_supported().await.unwrap_or(false).then_some(X86),
|
||||
Some(UNIVERSAL),
|
||||
],
|
||||
X86 => [Some(UNIVERSAL), None],
|
||||
_ => [None, None],
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue