Mercurial > core / rust/lib/util/src/bs/version.rs
changeset 698: |
96958d3eb5b0 |
parent: |
3d78bed56188
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
1 use std::{borrow::Cow, process::Command}; 5 /// Generate the `cargo:` key output 6 pub fn generate_cargo_keys() { 7 let output = Command::new("hg").args(["identify", "-i"]).output(); 9 let commit = match output { 10 Ok(o) if o.status.success() => { 11 let sha = String::from_utf8_lossy(&o.stdout).trim().to_owned(); 16 "cargo:warning=Mercurial command failed with status: {}", 22 println!("cargo:warning=Failed to execute hg command: {}", err); 28 "cargo:rustc-env=CORE_VERSION={}", 29 get_version_short(&commit) 32 println!("cargo:rustc-env=CORE_TARGET={}", get_platform()); 35 pub fn get_platform() -> String { 36 let env_dash = if TARGET_ENV.is_some() { "-" } else { "" }; 42 TARGET_ENV.map(|x| x.as_str()).unwrap_or(""), 46 pub fn get_version(impl_commit: &str) -> String { 47 let commit_dash = if impl_commit.is_empty() { "" } else { "-" }; 50 std::env::var("CARGO_PKG_VERSION").unwrap_or_default(), 57 // TODO [2021-09-01 Wed 02:39] - reimpl this function via flag in `get_version` 58 fn get_version_short(impl_commit: &str) -> String { 59 let commit_dash = if impl_commit.is_empty() { "" } else { "-" }; 62 std::env::var("CARGO_PKG_VERSION").unwrap_or_default(),