forked from tikv/raft-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (76 loc) · 3.29 KB
/
Makefile
File metadata and controls
88 lines (76 loc) · 3.29 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Makefile
## Additionaly arguments passed to cargo.
EXTRA_CARGO_ARGS ?=
## How to test stable toolchain.
## - auto: use current default toolchain, disable nightly features.
## - force: explicitly use stable toolchain, disable nightly features.
WITH_STABLE_TOOLCHAIN ?=
WITH_NIGHTLY_FEATURES =
ifeq (,$(filter $(WITH_STABLE_TOOLCHAIN),auto force))
WITH_NIGHTLY_FEATURES = 1
endif
TOOLCHAIN_ARGS =
ifeq ($(shell (rustc --version | grep -q nightly); echo $$?), 1)
ifdef WITH_NIGHTLY_FEATURES
# Force use nightly toolchain if we are building with nightly features.
TOOLCHAIN_ARGS = +nightly
endif
else
ifeq ($(WITH_STABLE_TOOLCHAIN), force)
TOOLCHAIN_ARGS = +stable
endif
endif
BIN_PATH = $(CURDIR)/bin
CARGO_TARGET_DIR ?= $(CURDIR)/target/
export RUST_LOG=info
.PHONY: clean format clippy test
.PHONY: ctl
all: format clippy test
clean:
cargo clean
rm -rf ${BIN_PATH}
## Format code in-place using rustfmt.
format:
cargo ${TOOLCHAIN_ARGS} fmt --all
CLIPPY_WHITELIST += -A clippy::bool_assert_comparison
CMAKE_COMPAT := CMAKE="$(CURDIR)/scripts/cmake-wrapper.sh"
## Run clippy.
clippy:
# Fresh lockfile resolution can pull grpcio/grpcio-sys versions that fail on
# macOS arm64 CI images. Force compatible selections before linting.
@if cargo ${TOOLCHAIN_ARGS} tree --all-features -i 'grpcio@0.13.0' >/dev/null 2>&1; then \
cargo ${TOOLCHAIN_ARGS} update -p grpcio@0.13.0 --precise 0.10.2; \
fi
@if cargo ${TOOLCHAIN_ARGS} tree --all-features -i 'grpcio-sys@0.10.1+1.44.0' >/dev/null 2>&1; then \
cargo ${TOOLCHAIN_ARGS} update -p grpcio-sys@0.10.1+1.44.0 --precise 0.10.3+1.44.0-patched; \
fi
ifdef WITH_NIGHTLY_FEATURES
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} clippy --all --features nightly_group,failpoints --all-targets -- -D clippy::all ${CLIPPY_WHITELIST}
else
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} clippy --all --features failpoints --all-targets -- -D clippy::all ${CLIPPY_WHITELIST}
endif
## Run tests.
test:
ifdef WITH_NIGHTLY_FEATURES
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} test --all --features nightly_group ${EXTRA_CARGO_ARGS} -- --nocapture
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} test --test failpoints --features nightly_group,failpoints ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
else
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} test --all ${EXTRA_CARGO_ARGS} -- --nocapture
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} test --test failpoints --features failpoints ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
endif
## Run tests with various features for maximum code coverage.
ifndef WITH_NIGHTLY_FEATURES
test_matrix:
$(error Must run test matrix with nightly features. Please reset WITH_STABLE_TOOLCHAIN.)
else
test_matrix: test
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} test --all ${EXTRA_CARGO_ARGS} -- --nocapture
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} test --test failpoints --features failpoints ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} test --all --features nightly_group,std_fs ${EXTRA_CARGO_ARGS} -- --nocapture
${CMAKE_COMPAT} cargo ${TOOLCHAIN_ARGS} test --test failpoints --features nightly_group,std_fs,failpoints ${EXTRA_CARGO_ARGS} -- --test-threads 1 --nocapture
endif
## Build raft-engine-ctl.
ctl:
cargo build --release --package raft-engine-ctl
@mkdir -p ${BIN_PATH}
@cp -f ${CARGO_TARGET_DIR}/release/raft-engine-ctl ${BIN_PATH}/