add build.rs for COMMIT environment variable

This commit is contained in:
hinto.janai 2023-12-07 21:15:41 -05:00
parent 76549cf519
commit 7fdd1b71eb
No known key found for this signature in database
GPG key ID: D47CE05FA175A499

15
cuprate/build.rs Normal file
View file

@ -0,0 +1,15 @@
// This sets the git `COMMIT` environment variable.
fn main() {
println!("cargo:rerun-if-changed=../.git/refs/heads/");
let output = std::process::Command::new("git")
.arg("rev-parse")
.arg("HEAD")
.output()
.unwrap();
let commit = String::from_utf8(output.stdout).unwrap();
assert!(commit.len() >= 40);
println!("cargo:rustc-env=COMMIT={commit}");
}