aboutsummaryrefslogtreecommitdiffstats
path: root/cli/template/build.rs
diff options
context:
space:
mode:
authormurilo ijanc2025-11-20 17:03:54 -0300
committermurilo ijanc2025-11-20 17:03:54 -0300
commitefda331aa8bf3fb18f7cea38418e5952f02852f2 (patch)
tree9c2f8d25b5788d19fe75ba92df9b6a8ab313cd88 /cli/template/build.rs
parentcd7cf0434f173b3ac135f2678ab38d1bc82f19c4 (diff)
downloadtemplates-efda331aa8bf3fb18f7cea38418e5952f02852f2.tar.gz
Add template cli
Diffstat (limited to 'cli/template/build.rs')
-rw-r--r--cli/template/build.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/cli/template/build.rs b/cli/template/build.rs
new file mode 100644
index 0000000..52cbd9f
--- /dev/null
+++ b/cli/template/build.rs
@@ -0,0 +1,21 @@
+use std::process::Command;
+
+fn main() {
+ let git_hash = Command::new("git")
+ .args(["rev-parse", "HEAD"])
+ .output()
+ .map(|out| String::from_utf8_lossy(&out.stdout).trim().to_string())
+ .unwrap_or_else(|_| "unknown".into());
+
+ let git_date = Command::new("git")
+ .args(["show", "-s", "--format=%cI", "HEAD"])
+ .output()
+ .map(|out| String::from_utf8_lossy(&out.stdout).trim().to_string())
+ .unwrap_or_else(|_| "unknown".into());
+
+ println!("cargo:rustc-env=GIT_HASH={}", git_hash);
+ println!("cargo:rustc-env=BUILD_DATE={}", git_date);
+
+ println!("cargo:rerun-if-changed=.git/HEAD");
+ println!("cargo:rerun-if-changed=.git/refs/heads");
+}