summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/proc-macro-srv/build.rs
blob: 9a17cfc9f360d2ad122df853766132a7357fa1ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Determine rustc version `proc-macro-srv` (and thus the sysroot ABI) is
//! build with and make it accessible at runtime for ABI selection.

use std::{env, process::Command};

fn main() {
    println!("cargo::rustc-check-cfg=cfg(rust_analyzer)");

    let rustc = env::var("RUSTC").expect("proc-macro-srv's build script expects RUSTC to be set");
    let output = Command::new(rustc).arg("--version").output().expect("rustc --version must run");
    let version_string = std::str::from_utf8(&output.stdout[..])
        .expect("rustc --version output must be UTF-8")
        .trim();
    println!("cargo::rustc-env=RUSTC_VERSION={}", version_string);
}