Skip to content

support building Miri outside a git repo #1798

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
May 15, 2021
Merged
Show file tree
Hide file tree
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
14 changes: 8 additions & 6 deletions cargo-miri/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::io::{self, BufRead, BufReader, BufWriter, Read, Write};
use std::ops::Not;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::fmt::{Write as _};

use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -90,12 +91,13 @@ fn show_help() {
}

fn show_version() {
println!(
"miri {} ({} {})",
env!("CARGO_PKG_VERSION"),
env!("VERGEN_GIT_SHA_SHORT"),
env!("VERGEN_GIT_COMMIT_DATE")
);
let mut version = format!("miri {}", env!("CARGO_PKG_VERSION"));
// Only use `option_env` on vergen variables to ensure the build succeeds
// when vergen failed to find the git info.
if let Some(sha) = option_env!("VERGEN_GIT_SHA_SHORT") {
write!(&mut version, " ({} {})", sha, option_env!("VERGEN_GIT_COMMIT_DATE").unwrap()).unwrap();
}
println!("{}", version);
}

fn show_error(msg: String) -> ! {
Expand Down
2 changes: 1 addition & 1 deletion cargo-miri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ fn main() {
let mut gen_config = vergen::Config::default();
*gen_config.git_mut().sha_kind_mut() = vergen::ShaKind::Short;
*gen_config.git_mut().commit_timestamp_kind_mut() = vergen::TimestampKind::DateOnly;
vergen(gen_config).expect("Unable to generate vergen keys!");
vergen(gen_config).ok(); // Ignore failure (in case we are built outside a git repo)
}