chore(firmware): stamp builds with UTC time and git hash
Emit BUILD_TIME and BUILD_GIT (git describe --always --dirty) as rustc env vars so the running firmware can identify itself on serial and on-panel. A rerun-if-changed on a nonexistent file forces the script every build, keeping the timestamp fresh. Bring-up lesson: know which build you're diagnosing.
This commit is contained in:
@@ -1,3 +1,27 @@
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
embuild::espidf::sysenv::output();
|
||||
|
||||
// Stamp the binary so serial output and on-panel text identify the
|
||||
// exact build (bring-up lesson: know which build you're diagnosing).
|
||||
let git = Command::new("git")
|
||||
.args(["describe", "--always", "--dirty"])
|
||||
.output()
|
||||
.ok()
|
||||
.filter(|o| o.status.success())
|
||||
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
|
||||
.unwrap_or_else(|| "unknown".into());
|
||||
let time = Command::new("date")
|
||||
.args(["-u", "+%m-%d %H:%M"])
|
||||
.output()
|
||||
.ok()
|
||||
.filter(|o| o.status.success())
|
||||
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
|
||||
.unwrap_or_else(|| "unknown".into());
|
||||
println!("cargo:rustc-env=BUILD_GIT={git}");
|
||||
println!("cargo:rustc-env=BUILD_TIME={time}Z");
|
||||
// Pointing rerun-if-changed at a file that never exists forces this
|
||||
// script to rerun on every build, keeping BUILD_TIME fresh.
|
||||
println!("cargo:rerun-if-changed=.force-build-stamp");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user