Skip to content

Commit effad62

Browse files
committed
Add the build date to the reported version. #21957
rustc --version says ``` rustc 1.0.0-dev (d0e82a6 2015-02-05) (built 2015-02-11) ```
1 parent d0e82a6 commit effad62

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

mk/main.mk

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ SPACE :=
6161
SPACE +=
6262
ifneq ($(CFG_GIT),)
6363
ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT_DIR))),)
64-
CFG_VER_DATE = $(shell git --git-dir='$(CFG_GIT_DIR)' log -1 --pretty=format:'%ci')
64+
CFG_VER_DATE = $(shell git --git-dir='$(CFG_GIT_DIR)' log -1 --date=short --pretty=format:'%cd')
6565
CFG_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse HEAD)
6666
CFG_SHORT_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse --short=9 HEAD)
6767
CFG_VERSION += ($(CFG_SHORT_VER_HASH) $(CFG_VER_DATE))
6868
endif
6969
endif
7070

71+
CFG_BUILD_DATE = $(shell date +%F)
72+
CFG_VERSION += (built $(CFG_BUILD_DATE))
73+
7174
# Windows exe's need numeric versions - don't use anything but
7275
# numbers and dots here
7376
CFG_VERSION_WIN = $(CFG_RELEASE_NUM)
@@ -317,6 +320,7 @@ endif
317320
ifdef CFG_VER_HASH
318321
export CFG_VER_HASH
319322
endif
323+
export CFG_BUILD_DATE
320324
export CFG_VERSION
321325
export CFG_VERSION_WIN
322326
export CFG_RELEASE

src/librustc_driver/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ pub fn commit_date_str() -> Option<&'static str> {
276276
option_env!("CFG_VER_DATE")
277277
}
278278

279+
pub fn build_date_str() -> Option<&'static str> {
280+
option_env!("CFG_BUILD_DATE")
281+
}
282+
279283
/// Prints version information and returns None on success or an error
280284
/// message on panic.
281285
pub fn version(binary: &str, matches: &getopts::Matches) {
@@ -287,6 +291,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
287291
println!("binary: {}", binary);
288292
println!("commit-hash: {}", unw(commit_hash_str()));
289293
println!("commit-date: {}", unw(commit_date_str()));
294+
println!("build-date: {}", unw(build_date_str()));
290295
println!("host: {}", config::host_triple());
291296
println!("release: {}", unw(release_str()));
292297
}

0 commit comments

Comments
 (0)