diff --git a/bin/darkirc/build.rs b/bin/darkirc/build.rs index 2873f96c5..8030da6ba 100644 --- a/bin/darkirc/build.rs +++ b/bin/darkirc/build.rs @@ -16,7 +16,20 @@ * along with this program. If not, see . */ +use std::process::Command; + fn main() { + let output = Command::new("git") + .args(["rev-parse", "--short", "HEAD"]) + .output(); + + if let Ok(output) = output { + if output.status.success() { + let commitish = String::from_utf8_lossy(&output.stdout); + println!("cargo:rustc-env=COMMITISH={}", commitish.trim()); + } + } + if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" { println!("cargo:rustc-link-search={}/sqlcipher", env!("CARGO_MANIFEST_DIR")); } diff --git a/bin/darkirc/src/main.rs b/bin/darkirc/src/main.rs index 642c55727..ef12e450b 100644 --- a/bin/darkirc/src/main.rs +++ b/bin/darkirc/src/main.rs @@ -66,7 +66,11 @@ fn panic_hook(panic_info: &std::panic::PanicHookInfo) { #[derive(Clone, Debug, Deserialize, StructOpt, StructOptToml)] #[serde(default)] -#[structopt(name = "darkirc", about = cli_desc!())] +#[structopt( + name = "darkirc", + about = cli_desc!(), + version = concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMITISH")) +)] struct Args { #[structopt(short, parse(from_occurrences))] /// Increase verbosity (-vvv supported) diff --git a/src/lib.rs b/src/lib.rs index 87df9c3c5..8bc559ef3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,10 +63,15 @@ pub const ANSI_LOGO: &str = include_str!("../contrib/darkfi.ansi"); #[macro_export] macro_rules! cli_desc { () => {{ + let commitish = match option_env!("COMMITISH") { + Some(c) => &format!("-{}", c), + None => "" + }; let desc = format!( - "{} {}\n{}\n{}", + "{} {}\n{}{}\n{}", env!("CARGO_PKG_NAME").to_string(), env!("CARGO_PKG_VERSION").to_string(), + commitish, env!("CARGO_PKG_DESCRIPTION").to_string(), darkfi::ANSI_LOGO, );