pub const COMPILER_CLASS: &str = if cfg!(target_env = "msvc") {
"msvc"
} else if cfg!(any(target_env = "gnu", target_env = "musl")) {
"gcc"
} else {
"clang"
};
pub const OS_CLASS: &str = if cfg!(target_os = "linux") {
"Linux"
} else if cfg!(target_os = "macos") {
"Darwin"
} else if cfg!(target_os = "windows") {
"WIN32"
} else if cfg!(target_os = "freebsd") {
"freebsd"
} else {
"Unknown"
};
pub const TARGET_ARCH: &str = if cfg!(all(target_os = "linux", target_arch = "x86_64")) {
"linux-x86_64"
} else if cfg!(all(target_os = "linux", target_arch = "aarch64")) {
"linux-aarch64"
} else if cfg!(all(target_os = "linux", target_arch = "arm")) {
"linux-arm"
} else if cfg!(all(target_os = "linux", target_arch = "x86")) {
"linux-x86"
} else if cfg!(all(target_os = "macos", target_arch = "aarch64")) {
"darwin-aarch64"
} else if cfg!(all(target_os = "macos", target_arch = "x86_64")) {
"darwin-x86"
} else if cfg!(all(target_os = "windows", target_arch = "x86_64")) {
"windows-x64"
} else if cfg!(all(target_os = "windows", target_arch = "x86")) {
"win32-x86"
} else {
"unknown"
};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn build_params_are_never_empty() {
assert!(!COMPILER_CLASS.is_empty());
assert!(!OS_CLASS.is_empty());
assert!(!TARGET_ARCH.is_empty());
}
#[test]
#[cfg(all(target_os = "linux", target_arch = "x86_64", target_env = "gnu"))]
fn matches_c_env_data_on_the_reference_platform() {
assert_eq!(COMPILER_CLASS, "gcc");
assert_eq!(OS_CLASS, "Linux");
assert_eq!(TARGET_ARCH, "linux-x86_64");
}
}