darkirc: append commit hash to --version output

This commit is contained in:
darkfi
2025-05-11 09:13:59 +02:00
parent e520db743b
commit 29d613fab3
3 changed files with 24 additions and 2 deletions

View File

@@ -16,7 +16,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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"));
}

View File

@@ -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)

View File

@@ -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,
);