-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (57 loc) · 2.56 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
IS_TARPAULIN:=$(shell cargo list | grep tarpaulin)
IS_CI:=$(CI)
IS_SCCACHE:=""
.DEFAULT_GOAL := help
help: ## Show available options with this Makefile
@grep -F -h "##" $(MAKEFILE_LIST) | grep -v grep | awk 'BEGIN { FS = ":.*?##" }; { printf "%-18s %s\n", $$1,$$2 }'
.PHONY: install_sccache
install_sccache: ## Check if sccache is installed, else install it.
ifdef IS_CI
@IS_SCCACHE=$(shell ls $(CI_PROJECT_DIR)/.cargo/bin/ | grep sccache)
else
@IS_SCCACHE=$(shell sh -c 'type -P sccache')
endif
ifndef IS_SCCACHE
@echo "*********** Installing sccache since its not found in the path ***********"
@cargo install sccache
else
@echo "*********** Found sccache in the path. Expect faster builds/tests ***********"
endif
.PHONY: install_tarpaulin
install_tarpaulin: ## Check if tarpaulin is installed, else install it.
ifndef IS_TARPAULIN
@echo "*************** Installing tarpaulin as its not found in the path ***********"
@RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo +nightly install cargo-tarpaulin ;
endif
.PHONY : test-cover
test-cover: install_tarpaulin install_sccache ## Run all the tests with coverage
ifdef IS_CI
@echo "*********** Running coverage command on CI ***********"
@RUSTC_WRAPPER=$(CI_PROJECT_DIR)/.cargo/bin/sccache cargo +nightly tarpaulin --root $(CI_PROJECT_DIR) --exclude-files *.cargo/** --verbose
else
@echo "*********** This is Local server. Running coverage now ***********"
@RUSTC_WRAPPER=$(HOME)/.cargo/bin/sccache cargo +nightly tarpaulin --verbose
endif
.PHONY : test
test: install_sccache ## Run all the tests
ifdef IS_CI
@echo "*********** This is CI server. Running tests now ***********"
@RUSTC_WRAPPER=$(CI_PROJECT_DIR)/.cargo/bin/sccache cargo test --all -- --nocapture
else
@echo "*********** This is Local Machine. Running tests now ***********"
@RUSTC_WRAPPER=$(HOME)/.cargo/bin/sccache cargo test --all -- --nocapture
endif
clean: ## Clean the application
@cargo clean
.PHONY : build_release
build_release: clean test install_sccache ## Create a release build
RUSTC_WRAPPER=$(HOME)/.cargo/bin/sccache RUSTFLAGS='-C link-args=-s' cargo build --release --target=x86_64-unknown-linux-musl
.PHONY : lint
lint: ## Run tests, fmt and clippy on this
touch src/lib.rs && cargo clippy --all && cargo fmt --all
.PHONY : docs
docs: ## Generate the docs for this project. Docs are located in target/doc/test_rs
@cargo doc --no-deps
.PHONY : docs-open
docs-open: docs ## Generate docs and open with xdg-open
@xdg-open target/doc/aiven_rs/index.html