20 lines
488 B
Rust
20 lines
488 B
Rust
use std::error::Error;
|
|
use vergen::EmitBuilder;
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
// Try to get the git sha from the local git repository
|
|
if EmitBuilder::builder()
|
|
.fail_on_error()
|
|
.git_sha(false)
|
|
.emit()
|
|
.is_err()
|
|
{
|
|
// Unable to get the git sha
|
|
if let Ok(sha) = std::env::var("GIT_SHA") {
|
|
// Set it from an env var
|
|
println!("cargo:rustc-env=VERGEN_GIT_SHA={sha}");
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|