Files
radicle-ci-broker/build.rs
T
Lars Wirzenius 15ae4148c9 refactor(build.rs): handle errors without panic
This has no real difference to the user, just makes it easier to find
uses of .expect with grep.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-07-29 14:15:08 +03:00

31 lines
870 B
Rust

// Build acceptance test suite using Subplot.
use std::process::Command;
fn main() {
// Set a build-time `GIT_HEAD` env var which includes the commit id;
// such that we can tell which code is running.
let hash = Command::new("git")
.arg("rev-parse")
.arg("--short")
.arg("HEAD")
.output()
.ok()
.and_then(|output| {
if output.status.success() {
String::from_utf8(output.stdout).ok()
} else {
None
}
})
.unwrap_or_else(|| String::from("unknown"));
println!("cargo:rustc-env=GIT_HEAD={hash}");
println!("cargo:rustc-rerun-if-changed=.git/HEAD");
if let Err(e) = subplot_build::codegen("ci-broker.subplot") {
eprintln!("failed to generate code with Subplot: {e}");
std::process::exit(1);
}
}