63 lines
1.1 KiB
Rust
63 lines
1.1 KiB
Rust
use crate::rhai::error::SalError;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
pub fn is_osx() -> bool {
|
|
true
|
|
}
|
|
|
|
#[cfg(not(target_os = "macos"))]
|
|
pub fn is_osx() -> bool {
|
|
false
|
|
}
|
|
|
|
#[cfg(target_os = "linux")]
|
|
pub fn is_linux() -> bool {
|
|
true
|
|
}
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
pub fn is_linux() -> bool {
|
|
false
|
|
}
|
|
|
|
#[cfg(target_arch = "aarch64")]
|
|
pub fn is_arm() -> bool {
|
|
true
|
|
}
|
|
|
|
#[cfg(not(target_arch = "aarch64"))]
|
|
pub fn is_arm() -> bool {
|
|
false
|
|
}
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
pub fn is_x86() -> bool {
|
|
true
|
|
}
|
|
|
|
#[cfg(not(target_arch = "x86_64"))]
|
|
pub fn is_x86() -> bool {
|
|
false
|
|
}
|
|
|
|
pub fn check_linux_x86() -> Result<(), SalError> {
|
|
if is_linux() && is_x86() {
|
|
Ok(())
|
|
} else {
|
|
Err(SalError::Generic(
|
|
"Platform Check Error".to_string(),
|
|
"This operation is only supported on Linux x86_64.".to_string(),
|
|
))
|
|
}
|
|
}
|
|
|
|
pub fn check_macos_arm() -> Result<(), SalError> {
|
|
if is_osx() && is_arm() {
|
|
Ok(())
|
|
} else {
|
|
Err(SalError::Generic(
|
|
"Platform Check Error".to_string(),
|
|
"This operation is only supported on macOS ARM.".to_string(),
|
|
))
|
|
}
|
|
} |