From 4157f20b99c29681531f25a2c161b76bf4103366 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Mon, 6 Jun 2022 22:40:52 +1000 Subject: [PATCH] Support for macos in `detect_targets` Signed-off-by: Jiahao XU --- src/target.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/target.rs b/src/target.rs index 4c6f8f57..24b0e3e9 100644 --- a/src/target.rs +++ b/src/target.rs @@ -19,8 +19,10 @@ pub async fn detect_targets() -> Vec> { { return linux::detect_targets_linux().await; } - - todo!() + #[cfg(target_os = "macos")] + { + macos::detect_targets_macos() + } } #[cfg(target_os = "linux")] @@ -95,3 +97,19 @@ mod linux { target.into_boxed_str() } } + +#[cfg(target_os = "macos")] +mod macos { + use guess_host_triple::guess_host_triple; + + const AARCH64: &str = "aarch64-apple-darwin"; + const X86: &str = "x86_64-apple-darwin"; + + pub(super) fn detect_targets_macos() -> Vec> { + if guess_host_triple() == Some(AARCH64) { + vec![AARCH64.into(), X86.into()] + } else { + vec![X86.into()] + } + } +}