mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
support building Miri outside a git repo
This commit is contained in:
parent
bcae3315a7
commit
64f128c456
@ -6,6 +6,7 @@ use std::io::{self, BufRead, BufReader, BufWriter, Read, Write};
|
|||||||
use std::ops::Not;
|
use std::ops::Not;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use std::fmt::{Write as _};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -90,12 +91,13 @@ fn show_help() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn show_version() {
|
fn show_version() {
|
||||||
println!(
|
let mut version = format!("miri {}", env!("CARGO_PKG_VERSION"));
|
||||||
"miri {} ({} {})",
|
// Only use `option_env` on vergen variables to ensure the build succeeds
|
||||||
env!("CARGO_PKG_VERSION"),
|
// when vergen failed to find the git info.
|
||||||
env!("VERGEN_GIT_SHA_SHORT"),
|
if let Some(sha) = option_env!("VERGEN_GIT_SHA_SHORT") {
|
||||||
env!("VERGEN_GIT_COMMIT_DATE")
|
write!(&mut version, " ({} {})", sha, option_env!("VERGEN_GIT_COMMIT_DATE").unwrap()).unwrap();
|
||||||
);
|
}
|
||||||
|
println!("{}", version);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_error(msg: String) -> ! {
|
fn show_error(msg: String) -> ! {
|
||||||
|
@ -7,5 +7,5 @@ fn main() {
|
|||||||
let mut gen_config = vergen::Config::default();
|
let mut gen_config = vergen::Config::default();
|
||||||
*gen_config.git_mut().sha_kind_mut() = vergen::ShaKind::Short;
|
*gen_config.git_mut().sha_kind_mut() = vergen::ShaKind::Short;
|
||||||
*gen_config.git_mut().commit_timestamp_kind_mut() = vergen::TimestampKind::DateOnly;
|
*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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user