Store target arch as HOST_ARCH
const, use this as default value for
`Package` struct
This commit is contained in:
parent
a58150cc9c
commit
7d6376d5c4
@ -1,7 +1,18 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{fmt, str::FromStr, error::Error};
|
use std::{fmt, str::FromStr, error::Error};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize)]
|
#[cfg(target_arch = "arm")]
|
||||||
|
pub const HOST_ARCH: Arch = Arch::armv7l;
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
pub const HOST_ARCH: Arch = Arch::aarch64;
|
||||||
|
#[cfg(target_arch = "x86")]
|
||||||
|
pub const HOST_ARCH: Arch = Arch::i486;
|
||||||
|
#[cfg(target_arch = "riscv64")]
|
||||||
|
pub const HOST_ARCH: Arch = Arch::riscv64;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
pub const HOST_ARCH: Arch = Arch::x86_64;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub enum Arch {
|
pub enum Arch {
|
||||||
armv7l,
|
armv7l,
|
||||||
@ -10,10 +21,15 @@ pub enum Arch {
|
|||||||
i586,
|
i586,
|
||||||
i686,
|
i686,
|
||||||
riscv64,
|
riscv64,
|
||||||
#[default]
|
|
||||||
x86_64,
|
x86_64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Arch {
|
||||||
|
fn default() -> Self {
|
||||||
|
HOST_ARCH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for Arch {
|
impl fmt::Display for Arch {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", match self {
|
write!(f, "{}", match self {
|
||||||
|
Loading…
Reference in New Issue
Block a user