generated from habedi/template-rust-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (65 loc) · 2.16 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
# Variables
PKG = github.com/habedi/spart
BINARY_NAME = $(or $(PROJ_BINARY), $(notdir $(PKG)))
BINARY = target/release/$(BINARY_NAME)
PATH := /snap/bin:$(PATH)
CARGO_TERM_COLOR = always
DEBUG_SPART = 0
# Default target
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: format
format: ## Format Rust files
@echo "Formatting Rust files..."
cargo fmt
.PHONY: test
test: format ## Run tests
@echo "Running tests..."
DEBUG_SPART=$(DEBUG_SPART) cargo test -- --nocapture
.PHONY: coverage
coverage: format ## Generate test coverage report
@echo "Generating test coverage report..."
DEBUG_SPART=$(DEBUG_SPART) cargo tarpaulin --out Xml --out Html
.PHONY: build
build: format ## Build the binary for the current platform
@echo "Building the project..."
DEBUG_SPART=$(DEBUG_SPART) cargo build --release
.PHONY: run
run: build ## Build and run the binary
@echo "Running the $(BINARY) binary..."
DEBUG_SPART=$(DEBUG_SPART) ./$(BINARY)
.PHONY: clean
clean: ## Remove generated and temporary files
@echo "Cleaning up..."
cargo clean
.PHONY: install-snap
install-snap: ## Install a few dependencies using Snapcraft
@echo "Installing the snap package..."
sudo apt-get update
sudo apt-get install -y snapd
sudo snap refresh
sudo snap install rustup --classic
.PHONY: install-deps
install-deps: install-snap ## Install development dependencies
@echo "Installing dependencies..."
rustup component add rustfmt clippy
cargo install cargo-tarpaulin
cargo install cargo-audit
.PHONY: lint
lint: format ## Run linters on Rust files
@echo "Linting Rust files..."
DEBUG_SPART=$(DEBUG_SPART) cargo clippy -- -D warnings
.PHONY: publish
publish: ## Publish the package to crates.io (requires CARGO_REGISTRY_TOKEN to be set)
@echo "Publishing the package to Cargo registry..."
cargo publish --token $(CARGO_REGISTRY_TOKEN)
.PHONY: bench
bench: ## Run benchmarks
@echo "Running benchmarks..."
DEBUG_SPART=$(DEBUG_SPART) cargo bench
.PHONY: audit
audit: ## Run security audit on Rust dependencies
@echo "Running security audit..."
cargo audit