From b08300904958c9db67cf374faa36de047100075f Mon Sep 17 00:00:00 2001 From: Xavier L'Heureux <xavier.lheureux@icloud.com> Date: Thu, 14 Feb 2019 20:35:21 -0500 Subject: [PATCH] Set cargo toolchain in Makefile Add toolchain in Makefile to remove the need to set a system-wide target toolchain but run the test against the right version --- Makefile | 12 +++++++----- examples/run_examples.sh | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index fbeb3b07..5229439e 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ RELEASE = debug DEBUG ?= 0 VENDORED = 0 REDOX ?= 0 +TOOLCHAIN ?= 1.28.0 GIT_REVISION=git_revision.txt SRC=Cargo.toml src/* src/*/* members/* members/*/* @@ -21,6 +22,7 @@ endif ifeq (1,$(REDOX)) undefine ARGSV ARGS += --target x86_64-unknown-redox + TOOLCHAIN = nightly endif .PHONY: all clean distclean install uninstall @@ -30,7 +32,7 @@ ifeq (1,$(REDOX)) mkdir -p .cargo grep redox .cargo/config || cat redox_linker >> .cargo/config endif - cargo build $(ARGS) $(ARGSV) + cargo +$(TOOLCHAIN) build $(ARGS) $(ARGSV) clean: cargo clean @@ -39,10 +41,10 @@ distclean: clean rm -rf vendor vendor.tar.xz .cargo git_revision.txt tests: - cargo test $(ARGSV) - bash examples/run_examples.sh + cargo +$(TOOLCHAIN) test $(ARGSV) + TOOLCHAIN=$(TOOLCHAIN) bash examples/run_examples.sh for crate in members/*; do \ - cargo test $(ARGSV) --manifest-path $$crate/Cargo.toml; \ + cargo +$(TOOLCHAIN) test $(ARGSV) --manifest-path $$crate/Cargo.toml; \ done install: @@ -60,7 +62,7 @@ $(GIT_REVISION): $(VENDOR): mkdir -p .cargo - cargo vendor | head -n -1 > .cargo/config + cargo +$(TOOLCHAIN) vendor | head -n -1 > .cargo/config echo 'directory = "vendor"' >> .cargo/config tar pcfJ vendor.tar.xz vendor rm -rf vendor diff --git a/examples/run_examples.sh b/examples/run_examples.sh index 2a644419..0d427068 100755 --- a/examples/run_examples.sh +++ b/examples/run_examples.sh @@ -13,6 +13,8 @@ PROJECT_DIR=$(dirname $(cargo locate-project | awk -F\" '{print $4}')) EXIT_VAL=0 +: "${TOOLCHAIN:=1.28.0}" + # Some of the examples assume that the working directory is the project root # and it never hurts to force consistency regardless cd $PROJECT_DIR @@ -52,7 +54,7 @@ function check_return_value { } # Build debug binary -cargo build +cargo +$TOOLCHAIN build set +e # Iterate over every Ion script in examples directory -- GitLab