diff --git a/bin/build.rs b/bin/build.rs new file mode 100644 index 00000000..3686e48b --- /dev/null +++ b/bin/build.rs @@ -0,0 +1,12 @@ +pub fn main() { + let mut base = env!("CARGO_PKG_VERSION").to_string(); + if option_env!("CI").is_none() { + base.push_str("-local"); + } else if option_env!("RELEASE").is_none() { + base.push_str("-dev"); + } + if cfg!(debug_assertions) { + base.push_str("-debug"); + } + println!("cargo:rustc-env=HEMTT_VERSION={}", base); +} diff --git a/bin/src/lib.rs b/bin/src/lib.rs index 854ff012..4f451cbd 100644 --- a/bin/src/lib.rs +++ b/bin/src/lib.rs @@ -24,18 +24,7 @@ pub fn cli() -> Command { #[allow(unused_mut)] let mut global = Command::new(env!("CARGO_PKG_NAME")) .about(env!("CARGO_PKG_DESCRIPTION")) - .version({ - let mut base = env!("CARGO_PKG_VERSION").to_string(); - if option_env!("CI").is_none() { - base.push_str("-local"); - } else if option_env!("RELEASE").is_none() { - base.push_str("-dev"); - } - if cfg!(debug_assertions) { - base.push_str("-debug"); - } - Box::leak(Box::new(base)).as_str() - }) + .version(env!("HEMTT_VERSION")) .subcommand_required(false) .arg_required_else_help(true) .subcommand(commands::new::cli()) @@ -111,7 +100,7 @@ pub fn execute(matches: &ArgMatches) -> Result<(), Error> { } } - trace!("version: {}", env!("CARGO_PKG_VERSION")); + trace!("version: {}", env!("HEMTT_VERSION")); trace!("platform: {}", std::env::consts::OS); if let Some(threads) = matches.get_one::("threads") {