run_make_support/
targets.rsuse std::panic;
use crate::command::Command;
use crate::env_var;
use crate::util::handle_failed_output;
#[must_use]
pub fn target() -> String {
env_var("TARGET")
}
#[must_use]
pub fn is_windows() -> bool {
target().contains("windows")
}
#[must_use]
pub fn is_msvc() -> bool {
target().contains("msvc")
}
#[must_use]
pub fn is_darwin() -> bool {
target().contains("darwin")
}
#[must_use]
pub fn is_aix() -> bool {
target().contains("aix")
}
#[must_use]
pub fn apple_os() -> &'static str {
if target().contains("darwin") {
"macos"
} else if target().contains("ios") {
"ios"
} else if target().contains("tvos") {
"tvos"
} else if target().contains("watchos") {
"watchos"
} else if target().contains("visionos") {
"visionos"
} else {
panic!("not an Apple OS")
}
}
#[must_use]
pub fn llvm_components_contain(component: &str) -> bool {
env_var("LLVM_COMPONENTS").split_whitespace().find(|s| s == &component).is_some()
}
#[track_caller]
#[must_use]
pub fn uname() -> String {
let caller = panic::Location::caller();
let mut uname = Command::new("uname");
let output = uname.run();
if !output.status().success() {
handle_failed_output(&uname, output, caller.line());
}
output.stdout_utf8()
}