diff --git a/.travis.yml b/.travis.yml index 4ca5b060..f0416a99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,9 @@ rust: - beta - nightly +env: + - NO_RUSTUP=1 + cache: cargo matrix: @@ -13,7 +16,7 @@ matrix: - rust: beta before_script: - - NO_RUSTUP=1 ./scripts/travis/before_script.sh + - ./scripts/travis/before_script.sh script: - - NO_RUSTUP=1 ./scripts/travis/script.sh + - ./scripts/travis/script.sh diff --git a/Makefile b/Makefile index 9c4b3477..7137b459 100644 --- a/Makefile +++ b/Makefile @@ -30,18 +30,45 @@ help: ## Print all the available commands # ================================ Tools ====================================== -CLIPPY_VERSION = 0.0.134 -RUSTFMT_VERSION = 0.8.4 - install: install-rustfmt install-clippy ## Install tools dependencies +RUSTFMT_TARGET_VERSION = 0.8.4 +RUSTFMT = $(shell command -v rustfmt 2> /dev/null) +ifeq ("$(RUSTFMT)","") + RUSTFMT_INSTALL_CMD = @echo "Installing rustfmt $(RUSTFMT_TARGET_VERSION)" \ + && $(CARGO) install --vers $(RUSTFMT_TARGET_VERSION) --force rustfmt +else + RUSTFMT_CURRENT_VERSION = $(shell rustfmt --version | sed 's/^\(.*\) ()/\1/') + ifeq ($(RUSTFMT_CURRENT_VERSION),$(RUSTFMT_TARGET_VERSION)) + RUSTFMT_INSTALL_CMD = @echo "Rustfmt is up to date" + else + RUSTFMT_INSTALL_CMD = @echo "Updating rustfmt from $(RUSTFMT_CURRENT_VERSION) to $(RUSTFMT_TARGET_VERSION)" \ + && $(CARGO) install --vers $(RUSTFMT_TARGET_VERSION) --force rustfmt + endif +endif + install-rustfmt: RUST_CHANNEL = nightly install-rustfmt: ## Intall rustfmt - $(CARGO) install --vers $(RUSTFMT_VERSION) --force rustfmt + $(RUSTFMT_INSTALL_CMD) + + +CLIPPY_TARGET_VERSION = 0.0.134 +CLIPPY_CURRENT_VERSION = $(shell $(CARGO) clippy --version 2>/dev/null) +ifeq ("$(CLIPPY_CURRENT_VERSION)","") + CLIPPY_INSTALL_CMD = @echo "Installing clippy $(CLIPPY_TARGET_VERSION)" \ + && $(CARGO) install --vers $(CLIPPY_TARGET_VERSION) --force clippy +else + ifeq ($(CLIPPY_CURRENT_VERSION),$(CLIPPY_TARGET_VERSION)) + CLIPPY_INSTALL_CMD = @echo "Clippy is up to date" + else + CLIPPY_INSTALL_CMD = @echo "Updating clippy from $(CLIPPY_CURRENT_VERSION) to $(CLIPPY_TARGET_VERSION)" \ + && $(CARGO) install --vers $(CLIPPY_TARGET_VERSION) --force clippy + endif +endif install-clippy: RUST_CHANNEL = nightly install-clippy: ## Install clippy - $(CARGO) install --vers $(CLIPPY_VERSION) --force clippy + $(CLIPPY_INSTALL_CMD) # =============================== Build ======================================= diff --git a/scripts/travis/script.sh b/scripts/travis/script.sh index bb8c739b..0b89774e 100755 --- a/scripts/travis/script.sh +++ b/scripts/travis/script.sh @@ -2,8 +2,6 @@ set -eu -make build -make test if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then make lint fi