My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/development/tools/cargo-workspace2/build.rs

26 lines
724 B

use std::{env, fs::File, io::Write, path::PathBuf, process::Command};
fn main() {
let rustc_path = env::var("CARGO_WS2_RUSTC").unwrap_or_else(|_| "rustc".into());
let version = Command::new(rustc_path)
.arg("-V")
.output()
.expect("failed to get rustc version. Is rustc in $PATH?")
.stdout;
let out_path = PathBuf::new();
let mut f = File::create(
out_path
.join(env::var("OUT_DIR").unwrap())
.join("rustc.version"),
)
.unwrap();
f.write_all(
String::from_utf8(version)
.expect("Invalid rustc command return")
.replace("\"", "")
.trim()
.as_bytes(),
)
.unwrap();
}