From 021624a757cf3842ea0facbf3f7ed5633db9fded Mon Sep 17 00:00:00 2001 From: "Mitchell R. Vollger" Date: Wed, 11 Dec 2024 11:10:35 -0800 Subject: [PATCH] fix version string --- build.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index b21b9f22..db72d5a2 100644 --- a/build.rs +++ b/build.rs @@ -7,10 +7,21 @@ fn vergen() -> Result<(), Box> { let build = BuildBuilder::all_build()?; let git2 = Git2Builder::all_git()?; - Emitter::default() + let status = Emitter::default() .add_instructions(&build)? .add_instructions(&git2)? - .emit()?; + .fail_on_error() + .emit(); + // if the status is an error set the version in a custom way + if let Err(e) = status { + let version = env!("CARGO_PKG_VERSION"); + eprintln!("Using CARGO version instead of git version: {}", version); + eprintln!("Vergen error: {}", e); + // set the env variable VERGEN_GIT_DESCRIBE using the CARO_PKG_VERSION + std::env::set_var("VERGEN_GIT_DESCRIBE", version); + } + + //.emit()?; Ok(()) }