diff options
Diffstat (limited to 'mumctl/build.rs')
| -rw-r--r-- | mumctl/build.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mumctl/build.rs b/mumctl/build.rs new file mode 100644 index 0000000..45cfd4e --- /dev/null +++ b/mumctl/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("???") + } +} |
