1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/// A CPU architecture normalized for release artifact names.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Architecture {
/// 64-bit ARM, named `arm64` by Apple and many package managers.
Arm64,
/// 64-bit x86, named `x86_64` by Rust and Apple.
X86_64,
}
impl Architecture {
/// Return the architecture for the current compilation target.
pub fn current() -> Option<Self> {
match std::env::consts::ARCH {
"aarch64" => Some(Self::Arm64),
"x86_64" => Some(Self::X86_64),
_ => None,
}
}
/// Rust target architecture name.
pub const fn rust(self) -> &'static str {
match self {
Self::Arm64 => "aarch64",
Self::X86_64 => "x86_64",
}
}
/// Apple artifact architecture name.
pub const fn apple(self) -> &'static str {
match self {
Self::Arm64 => "arm64",
Self::X86_64 => "x86_64",
}
}
/// Debian / nfpm architecture name.
pub const fn debian(self) -> &'static str {
match self {
Self::Arm64 => "arm64",
Self::X86_64 => "amd64",
}
}
}