blob: 78f279f761e060829ddfc70da16cbce84d6a0f72 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
use std::process::Command;
fn main() {
let maybe_hash = commit_hash();
let version = match maybe_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())
}
|