Support for macos in detect_targets

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-06-06 22:40:52 +10:00
parent ca5c9b7c23
commit 4157f20b99
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -19,8 +19,10 @@ pub async fn detect_targets() -> Vec<Box<str>> {
{
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<Box<str>> {
if guess_host_triple() == Some(AARCH64) {
vec![AARCH64.into(), X86.into()]
} else {
vec![X86.into()]
}
}
}