-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathbuild.rs
32 lines (30 loc) · 1.11 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::process::Command;
mod datetime;
fn main() -> std::io::Result<()> {
// recording the build date and the git hash
let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.expect("failed to get the git hash");
let git_hash_short = String::from_utf8_lossy(&output.stdout);
let now = datetime::now();
#[allow(deprecated)]
let erg_path = std::env::home_dir().unwrap_or_default().join(".erg");
println!("cargo:rustc-env=GIT_HASH_SHORT={git_hash_short}");
println!("cargo:rustc-env=BUILD_DATE={now}");
println!("cargo:rustc-env=CARGO_ERG_PATH={}", erg_path.display());
let case_sensitive = if cfg!(windows) {
false
} else if cfg!(target_os = "macos") {
let command = Command::new("diskutil")
.args(["info", "/"])
.output()
.expect("failed to get the file system type");
let output = String::from_utf8_lossy(&command.stdout);
output.contains("Case-sensitive")
} else {
true
};
println!("cargo:rustc-env=CASE_SENSITIVE={}", case_sensitive);
Ok(())
}