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.
|
/// for more information.
|
||||||
pub async fn detect_targets() -> ArrayVec<Box<str>, 2> {
|
pub async fn detect_targets() -> ArrayVec<Box<str>, 2> {
|
||||||
if let Some(target) = get_targets_from_rustc().await {
|
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")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
linux::detect_targets_linux().await
|
linux::detect_targets_linux().await
|
||||||
|
@ -37,6 +48,7 @@ pub async fn detect_targets() -> ArrayVec<Box<str>, 2> {
|
||||||
vec![TARGET.into()]
|
vec![TARGET.into()]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Figure out what the host target is, from rustc or from this program's own build target
|
// Figure out what the host target is, from rustc or from this program's own build target
|
||||||
async fn get_targets_from_rustc() -> Option<Box<str>> {
|
async fn get_targets_from_rustc() -> Option<Box<str>> {
|
||||||
|
@ -139,8 +151,8 @@ mod macos {
|
||||||
use super::{from_array, ArrayVec};
|
use super::{from_array, ArrayVec};
|
||||||
use guess_host_triple::guess_host_triple;
|
use guess_host_triple::guess_host_triple;
|
||||||
|
|
||||||
const AARCH64: &str = "aarch64-apple-darwin";
|
pub(super) const AARCH64: &str = "aarch64-apple-darwin";
|
||||||
const X86: &str = "x86_64-apple-darwin";
|
pub(super) const X86: &str = "x86_64-apple-darwin";
|
||||||
|
|
||||||
pub(super) fn detect_targets_macos() -> ArrayVec<Box<str>, 2> {
|
pub(super) fn detect_targets_macos() -> ArrayVec<Box<str>, 2> {
|
||||||
if guess_host_triple() == Some(AARCH64) {
|
if guess_host_triple() == Some(AARCH64) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue