From 7fdd1b71ebf9fab9c44705fe42f4ff973f93a57e Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Thu, 7 Dec 2023 21:15:41 -0500 Subject: [PATCH] add `build.rs` for `COMMIT` environment variable --- cuprate/build.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 cuprate/build.rs diff --git a/cuprate/build.rs b/cuprate/build.rs new file mode 100644 index 0000000..f0e8751 --- /dev/null +++ b/cuprate/build.rs @@ -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}"); +}