From 5566d1ee205ae8b806c7a4d78038c8c2fd596620 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 1 Aug 2020 00:04:27 +0800 Subject: [PATCH] chore: add build.rs --- build.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 build.rs diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..c06ce28 --- /dev/null +++ b/build.rs @@ -0,0 +1,11 @@ +use std::process::Command; + +fn main() { + let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap(); + let git_hash = String::from_utf8(output.stdout).unwrap(); + println!("cargo:rustc-env=GIT_HASH={}", git_hash); + let date_output = Command::new("date").args(&["+%Y-%m-%dT%H:%M:%S%z"]).output().unwrap(); + let date = String::from_utf8(date_output.stdout).unwrap(); + println!("cargo:rustc-env=BUILD_DATE={}", date); +} +