-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (117 loc) · 3.88 KB
/
Copy pathMakefile
File metadata and controls
137 lines (117 loc) · 3.88 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
.PHONY: help install build run test test-rust test-python lint lint-rust lint-python format fmt fmt-rust fmt-python check clean all
help:
@echo "Available targets:"
@echo ""
@echo "Setup & Build:"
@echo " make install - Install dependencies and build Rust extension with uv"
@echo " make build - Build the Rust extension with uv"
@echo " make check - Check code without building (cargo check + ruff check)"
@echo ""
@echo "Run & Test:"
@echo " make run - Run the Python project"
@echo " make test - Run all tests (Rust + Python)"
@echo " make test-rust - Run Rust unit tests only"
@echo " make test-python - Run Python integration tests only"
@echo ""
@echo "Code Quality:"
@echo " make lint - Run all linters (Rust + Python)"
@echo " make lint-rust - Run cargo clippy (Rust linter)"
@echo " make lint-python - Run ruff check (Python linter)"
@echo " make fmt - Format all code (Rust + Python)"
@echo " make fmt-rust - Format Rust code with cargo fmt"
@echo " make fmt-python - Format Python code with ruff"
@echo ""
@echo "Maintenance:"
@echo " make clean - Clean build artifacts"
@echo " make all - Install, build, and run (complete setup)"
@echo ""
@echo "Usage: make [target]"
@echo "Example: make all"
install:
@echo "🔧 Installing dependencies and building Rust extension with uv..."
@echo ""
@echo "Step 1: Syncing Python environment with uv..."
uv sync --all-extras
@echo ""
@echo "Step 2: Building Rust extension with maturin (using uv)..."
cd digits-calculator && unset CONDA_PREFIX && uv run maturin develop --release
@echo ""
@echo "✅ Installation complete!"
build:
@echo "🔨 Building Rust extension with uv..."
cd digits-calculator && unset CONDA_PREFIX && uv run maturin develop --release
@echo "✅ Build complete!"
run:
@echo "🚀 Running the Python project with uv..."
@echo ""
uv run python main.py
test:
@echo "🧪 Running tests..."
@echo ""
@make test-rust
@echo ""
@make test-python
test-rust:
@echo "🦀 Running Rust unit tests (pure math module)..."
cd digits-calculator && cargo test math:: --lib 2>&1
@echo "✅ Rust unit tests passed!"
test-python:
@echo "🐍 Running Python integration tests..."
uv run pytest tests/ -v
@echo "✅ Python tests passed!"
check:
@echo "✅ Checking code without full build..."
@echo ""
@make check-rust
@echo ""
@make check-python
check-rust:
@echo "🦀 Checking Rust code (cargo check)..."
cd digits-calculator && cargo check --release 2>&1
@echo "✅ Rust code check complete!"
check-python:
@echo "🐍 Checking Python code (ruff check)..."
uv run ruff check .
@echo "✅ Python code check complete!"
lint:
@echo "🔍 Running all linters..."
@echo ""
@make lint-rust
@echo ""
@make lint-python
lint-rust:
@echo "🦀 Running cargo clippy (Rust linter)..."
cd digits-calculator && cargo clippy --release -- -D warnings 2>&1
@echo "✅ Rust linting complete!"
lint-python:
@echo "🐍 Running ruff check (Python linter)..."
uv run ruff check .
@echo "✅ Python linting complete!"
format:
@echo "📝 Formatting all code..."
@echo ""
@make fmt-rust
@echo ""
@make fmt-python
fmt:
@make format
fmt-rust:
@echo "🦀 Formatting Rust code with cargo fmt..."
cd digits-calculator && cargo fmt 2>&1
@echo "✅ Rust formatting complete!"
fmt-python:
@echo "🐍 Formatting Python code with ruff..."
uv run ruff format .
@echo "✅ Python formatting complete!"
all: install run
@echo ""
@echo "✅ Project setup and execution complete!"
clean:
@echo "🧹 Cleaning up build artifacts..."
cd digits-calculator && cargo clean
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type d -name ".venv" -exec rm -rf {} + 2>/dev/null || true
rm -f digits-calculator/libdigits_calculator.so
@echo "✅ Cleanup complete!"
.DEFAULT_GOAL := help