1+ # Makefile for Rust project using Cargo
2+
3+ .PHONY : all
4+ all : pre-commit
5+
6+ # Build the project with all features enabled in release mode
7+ .PHONY : build
8+ build :
9+ cargo build --release --all-features
10+
11+ # Update dependencies to their latest compatible versions
12+ .PHONY : update
13+ update :
14+ cargo update
15+
16+ # Run the project with all features enabled in release mode
17+ .PHONY : run
18+ run :
19+ cargo run --release --all-features
20+
21+ # Run all tests with all features enabled
22+ .PHONY : test
23+ test :
24+ cargo test --all-features
25+
26+ # Run benchmarks with all features enabled
27+ .PHONY : bench
28+ bench :
29+ cargo bench --all-features
30+
31+ # Run Clippy linter with nightly toolchain, fixing issues automatically
32+ # and applying strict linting rules
33+ .PHONY : clippy
34+ clippy :
35+ cargo +nightly clippy --fix \
36+ --all-targets \
37+ --all-features \
38+ --allow-dirty \
39+ --allow-staged \
40+ -- -D warnings \
41+ -W clippy::pedantic \
42+ -W clippy::nursery \
43+ -W clippy::unwrap_used \
44+ -W clippy::expect_used
45+
46+ # Format the code using rustfmt with nightly toolchain
47+ .PHONY : fmt
48+ fmt :
49+ cargo +nightly fmt
50+
51+ # Generate documentation for all crates and open it in the browser
52+ .PHONY : doc
53+ doc :
54+ cargo +nightly doc --all-features --no-deps --open
55+
56+ # Generate CHANGELOG.md using git-cliff
57+ .PHONY : cliff
58+ cliff :
59+ git-cliff
60+ git cliff --output CHANGELOG.md
61+
62+ # Check for unused dependencies using cargo-udeps with nightly toolchain
63+ .PHONY : udeps
64+ udeps :
65+ cargo +nightly udeps --all-features
66+
67+ # Update and run udeps to check for unused dependencies
68+ .PHONY : udeps-check
69+ udeps-check :
70+ cargo update
71+ cargo +nightly udeps --all-features
72+
73+ # Build the wasm package
74+ .PHONY : wasm-build
75+ wasm-build :
76+ @echo " Building WASM package..."
77+ (cd option-wasm && wasm-pack build --target web && wasm-pack pack pkg)
78+
79+ # Publish the wasm package to npm
80+ # Note: You must be logged in to npm for this to work (`npm login`)
81+ .PHONY : wasm-publish
82+ wasm-publish : wasm-build
83+ @echo " Publishing WASM package to npm..."
84+ (cd option-wasm/pkg && npm pkg fix && npm pkg set name=" @qntx/option" && npm publish --access public)
85+
86+ # Convenience target to build and publish wasm
87+ .PHONY : wasm
88+ wasm : wasm-publish
89+
90+ # Sync Python environment using uv
91+ .PHONY : uv-sync
92+ uv-sync :
93+ uv venv
94+ uv lock --upgrade
95+ uv sync
96+ maturin build
97+ maturin develop --uv
98+
99+ # Run pre-commit hooks on all files
100+ .PHONY : pre-commit
101+ pre-commit :
102+ $(MAKE ) udeps
103+ $(MAKE ) build
104+ $(MAKE ) test
105+ $(MAKE ) clippy
106+ $(MAKE ) fmt
107+ $(MAKE ) cliff
108+ $(MAKE ) wasm-build
109+ $(MAKE ) uv-sync
0 commit comments