Skip to content

feat: show extra build description from bootstrap #15269

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

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/cargo/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ pub struct VersionInfo {
///
/// `None` if not built from a git repo.
pub commit_info: Option<CommitInfo>,

/// A descriptive string to be appended to version output.
///
/// This is usually set by the bootstrap in rust-lang/rust
/// via the `CFG_VER_DESCRIPTION` environment variable.
/// Useful for showing vendor build information.
/// For example,
///
/// ```text
/// cargo 1.85.0 (d73d2caf9 2024-12-31) (MyCustomBuild 1.85.0-3)
/// ```
pub description: Option<String>,
}

impl fmt::Display for VersionInfo {
Expand All @@ -30,6 +42,10 @@ impl fmt::Display for VersionInfo {
if let Some(ref ci) = self.commit_info {
write!(f, " ({} {})", ci.short_commit_hash, ci.commit_date)?;
};

if let Some(description) = self.description.as_ref().filter(|d| !d.is_empty()) {
write!(f, " ({description})")?;
};
Ok(())
}
}
Expand Down Expand Up @@ -71,10 +87,12 @@ pub fn version() -> VersionInfo {
commit_hash,
commit_date: option_env_str!("CARGO_COMMIT_DATE").unwrap(),
});
let description = option_env_str!("CFG_VER_DESCRIPTION");

VersionInfo {
version,
release_channel,
commit_info,
description,
}
}