-
Notifications
You must be signed in to change notification settings - Fork 412
Update cross-util program name and version. #1052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5365ed2
to
228b9c3
Compare
diff --git a/Cargo.lock b/Cargo.lock
index 6615045..575a265 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -209,7 +209,6 @@ dependencies = [
"ignore",
"libc",
"nix",
- "once_cell",
"owo-colors",
"regex",
"rustc_version",
diff --git a/Cargo.toml b/Cargo.toml
index 8cfc50a..7535e37 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -47,7 +47,6 @@ walkdir = { version = "2", optional = true }
tempfile = "3.3.0"
owo-colors = { version = "3.5.0", features = ["supports-colors"] }
semver = "1"
-once_cell = "1.15"
[target.'cfg(not(windows))'.dependencies]
nix = { version = "0.25", default-features = false, features = ["user"] }
diff --git a/src/bin/cross-util.rs b/src/bin/cross-util.rs
index a5092e1..cc90a68 100644
--- a/src/bin/cross-util.rs
+++ b/src/bin/cross-util.rs
@@ -3,24 +3,14 @@
use clap::{CommandFactory, Parser, Subcommand};
use cross::shell::MessageInfo;
use cross::{docker, rustc::Toolchain};
-use once_cell::sync::OnceCell;
mod commands;
const APP_NAME: &str = "cross-util";
-static VERSION: OnceCell<String> = OnceCell::new();
-
-fn version() -> &'static str {
- VERSION.get_or_init(|| {
- format!(
- concat!(env!("CARGO_PKG_VERSION"), "{}"),
- cross::commit_info()
- )
- })
-}
+static VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), cross::commit_info!());
#[derive(Parser, Debug)]
-#[clap(about, long_about = None, name = APP_NAME, version = version())]
+#[clap(about, long_about = None, name = APP_NAME, version = VERSION)]
struct Cli {
/// Toolchain name/version to use (such as stable or 1.59.0).
#[clap(value_parser = is_toolchain)]
diff --git a/src/lib.rs b/src/lib.rs
index a79452b..42b91a0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -780,8 +780,15 @@ pub(crate) fn warn_host_version_mismatch(
Ok(VersionMatch::Same)
}
-pub fn commit_info() -> &'static str {
- include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
+pub const fn commit_info() -> &'static str {
+ commit_info!()
+}
+
+#[macro_export]
+macro_rules! commit_info {
+ () => {
+ include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
+ };
}
/// Obtains the [`CrossToml`] from one of the possible locations this works without any added deps |
Even better, on clap 4.0, with the
|
Nice, the clap 4.0 migration will be very handy. I've updated it to move |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Build succeeded: |
Updates to output of
cross-util --version
to use the program namecross-util
, and in development builds, add the commit hash (so, for example, the output might becross-util 0.2.4 (8d8d84b 2022-09-08)
). The previous output would have beencross 0.2.4
.