summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_gcc/build_system/src/rustc_info.rs
blob: 0988b56d81eb157ca084eae988c5042e129a45f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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_path_buf())
}