buster/cli/build.rs

21 lines
725 B
Rust

use chrono::Utc;
use std::process::Command;
fn main() {
// Set the build date
let build_date = Utc::now().format("%Y-%m-%d %H:%M:%S UTC").to_string();
println!("cargo:rustc-env=BUILD_DATE={}", build_date);
// Get the git hash if possible
let git_hash = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.and_then(|output| String::from_utf8(output.stdout).ok())
.unwrap_or_else(|| "unknown".to_string());
println!("cargo:rustc-env=GIT_HASH={}", git_hash.trim());
// Tell cargo to rerun this if any git changes occur
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs/heads/main");
}