-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (89 loc) · 2.76 KB
/
Makefile
File metadata and controls
112 lines (89 loc) · 2.76 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Standard Makefile for Rust libraries
# -----------------------------------
# Common usage:
# make # fmt + lint + test + release
# make release # build release artifacts
# make test # run tests
# make fmt # format code
# make lint # clippy (fail on warnings)
# make update-deps # cargo update
# make upgrade-deps # cargo upgrade (needs cargo-edit)
#
# You can override these per-project:
# make FEATURES="foo,bar"
# make WORKSPACE=--workspace
# make CARGO_FLAGS="--all-targets"
CARGO ?= cargo
FEATURES ?=
WORKSPACE ?=
CARGO_FLAGS ?=
# Optional: additional test flags (e.g., TEST_FLAGS=-- --nocapture)
TEST_FLAGS ?=
# Build features flag if FEATURES is set
ifeq ($(strip $(FEATURES)),)
FEATURES_FLAG :=
else
FEATURES_FLAG := --features $(FEATURES)
endif
ALL_FLAGS := $(WORKSPACE) $(CARGO_FLAGS) $(FEATURES_FLAG)
.PHONY: all debug release test fmt lint check doc clean update-deps upgrade-deps ci help
# Default: do the “usual good stuff”
all: fmt lint test release
# --------------------
# Help
# --------------------
help:
@echo "Standard Make targets:"
@echo " make / make all - fmt, lint, test, release"
@echo " make debug - build debug"
@echo " make release - build release"
@echo " make test - run tests"
@echo " make fmt - format code with rustfmt"
@echo " make lint - run clippy (fail on warnings)"
@echo " make check - cargo check (fast compile check)"
@echo " make doc - build docs"
@echo " make ci - fmt, lint, test (CI pipeline)"
@echo " make clean - clean target dir"
@echo " make update-deps - cargo update (lockfile refresh)"
@echo " make upgrade-deps - cargo upgrade (bump dependency versions)"
@echo ""
@echo "You can also override:"
@echo " FEATURES=foo,bar (feature flags)"
@echo " WORKSPACE=--workspace"
@echo " CARGO_FLAGS=... (e.g., --all-targets)"
# --------------------
# Build targets
# --------------------
debug:
$(CARGO) build $(ALL_FLAGS)
release:
$(CARGO) build $(ALL_FLAGS) --release
# --------------------
# Quality & tests
# --------------------
test:
$(CARGO) test $(ALL_FLAGS) $(TEST_FLAGS)
fmt:
$(CARGO) fmt
lint:
$(CARGO) clippy $(ALL_FLAGS) --all-targets -- -D warnings
# “check” is cheaper than a full build, useful for CI
check:
$(CARGO) check $(ALL_FLAGS)
# Full CI pipeline in one target (easy to call from GitHub Actions)
ci: fmt lint test
# --------------------
# Docs
# --------------------
doc:
$(CARGO) doc $(ALL_FLAGS) --no-deps
# --------------------
# Maintenance
# --------------------
clean:
$(CARGO) clean
update-deps:
$(CARGO) update --verbose
# Requires `cargo-edit` (`cargo install cargo-edit`)
upgrade-deps:
$(CARGO) upgrade --verbose