-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
build.rs
22 lines (18 loc) · 802 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::env;
use std::fs;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rustc-check-cfg=cfg(host_os, values(\"windows\"))");
let prettyplease_version = match env::var("DEP_PRETTYPLEASE02_VERSION") {
Ok(prettyplease_version) => format!(r#"Some("{}")"#, prettyplease_version.escape_debug()),
Err(_) => "None".to_owned(),
};
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let prettyplease_version_file = out_dir.join("prettyplease.version");
fs::write(prettyplease_version_file, prettyplease_version).unwrap();
let host = env::var_os("HOST").unwrap();
if let Some("windows") = host.to_str().unwrap().split('-').nth(2) {
println!("cargo:rustc-cfg=host_os=\"windows\"");
}
}