2018-11-25 20:49:37 +00:00
|
|
|
SHELL=/bin/bash
|
2017-05-21 07:40:31 +00:00
|
|
|
|
|
|
|
# ================================ Cargo ======================================
|
|
|
|
|
|
|
|
|
|
|
|
RUST_CHANNEL ?= stable
|
|
|
|
CARGO_FLAGS =
|
|
|
|
RUSTUP_INSTALLED = $(shell command -v rustup 2> /dev/null)
|
|
|
|
|
|
|
|
ifndef RUSTUP_INSTALLED
|
|
|
|
CARGO = cargo
|
|
|
|
else
|
2017-12-26 17:45:24 +00:00
|
|
|
ifdef CI
|
2017-05-21 07:54:32 +00:00
|
|
|
CARGO = cargo
|
|
|
|
else
|
|
|
|
CARGO = rustup run $(RUST_CHANNEL) cargo
|
|
|
|
endif
|
2017-05-21 07:40:31 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# ================================ Help =======================================
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: help
|
2017-05-21 07:40:31 +00:00
|
|
|
help: ## Print all the available commands
|
|
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
|
|
|
|
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
|
|
|
|
|
|
|
|
|
|
# =============================== Build =======================================
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: check
|
2017-05-21 07:40:31 +00:00
|
|
|
check: ## Validate the project code
|
|
|
|
$(CARGO) check
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: build
|
2017-05-21 07:40:31 +00:00
|
|
|
build: ## Build the project in debug mode
|
|
|
|
$(CARGO) build $(CARGO_FLAGS)
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: release
|
2017-05-21 07:40:31 +00:00
|
|
|
release: CARGO_FLAGS += --release
|
|
|
|
release: build ## Build the project in release mode
|
|
|
|
|
|
|
|
|
|
|
|
# ================================ Lint =======================================
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: lint
|
2017-05-21 07:40:31 +00:00
|
|
|
lint: fmt clippy ## Lint project files
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: fmt
|
2017-05-21 07:40:31 +00:00
|
|
|
fmt: ## Check the format of the source code
|
2018-08-12 22:27:56 +00:00
|
|
|
cargo fmt --all -- --check
|
2017-05-21 07:40:31 +00:00
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: clippy
|
2017-05-21 07:40:31 +00:00
|
|
|
clippy: RUST_CHANNEL = nightly
|
|
|
|
clippy: ## Check the style of the source code and catch common errors
|
2017-05-25 13:17:32 +00:00
|
|
|
$(CARGO) clippy --features="termion rustbox"
|
2017-05-21 07:40:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
# ================================ Test =======================================
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: test
|
2017-05-21 07:40:31 +00:00
|
|
|
test: ## Run the tests
|
2018-09-09 06:53:37 +00:00
|
|
|
$(CARGO) test --features=termion,crossterm
|
|
|
|
|
|
|
|
# =============================== Examples ====================================
|
|
|
|
|
|
|
|
.PHONY: build-examples
|
|
|
|
build-examples: ## Build all examples
|
|
|
|
@$(CARGO) build --examples --features=termion,crossterm
|
|
|
|
|
|
|
|
.PHONY: run-examples
|
|
|
|
run-examples: ## Run all examples
|
|
|
|
@for file in examples/*.rs; do \
|
2018-11-25 20:49:37 +00:00
|
|
|
name=$$(basename $${file/.rs/}); \
|
2018-09-23 18:59:51 +00:00
|
|
|
$(CARGO) run --features=termion,crossterm --example $$name; \
|
2018-09-09 06:53:37 +00:00
|
|
|
done;
|
2017-05-21 07:40:31 +00:00
|
|
|
|
|
|
|
# ================================ Doc ========================================
|
|
|
|
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: doc
|
2017-05-21 07:40:31 +00:00
|
|
|
doc: ## Build the documentation (available at ./target/doc)
|
|
|
|
$(CARGO) doc
|
|
|
|
|
|
|
|
|
|
|
|
# ================================= Watch =====================================
|
|
|
|
|
|
|
|
# Requires watchman and watchman-make (https://facebook.github.io/watchman/docs/install.html)
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: watch
|
2017-05-21 07:40:31 +00:00
|
|
|
watch: ## Watch file changes and build the project if any
|
|
|
|
watchman-make -p 'src/**/*.rs' -t check build
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: watch-test
|
2017-05-21 07:40:31 +00:00
|
|
|
watch-test: ## Watch files changes and run the tests if any
|
2016-11-06 20:41:32 +00:00
|
|
|
watchman-make -p 'src/**/*.rs' 'tests/**/*.rs' 'examples/**/*.rs' -t test
|
2016-11-04 16:54:57 +00:00
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: watch-doc
|
2017-05-21 07:40:31 +00:00
|
|
|
watch-doc: ## Watch file changes and rebuild the documentation if any
|
2016-11-04 16:54:57 +00:00
|
|
|
watchman-make -p 'src/**/*.rs' -t doc
|
2017-05-25 13:18:24 +00:00
|
|
|
|
|
|
|
# ================================= Pipelines =================================
|
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: stable
|
2017-05-25 13:18:24 +00:00
|
|
|
stable: RUST_CHANNEL = stable
|
2017-05-25 13:29:04 +00:00
|
|
|
stable: build test ## Run build and tests for stable
|
2017-05-25 13:18:24 +00:00
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: beta
|
2017-05-25 13:18:24 +00:00
|
|
|
beta: RUST_CHANNEL = beta
|
2017-05-25 13:29:04 +00:00
|
|
|
beta: build test ## Run build and tests for beta
|
2017-05-25 13:18:24 +00:00
|
|
|
|
2018-09-09 06:53:37 +00:00
|
|
|
.PHONY: nightly
|
2017-05-25 13:18:24 +00:00
|
|
|
nightly: RUST_CHANNEL = nightly
|
2018-08-12 22:27:56 +00:00
|
|
|
nightly: build lint test ## Run build, lint and tests for nightly
|