aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mumd/build.rs')
-rw-r--r--mumd/build.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/mumd/build.rs b/mumd/build.rs
new file mode 100644
index 0000000..45cfd4e
--- /dev/null
+++ b/mumd/build.rs
@@ -0,0 +1,25 @@
+use std::process::Command;
+
+fn main() {
+ let version = format!(
+ "{} {}-{}",
+ env!("CARGO_PKG_NAME"),
+ env!("CARGO_PKG_VERSION"),
+ commit_hash(),
+ );
+
+ println!("cargo:rustc-env=VERSION={}", version);
+}
+
+fn commit_hash() -> String {
+ let output = Command::new("git")
+ .arg("show")
+ .arg("--pretty=format:%h") // abbrev hash
+ .current_dir(env!("CARGO_MANIFEST_DIR"))
+ .output();
+ if let Ok(output) = output {
+ String::from_utf8_lossy(&output.stdout).to_string()
+ } else {
+ String::from("???")
+ }
+}