aboutsummaryrefslogtreecommitdiffstats
path: root/mumctl/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mumctl/build.rs')
-rw-r--r--mumctl/build.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/mumctl/build.rs b/mumctl/build.rs
new file mode 100644
index 0000000..0a4f506
--- /dev/null
+++ b/mumctl/build.rs
@@ -0,0 +1,19 @@
+use std::process::Command;
+
+fn main() {
+ let version = match commit_hash().as_deref() {
+ None | Some("") => format!("v{}", env!("CARGO_PKG_VERSION")),
+ Some(version) => version.to_string(),
+ };
+
+ println!("cargo:rustc-env=VERSION={}", version);
+}
+
+fn commit_hash() -> Option<String> {
+ let output = Command::new("git")
+ .arg("describe")
+ .arg("--tags")
+ .current_dir(env!("CARGO_MANIFEST_DIR"))
+ .output();
+ output.ok().map(|o| String::from_utf8_lossy(&o.stdout).to_string())
+}