fabro/lib/crates/fabro-cli/build.rs
Bryan Helmkamp 4d925d5d5d refactor(async): lint std::process::Command across all targets
Move async subprocess paths to Tokio or spawn_blocking, document the
intentional synchronous std::process::Command callsites, and make CI run
Clippy with --all-targets so the guardrail applies to test code too.
2026-04-12 13:35:57 -04:00

27 lines
889 B
Rust

#[expect(
clippy::disallowed_methods,
reason = "Build scripts run outside Tokio and need a synchronous git probe for the embedded build SHA."
)]
fn main() {
println!("cargo:rerun-if-changed=../../../.git/HEAD");
let sha = std::process::Command::new("git")
.args(["rev-list", "-1", "HEAD"])
.output()
.ok()
.and_then(|o| {
if o.status.success() {
String::from_utf8(o.stdout)
.ok()
.map(|s| s.trim().to_string())
} else {
None
}
})
.unwrap_or_default();
let short_sha = if sha.len() >= 7 { &sha[..7] } else { &sha };
println!("cargo:rustc-env=FABRO_GIT_SHA={short_sha}");
let build_date = chrono::Utc::now().format("%Y-%m-%d").to_string();
println!("cargo:rustc-env=FABRO_BUILD_DATE={build_date}");
}