summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge (Mutabah) <acessdev@gmail.com>2016-09-28 21:49:44 +0800
committerGitHub <noreply@github.com>2016-09-28 21:49:44 +0800
commit336247fe7101499794cff44e31ee1f794422aab4 (patch)
tree16a6f248d656d6074afb7ce15b07529a19e7a235
parent67244fb57c3b1002dc22ea9fb393e660cb000fd1 (diff)
parentdc1bf11fb48dd7198ed8974d243d54e9dd691126 (diff)
downloadmrust-336247fe7101499794cff44e31ee1f794422aab4.tar.gz
Merge pull request #6 from est31/master
Download rust nightly automatically
-rw-r--r--Makefile22
-rw-r--r--rust-nightly-date1
2 files changed, 16 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 9c4ade8b..feca4d21 100644
--- a/Makefile
+++ b/Makefile
@@ -90,15 +90,16 @@ output/%.ast: samples/%.rs $(BIN)
$(DBG) $(BIN) $< -o $@ $(PIPECMD)
RUSTCSRC := ./rustc-nightly/
+RUSTC_SRC_DL := $(RUSTCSRC)/dl-version
-output/lib%.hir: $(RUSTCSRC)src/lib%/lib.rs $(BIN)
+output/lib%.hir: $(RUSTCSRC)src/lib%/lib.rs $(RUSTCSRC) $(BIN)
@echo "--- [MRUSTC] $@"
@mkdir -p output/
@rm -f $@
$(DBG) $(BIN) $< -o $@ $(PIPECMD)
# # HACK: Work around gdb returning success even if the program crashed
@test -e $@
-output/lib%.hir: $(RUSTCSRC)src/lib%/src/lib.rs $(BIN)
+output/lib%.hir: $(RUSTCSRC)src/lib%/src/lib.rs $(RUSTCSRC) $(BIN)
@echo "--- [MRUSTC] $@"
@mkdir -p output/
@rm -f $@
@@ -113,10 +114,17 @@ output/librand.hir: output/libcore.hir
output/liblibc.hir: output/libcore.hir
output/libstd.hir: output/libcore.hir output/libcollections.hir output/librand.hir output/liblibc.hir output/libunwind.hir
-.PHONY: UPDATE
-UPDATE:
- wget -c https://static.rust-lang.org/dist/rustc-nightly-src.tar.gz
- tar -xf rustc-nightly-src.tar.gz
+$(RUSTCSRC): rust-nightly-date
+ @export DL_RUST_DATE=$$(cat rust-nightly-date); \
+ export DISK_RUST_DATE=$$([ -f $(RUSTC_SRC_DL) ] && cat $(RUSTC_SRC_DL)); \
+ if [ "$$DL_RUST_DATE" != "$$DISK_RUST_DATE" ]; then \
+ echo "Rust version on disk is '$${DISK_RUST_DATE}'. Downloading $${DL_RUST_DATE}."; \
+ rm rustc-nightly-src.tar.gz; \
+ rm -rf rustc-nightly; \
+ wget https://static.rust-lang.org/dist/$${DL_RUST_DATE}/rustc-nightly-src.tar.gz; \
+ tar -xf rustc-nightly-src.tar.gz; \
+ echo "$$DL_RUST_DATE" > $(RUSTC_SRC_DL); \
+ fi
.PHONY: rust_tests
RUST_TESTS_DIR := $(RUSTCSRC)src/test/
@@ -127,7 +135,7 @@ rust_tests-run-pass: $(call DEF_RUST_TESTS,run-pass)
rust_tests-run-fail: $(call DEF_RUST_TESTS,run-fail)
rust_tests-compile-fail: $(call DEF_RUST_TESTS,compile-fail)
-output/rust/%.o: $(RUST_TESTS_DIR)%.rs $(BIN)
+output/rust/%.o: $(RUST_TESTS_DIR)%.rs $(RUSTCSRC) $(BIN)
@mkdir -p $(dir $@)
$(BIN) $< -o $@ --stop-after parse > $@.txt 2>&1
touch $@
diff --git a/rust-nightly-date b/rust-nightly-date
new file mode 100644
index 00000000..02e42b37
--- /dev/null
+++ b/rust-nightly-date
@@ -0,0 +1 @@
+2016-08-23