-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
86 lines (70 loc) · 3.08 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Makefile using cargo for managing builds and dependencies in a Rust project.
# Default target executed when no arguments are given to make.
.PHONY: all
all: help ## Display this help.
# Build the project including all workspace members.
.PHONY: build
build: ## Build the project.
@echo "Building all project components..."
@cargo build --all
# Lint the project with stringent rules using Clippy, install Clippy if not present.
.PHONY: lint
lint: ensure-clippy ## Lint the project with Clippy.
@echo "Linting with Clippy..."
@cargo clippy --all-features --all-targets --all -- \
--deny clippy::dbg_macro --deny clippy::unimplemented --deny clippy::todo --deny warnings \
--deny missing_docs --deny broken_intra_doc_links --forbid unused_must_use --deny clippy::result_unit_err
# Run all unit and integration tests in the project.
.PHONY: test
test: ## Run tests for the project.
@echo "Running tests..."
@cargo test
# Check the project for errors without producing outputs.
.PHONY: check
check: ## Check the project for errors without producing outputs.
@echo "Checking code formatting..."
@cargo check
# Format all code in the project according to rustfmt's standards, install rustfmt if not present.
.PHONY: format
format: ensure-rustfmt ## Format the code.
@echo "Formatting all project components..."
@cargo fmt --all
# Check code formatting without making changes, with verbose output, install rustfmt if not present.
.PHONY: format-check-verbose
format-check-verbose: ensure-rustfmt ## Check code formatting with verbose output.
@echo "Checking code format with verbose output..."
@cargo fmt --all -- --check --verbose
# Apply fixes to the project using cargo fix, install cargo-fix if necessary.
.PHONY: fix
fix: ensure-cargo-fix ## Automatically fix Rust lint warnings using cargo fix.
@echo "Applying cargo fix..."
@cargo fix --all
# Use cargo-deny to check for security vulnerabilities, licensing issues, and more, install if not present.
.PHONY: deny
deny: ensure-cargo-deny ## Run cargo deny checks.
@echo "Running cargo deny checks..."
@cargo deny check
# Check for outdated dependencies only for the root package, install cargo-outdated if necessary.
.PHONY: outdated
outdated: ensure-cargo-outdated ## Check for outdated dependencies for the root package only.
@echo "Checking for outdated dependencies..."
@cargo outdated --root-deps-only
# Installation checks and setups
.PHONY: ensure-clippy ensure-rustfmt ensure-cargo-fix ensure-cargo-deny ensure-cargo-outdated
ensure-clippy:
@cargo clippy --version || rustup component add clippy
ensure-rustfmt:
@cargo fmt --version || rustup component add rustfmt
ensure-cargo-fix:
@cargo fix --version || rustup component add rustfix
ensure-cargo-deny:
@command -v cargo-deny || cargo install cargo-deny
ensure-cargo-outdated:
@command -v cargo-outdated || cargo install cargo-outdated
# Help target to display callable targets and their descriptions.
.PHONY: help
help: ## Display this help.
@echo "Usage: make [target]..."
@echo ""
@echo "Targets:"
@awk 'BEGIN {FS = ":.*?##"} /^[a-zA-Z_-]+:.*?##/ {printf " %-30s %s\n", $$1, $$2}' $(MAKEFILE_LIST)