Skip to content

Commit c5faacc

Browse files
committed
Auto merge of rust-lang#2576 - RalfJung:no-more-vergen, r=RalfJung
2 parents dc5fc32 + d266952 commit c5faacc

File tree

4 files changed

+23
-266
lines changed

4 files changed

+23
-266
lines changed

cargo-miri/Cargo.lock

Lines changed: 7 additions & 247 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cargo-miri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ rustc-workspace-hack = "1.0.0"
3030
serde = { version = "*", features = ["derive"] }
3131

3232
[build-dependencies]
33-
vergen = { version = "7", default_features = false, features = ["git"] }
33+
rustc_tools_util = "0.2"

cargo-miri/build.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
use vergen::vergen;
2-
31
fn main() {
42
// Don't rebuild miri when nothing changed.
53
println!("cargo:rerun-if-changed=build.rs");
6-
// vergen
7-
let mut gen_config = vergen::Config::default();
8-
*gen_config.git_mut().sha_kind_mut() = vergen::ShaKind::Short;
9-
*gen_config.git_mut().commit_timestamp_kind_mut() = vergen::TimestampKind::DateOnly;
10-
vergen(gen_config).ok(); // Ignore failure (in case we are built outside a git repo)
4+
// gather version info
5+
println!(
6+
"cargo:rustc-env=GIT_HASH={}",
7+
rustc_tools_util::get_commit_hash().unwrap_or_default()
8+
);
9+
println!(
10+
"cargo:rustc-env=COMMIT_DATE={}",
11+
rustc_tools_util::get_commit_date().unwrap_or_default()
12+
);
1113
}

cargo-miri/src/phases.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Implements the various phases of `cargo miri run/test`.
22
33
use std::env;
4-
use std::fmt::Write as _;
54
use std::fs::{self, File};
65
use std::io::BufReader;
76
use std::path::PathBuf;
@@ -39,17 +38,13 @@ fn show_help() {
3938
}
4039

4140
fn show_version() {
42-
let mut version = format!("miri {}", env!("CARGO_PKG_VERSION"));
43-
// Only use `option_env` on vergen variables to ensure the build succeeds
44-
// when vergen failed to find the git info.
45-
if let Some(sha) = option_env!("VERGEN_GIT_SHA_SHORT") {
46-
// This `unwrap` can never fail because if VERGEN_GIT_SHA_SHORT exists, then so does
47-
// VERGEN_GIT_COMMIT_DATE.
48-
#[allow(clippy::option_env_unwrap)]
49-
write!(&mut version, " ({} {})", sha, option_env!("VERGEN_GIT_COMMIT_DATE").unwrap())
50-
.unwrap();
41+
print!("miri {}", env!("CARGO_PKG_VERSION"));
42+
let version = format!("{} {}", env!("GIT_HASH"), env!("COMMIT_DATE"));
43+
if version.len() > 1 {
44+
// If there is actually something here, print it.
45+
print!(" ({version})");
5146
}
52-
println!("{}", version);
47+
println!();
5348
}
5449

5550
fn forward_patched_extern_arg(args: &mut impl Iterator<Item = String>, cmd: &mut Command) {

0 commit comments

Comments
 (0)