rust/crates/ra_lsp_server/build.rs

16 lines
431 B
Rust
Raw Normal View History

2019-12-09 08:59:04 -06:00
//! Just embed git-hash to `--version`
use std::process::Command;
fn main() {
let rev = rev().unwrap_or_else(|| "???????".to_string());
println!("cargo:rustc-env=REV={}", rev)
}
fn rev() -> Option<String> {
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().ok()?;
let stdout = String::from_utf8(output.stdout).ok()?;
let short_hash = stdout.get(0..7)?;
Some(short_hash.to_owned())
}