mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-09 05:23:07 +00:00
commit
b7bc720638
14
build.rs
14
build.rs
@ -26,12 +26,22 @@ fn main() {
|
||||
// Try to get hash and date of the last commit on a best effort basis. If anything goes wrong
|
||||
// (git not installed or if this is not a git repository) just return an empty string.
|
||||
fn commit_info() -> String {
|
||||
match (commit_hash(), commit_date()) {
|
||||
(Some(hash), Some(date)) => format!(" ({} {})", hash.trim_right(), date),
|
||||
match (channel(), commit_hash(), commit_date()) {
|
||||
(channel, Some(hash), Some(date)) => {
|
||||
format!("{} ({} {})", channel, hash.trim_right(), date)
|
||||
}
|
||||
_ => String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn channel() -> String {
|
||||
if let Ok(channel) = env::var("CFG_RELEASE_CHANNEL") {
|
||||
channel
|
||||
} else {
|
||||
"nightly".to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
fn commit_hash() -> Option<String> {
|
||||
Command::new("git")
|
||||
.args(&["rev-parse", "--short", "HEAD"])
|
||||
|
@ -385,9 +385,8 @@ fn print_usage_to_stdout(opts: &Options, reason: &str) {
|
||||
|
||||
fn print_version() {
|
||||
let version_info = format!(
|
||||
"{}{}{}",
|
||||
"{}-{}",
|
||||
option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"),
|
||||
"-",
|
||||
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user