firmware: do not lose the ".dirty" suffix in build versions.

Fixes #1074.
This commit is contained in:
whitequark 2018-06-21 05:18:51 +00:00
parent 095ee28fd9
commit 7cc3da4faf
1 changed files with 6 additions and 9 deletions

View File

@ -1,24 +1,21 @@
extern crate walkdir; extern crate walkdir;
use std::env; use std::env;
use std::fs::File; use std::fs;
use std::io::Write;
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process::Command;
use walkdir::WalkDir; use walkdir::WalkDir;
pub fn git_describe() { pub fn git_describe() {
let git_dir = Path::new("../../../.git"); let git_checkout = Path::new("../../..");
for entry in WalkDir::new(git_checkout) {
println!("cargo:rerun-if-changed={}", git_dir.join("HEAD").display());
for entry in WalkDir::new(git_dir.join("refs")) {
let entry = entry.unwrap(); let entry = entry.unwrap();
println!("cargo:rerun-if-changed={}", entry.path().display()); println!("cargo:rerun-if-changed={}", entry.path().display());
} }
let version; let version;
if git_dir.exists() { if git_checkout.join(".git").exists() {
let git_describe = let git_describe =
Command::new("git") Command::new("git")
.arg("describe") .arg("describe")
@ -43,6 +40,6 @@ pub fn git_describe() {
} }
let out_dir = env::var("OUT_DIR").unwrap(); let out_dir = env::var("OUT_DIR").unwrap();
let mut f = File::create(Path::new(&out_dir).join("git-describe")).unwrap(); let git_describe = Path::new(&out_dir).join("git-describe");
write!(f, "{}", version).unwrap(); fs::write(&git_describe, version).unwrap();
} }