1
Fork 0
rust/build_system/src/rustc_info.rs

13 lines
367 B
Rust
Raw Normal View History

2023-08-18 16:06:20 +02:00
use std::path::{Path, PathBuf};
use crate::utils::run_command;
pub fn get_rustc_path() -> Option<PathBuf> {
if let Ok(rustc) = std::env::var("RUSTC") {
return Some(PathBuf::from(rustc));
}
run_command(&[&"rustup", &"which", &"rustc"], None)
.ok()
.map(|out| Path::new(String::from_utf8(out.stdout).unwrap().trim()).to_owned())
}