diff options
| author | Graydon Hoare <[email protected]> | 2011-05-06 11:21:51 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-05-06 11:21:51 -0700 |
| commit | 1e03f004047668e80ea4e1469addd0484ef48fbc (patch) | |
| tree | 852fa5123f4b03475a87a1930d98c3ab44532e3c | |
| parent | Fix OS X build. (diff) | |
| download | rust-1e03f004047668e80ea4e1469addd0484ef48fbc.tar.xz rust-1e03f004047668e80ea4e1469addd0484ef48fbc.zip | |
Use #env to bake a git revision string into rustc's --version output.
| -rw-r--r-- | Makefile.in | 9 | ||||
| -rw-r--r-- | src/comp/driver/rustc.rs | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/Makefile.in b/Makefile.in index 3daf9e8d..c32ac1e4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index b7bca48a..aef6ef3b 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -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) { |