-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
208 lines (165 loc) · 4.91 KB
/
Copy pathMakefile
File metadata and controls
208 lines (165 loc) · 4.91 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
.DEFAULT_GOAL := help
GIT_SHA ?= $(shell git rev-parse HEAD)
GIT_TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev")
BIN_DIR = dist/bin
CARGO_TARGET_DIR ?= target
PROFILE ?= dev
FEATURES ?=
CARGO_INSTALL_EXTRA_FLAGS ?=
##@ Help
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Build
.PHONY: build
build: ## Build the project.
cargo build --features "$(FEATURES)" --profile "$(PROFILE)"
.PHONY: build-release
build-release: ## Build in release mode.
cargo build --features "$(FEATURES)" --profile release
.PHONY: profiling
profiling: ## Build with profiling symbols.
RUSTFLAGS="-C target-cpu=native" cargo build --profile profiling
.PHONY: maxperf
maxperf: ## Build with maximum performance optimizations.
RUSTFLAGS="-C target-cpu=native" cargo build --profile maxperf
##@ Lint
.PHONY: fmt
fmt: ## Run rustfmt (nightly).
cargo +nightly fmt --all
.PHONY: fmt-check
fmt-check: ## Check rustfmt (nightly).
cargo +nightly fmt --all --check
.PHONY: clippy
clippy: ## Run clippy with all features, deny warnings.
cargo +nightly clippy \
--workspace \
--lib \
--examples \
--tests \
--benches \
--all-features \
-- -D warnings
.PHONY: clippy-fix
clippy-fix: ## Run clippy with auto-fix.
cargo +nightly clippy \
--workspace \
--lib \
--examples \
--tests \
--benches \
--all-features \
--fix \
--allow-staged \
--allow-dirty \
-- -D warnings
.PHONY: lint-typos
lint-typos: ensure-typos ## Run typos spell checker.
typos
.PHONY: lint-toml
lint-toml: ensure-dprint ## Format all TOML files.
dprint fmt
.PHONY: lint-toml-check
lint-toml-check: ensure-dprint ## Check TOML formatting.
dprint check
.PHONY: udeps
udeps: ## Check for unused dependencies.
cargo +nightly udeps --workspace --all-features
.PHONY: hack
hack: ## Check feature powerset with cargo-hack.
cargo hack check --workspace --feature-powerset --depth 2
.PHONY: zepter
zepter: ## Check feature propagation with zepter.
zepter run check
.PHONY: lint
lint: ## Run ALL linters (fmt + clippy + typos + toml).
$(MAKE) fmt && \
$(MAKE) clippy && \
$(MAKE) lint-typos && \
$(MAKE) lint-toml
##@ Test
.PHONY: test-unit
test-unit: ## Run unit tests with nextest.
cargo nextest run --workspace --no-fail-fast
.PHONY: test-doc
test-doc: ## Run doc tests.
cargo test --doc --workspace --all-features
.PHONY: test
test: ## Run all tests (unit + doc).
$(MAKE) test-unit && \
$(MAKE) test-doc
.PHONY: test-coverage
test-coverage: ## Run tests with coverage (requires cargo-llvm-cov).
cargo +nightly llvm-cov nextest --lcov --output-path lcov.info --workspace
cargo +nightly llvm-cov report --html
@echo "Coverage report: target/llvm-cov/html/index.html"
##@ Cross-compilation
.PHONY: check-wasm
check-wasm: ## Check compilation for wasm32-wasip1 target.
cargo check --workspace --target wasm32-wasip1
.PHONY: check-riscv
check-riscv: ## Check compilation for riscv32imac-unknown-none-elf target.
cargo check --workspace --target riscv32imac-unknown-none-elf
##@ Security & Dependencies
.PHONY: deny
deny: ## Run cargo-deny checks (advisories, bans, licenses, sources).
cargo deny --all-features check all
.PHONY: audit
audit: ## Run cargo-audit for vulnerabilities.
cargo audit
.PHONY: check-no-test-deps
check-no-test-deps: ## Ensure test-only deps don't leak into production.
@if cargo tree --workspace -e normal,build --no-default-features 2>/dev/null | grep -qE "arbitrary|proptest"; then \
echo "ERROR: Found test-only dependencies in non-dev dependency tree"; \
cargo tree --workspace -e normal,build --no-default-features | grep -E "arbitrary|proptest"; \
exit 1; \
fi
##@ Documentation
.PHONY: docs
docs: ## Build documentation with all features.
RUSTDOCFLAGS="\
--cfg docsrs \
--show-type-layout \
--generate-link-to-definition \
--enable-index-page -Zunstable-options -D warnings" \
cargo +nightly doc \
--workspace \
--all-features \
--no-deps \
--document-private-items
##@ Benchmarks
.PHONY: bench
bench: ## Run all benchmarks.
cargo bench --workspace
##@ CI / PR
.PHONY: pr
pr: ## Run all checks (deny + lint + test + docs).
$(MAKE) deny && \
$(MAKE) lint && \
$(MAKE) udeps && \
$(MAKE) hack && \
$(MAKE) zepter && \
$(MAKE) check-no-test-deps && \
$(MAKE) test && \
$(MAKE) docs
##@ Utility
.PHONY: clean
clean: ## Clean build artifacts.
cargo clean
rm -rf $(BIN_DIR)
.PHONY: fix-lint
fix-lint: ## Auto-fix clippy + reformat.
$(MAKE) clippy-fix && \
$(MAKE) fmt
.PHONY: ensure-typos
ensure-typos:
@command -v typos >/dev/null || { \
echo "typos not found. Install: cargo install --locked typos-cli"; \
exit 1; \
}
.PHONY: ensure-dprint
ensure-dprint:
@command -v dprint >/dev/null || { \
echo "dprint not found. Install: cargo install --locked dprint"; \
exit 1; \
}