Refactor Makefile install rule

Check for older installation of the tools and only install them if
missing or if the versions don't match
This commit is contained in:
Florian Dehau 2017-05-21 12:07:50 +02:00
parent b2bb24b9d2
commit c42ca05849
3 changed files with 37 additions and 9 deletions

View File

@ -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

View File

@ -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 =======================================

View File

@ -2,8 +2,6 @@
set -eu
make build
make test
if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then
make lint
fi