#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Platform {
pub tag: &'static str,
pub triple: &'static str,
pub os: &'static str,
}
pub const ALL: &[Platform] = &[
Platform {
tag: "linux-x86_64",
triple: "x86_64-unknown-linux-gnu",
os: "linux",
},
Platform {
tag: "linux-aarch64",
triple: "aarch64-unknown-linux-gnu",
os: "linux",
},
Platform {
tag: "windows-x86_64",
triple: "x86_64-pc-windows-gnu",
os: "windows",
},
Platform {
tag: "macos-x86_64",
triple: "x86_64-apple-darwin",
os: "macos",
},
Platform {
tag: "macos-aarch64",
triple: "aarch64-apple-darwin",
os: "macos",
},
];
pub fn host_tag() -> String {
format!(
"{}{}{}",
std::env::consts::OS,
crate::sep::HYPHEN,
std::env::consts::ARCH
)
}
pub fn host() -> Option<&'static Platform> {
by_tag(&host_tag())
}
pub fn by_tag(tag: &str) -> Option<&'static Platform> {
ALL.iter().find(|p| p.tag == tag)
}