From eba1c032ae3a01ab4c975fcdd9dcf58f0fed8c40 Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Mon, 29 Aug 2022 13:29:38 +0200 Subject: [PATCH] Add build commit hash to eww --version --- crates/eww/build.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 crates/eww/build.rs diff --git a/crates/eww/build.rs b/crates/eww/build.rs new file mode 100644 index 0000000..f6e6768 --- /dev/null +++ b/crates/eww/build.rs @@ -0,0 +1,16 @@ +use std::process::Command; +fn main() { + let output = Command::new("git").args(&["rev-parse", "HEAD"]).output(); + if let Ok(output) = output { + if let Ok(hash) = String::from_utf8(output.stdout) { + println!("cargo:rustc-env=GIT_HASH={}", hash); + println!("cargo:rustc-env=CARGO_PKG_VERSION={} {}", env!("CARGO_PKG_VERSION"), hash); + } + } + let output = Command::new("git").args(&["show", "-s", "--format=%ci"]).output(); + if let Ok(output) = output { + if let Ok(date) = String::from_utf8(output.stdout) { + println!("cargo:rustc-env=GIT_COMMIT_DATE={}", date); + } + } +}