geist_supervisor 0.1.28

Generic OTA supervisor for field devices
Documentation
use std::process::Command;

fn main() {
    let git_hash = git_output(&["rev-parse", "HEAD"]).unwrap_or_else(|| "unknown".into());
    let build_date = git_output(&["log", "-1", "--format=%cI"]).unwrap_or_else(|| "unknown".into());

    println!("cargo:rustc-env=GIT_HASH={git_hash}");
    println!("cargo:rustc-env=BUILD_DATE={build_date}");

    // Only re-run when HEAD moves
    println!("cargo:rerun-if-changed=.git/HEAD");
    println!("cargo:rerun-if-changed=.git/refs/");
    println!("cargo:rerun-if-changed=.git/packed-refs");
}

fn git_output(args: &[&str]) -> Option<String> {
    Command::new("git")
        .args(args)
        .output()
        .ok()
        .filter(|o| o.status.success())
        .and_then(|o| String::from_utf8(o.stdout).ok())
        .map(|s| s.trim().to_string())
        .filter(|s| !s.is_empty())
}