use std::{
ffi::{OsStr, OsString},
io::BufRead,
process::Command,
};
pub fn host_platform() -> String {
rustc_host_target_triple(&rustc_location())
}
pub fn rustc_location() -> OsString {
std::env::var_os("RUSTC").unwrap_or("rustc".into())
}
pub fn rustc_host_target_triple(rustc_path: &OsStr) -> String {
Command::new(rustc_path)
.arg("-vV")
.output()
.expect("Failed to invoke rustc! Is it in your $PATH?")
.stdout
.lines()
.map(|l| l.unwrap())
.find(|l| l.starts_with("host: "))
.map(|l| l[6..].to_string())
.expect("Failed to parse rustc output to determine the current platform. Please report this bug!")
}