]> git.lizzy.rs Git - rust.git/blob - crates/proc-macro-srv/build.rs
Fixes tests
[rust.git] / crates / proc-macro-srv / build.rs
1 //! Determine rustc version `proc-macro-srv` (and thus the sysroot ABI) is
2 //! build with and make it accessible at runtime for ABI selection.
3
4 use std::{env, fs::File, io::Write, path::PathBuf, process::Command};
5
6 fn main() {
7     let mut path = PathBuf::from(env::var_os("OUT_DIR").unwrap());
8     path.push("rustc_version.rs");
9     let mut f = File::create(&path).unwrap();
10
11     let rustc = env::var("RUSTC").expect("proc-macro-srv's build script expects RUSTC to be set");
12     let output = Command::new(rustc).arg("--version").output().expect("rustc --version must run");
13     let version_string = std::str::from_utf8(&output.stdout[..])
14         .expect("rustc --version output must be UTF-8")
15         .trim();
16
17     write!(
18         f,
19         "
20     #[allow(dead_code)]
21     pub(crate) const RUSTC_VERSION_STRING: &str = {version_string:?};
22     "
23     )
24     .unwrap();
25 }