Skip to content

Commit 596b223

Browse files
Merge #1052
1052: Update cross-util program name and version. r=Emilgardis a=Alexhuszagh Updates to output of `cross-util --version` to use the program name `cross-util`, and in development builds, add the commit hash (so, for example, the output might be `cross-util 0.2.4 (8d8d84b 2022-09-08)`). The previous output would have been `cross 0.2.4`. Co-authored-by: Alex Huszagh <[email protected]>
2 parents ba06b09 + a1c495b commit 596b223

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ lto = true
6161

6262
[dev-dependencies]
6363
regex = "1"
64-
once_cell = "1"
64+
once_cell = "1.15"
6565
ignore = "0.4"
6666

6767
[package.metadata.release]

src/bin/cross-util.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ use cross::{docker, rustc::Toolchain};
66

77
mod commands;
88

9+
const APP_NAME: &str = "cross-util";
10+
static VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), cross::commit_info!());
11+
912
#[derive(Parser, Debug)]
10-
#[clap(version, about, long_about = None)]
13+
#[clap(about, long_about = None, name = APP_NAME, version = VERSION)]
1114
struct Cli {
1215
/// Toolchain name/version to use (such as stable or 1.59.0).
1316
#[clap(value_parser = is_toolchain)]

src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,10 @@ pub fn run(
501501
msg_info: &mut MessageInfo,
502502
) -> Result<Option<ExitStatus>> {
503503
if args.version && args.subcommand.is_none() {
504-
msg_info.print(format_args!(
505-
concat!("cross ", env!("CARGO_PKG_VERSION"), "{}"),
506-
crate::commit_info()
504+
msg_info.print(concat!(
505+
"cross ",
506+
env!("CARGO_PKG_VERSION"),
507+
crate::commit_info!()
507508
))?;
508509
}
509510

@@ -780,8 +781,15 @@ pub(crate) fn warn_host_version_mismatch(
780781
Ok(VersionMatch::Same)
781782
}
782783

783-
fn commit_info() -> &'static str {
784-
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
784+
pub const fn commit_info() -> &'static str {
785+
commit_info!()
786+
}
787+
788+
#[macro_export]
789+
macro_rules! commit_info {
790+
() => {
791+
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
792+
};
785793
}
786794

787795
/// Obtains the [`CrossToml`] from one of the possible locations

0 commit comments

Comments
 (0)