Skip to content

Commit f18e7fc

Browse files
committed
Added makefile
1 parent a96bbaa commit f18e7fc

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

Makefile

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Makefile for Rust project
2+
3+
# Variables
4+
CARGO := cargo
5+
RUSTFMT := rustfmt
6+
CLIPPY := clippy
7+
TARGET_DIR := target
8+
RELEASE_DIR := $(TARGET_DIR)/release
9+
10+
# Default target
11+
.PHONY: all
12+
all: format lint test build
13+
14+
# Format code using rustfmt
15+
.PHONY: format
16+
format:
17+
@echo "Formatting code..."
18+
$(CARGO) fmt --all
19+
@echo "Formatting complete!"
20+
21+
# Lint code using clippy
22+
.PHONY: lint
23+
lint:
24+
@echo "Linting code..."
25+
$(CARGO) clippy -- -D warnings
26+
@echo "Linting complete!"
27+
28+
# Run tests
29+
.PHONY: test
30+
test:
31+
@echo "Running tests..."
32+
$(CARGO) test
33+
@echo "Tests complete!"
34+
35+
# Build debug version
36+
.PHONY: build
37+
build:
38+
@echo "Building debug version..."
39+
$(CARGO) build
40+
@echo "Debug build complete!"
41+
42+
# Build release version
43+
.PHONY: release
44+
release:
45+
@echo "Building release version..."
46+
$(CARGO) build --release
47+
@echo "Release build complete!"
48+
49+
# Clean build artifacts
50+
.PHONY: clean
51+
clean:
52+
@echo "Cleaning build artifacts..."
53+
$(CARGO) clean
54+
@echo "Clean complete!"
55+
56+
# Check code without building
57+
.PHONY: check
58+
check:
59+
@echo "Checking code..."
60+
$(CARGO) check
61+
@echo "Check complete!"
62+
63+
# Run the program (debug version)
64+
.PHONY: run
65+
run:
66+
@echo "Running program..."
67+
$(CARGO) run
68+
69+
# Run the program (release version)
70+
.PHONY: run-release
71+
run-release:
72+
@echo "Running program (release)..."
73+
$(CARGO) run --release
74+
75+
# Update dependencies
76+
.PHONY: update
77+
update:
78+
@echo "Updating dependencies..."
79+
$(CARGO) update
80+
@echo "Update complete!"
81+
82+
# Generate documentation
83+
.PHONY: doc
84+
doc:
85+
@echo "Generating documentation..."
86+
$(CARGO) doc --no-deps
87+
@echo "Documentation complete!"
88+
89+
# Watch for changes and run tests
90+
.PHONY: watch
91+
watch:
92+
@echo "Watching for changes..."
93+
$(CARGO) watch -x test
94+
95+
# Install cargo tools if needed
96+
.PHONY: install-tools
97+
install-tools:
98+
@echo "Installing cargo tools..."
99+
cargo install cargo-watch
100+
cargo install cargo-clippy
101+
rustup component add rustfmt
102+
rustup component add clippy
103+
@echo "Tools installation complete!"
104+
105+
# Help target
106+
.PHONY: help
107+
help:
108+
@echo "Available targets:"
109+
@echo " all - Format, lint, test, and build"
110+
@echo " format - Format code using rustfmt"
111+
@echo " lint - Lint code using clippy"
112+
@echo " test - Run tests"
113+
@echo " build - Build debug version"
114+
@echo " release - Build release version"
115+
@echo " clean - Clean build artifacts"
116+
@echo " check - Check code without building"
117+
@echo " run - Run the program (debug)"
118+
@echo " run-release - Run the program (release)"
119+
@echo " update - Update dependencies"
120+
@echo " doc - Generate documentation"
121+
@echo " watch - Watch for changes and run tests"
122+
@echo " install-tools- Install required cargo tools"

0 commit comments

Comments
 (0)