Use #env to bake a git revision string into rustc's --version output.

This commit is contained in:
Graydon Hoare 2011-05-06 11:21:51 -07:00
parent 8df37716ce
commit 1e03f00404
2 changed files with 14 additions and 4 deletions

View File

@ -35,6 +35,14 @@ CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt)
CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm)
CFG_STDLIB :=$(call CFG_LIB_NAME,std)
# version-string calculation
CFG_GIT_DIR := $(CFG_SRC_DIR).git
CFG_VERSION := prerelease
ifneq ($(wildcard $(CFG_GIT_DIR)),)
CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \
--pretty=format:'(%h %ci)')
endif
ifdef CFG_OCAMLC_OPT
$(info cfg: have ocaml native compiler)
OPT=.opt
@ -140,6 +148,7 @@ SREQ2 := stage2/rustc$(X) $(LREQ) stage3/glue.o stage3/$(CFG_STDLIB)
######################################################################
export CFG_SRC_DIR
export CFG_VERSION
######################################################################
# Subprograms

View File

@ -127,11 +127,12 @@ fn pretty_print_input(session.session sess,
}
fn version(str argv0) {
auto git_rev = ""; // when snapshotted to extenv: #env("GIT_REV");
if (_str.byte_len(git_rev) != 0u) {
git_rev = #fmt(" (git: %s)", git_rev);
auto vers = "unknown version";
auto env_vers = #env("CFG_VERSION");
if (_str.byte_len(env_vers) != 0u) {
vers = env_vers;
}
io.stdout().write_str(#fmt("%s prerelease%s\n", argv0, git_rev));
io.stdout().write_str(#fmt("%s %s\n", argv0, vers));
}
fn usage(str argv0) {