mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-20 12:38:43 +00:00
Add fallbacks for get_targets_from_rustc
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
cce378e2c5
commit
6b764b0b3f
1 changed files with 27 additions and 15 deletions
|
@ -21,9 +21,20 @@ pub const TARGET: &str = env!("TARGET");
|
|||
/// for more information.
|
||||
pub async fn detect_targets() -> ArrayVec<Box<str>, 2> {
|
||||
if let Some(target) = get_targets_from_rustc().await {
|
||||
return from_array([target]);
|
||||
let mut v = from_array([target]);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
if v[0].contains("gnu") {
|
||||
v.push(target.replace("gnu", "musl").into_boxed_str());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
if &*v[0] == macos::AARCH64 {
|
||||
v.push(macos::X86.into());
|
||||
}
|
||||
|
||||
v
|
||||
} else {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
linux::detect_targets_linux().await
|
||||
|
@ -36,6 +47,7 @@ pub async fn detect_targets() -> ArrayVec<Box<str>, 2> {
|
|||
{
|
||||
vec![TARGET.into()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out what the host target is, from rustc or from this program's own build target
|
||||
|
@ -139,8 +151,8 @@ mod macos {
|
|||
use super::{from_array, ArrayVec};
|
||||
use guess_host_triple::guess_host_triple;
|
||||
|
||||
const AARCH64: &str = "aarch64-apple-darwin";
|
||||
const X86: &str = "x86_64-apple-darwin";
|
||||
pub(super) const AARCH64: &str = "aarch64-apple-darwin";
|
||||
pub(super) const X86: &str = "x86_64-apple-darwin";
|
||||
|
||||
pub(super) fn detect_targets_macos() -> ArrayVec<Box<str>, 2> {
|
||||
if guess_host_triple() == Some(AARCH64) {
|
||||
|
|
Loading…
Add table
Reference in a new issue