
# Define the binary file generated by Cargo
BINARY_NAME = moto
TARGET_DIR = target
RELEASE_BIN = $(TARGET_DIR)/release/$(BINARY_NAME)
DEBUG_BIN = $(TARGET_DIR)/debug/$(BINARY_NAME)

# .PHONY: targets that are not files
.PHONY: all build run test fmt clippy check doc clean

# 'all' 
# Builds the optimized version
all: build

# Builds the project in release mode
build:
	@echo "Building release binary..."
	@cargo build --release

# Runs the program (in debug mode)
# Allows passing arguments, e.g.: make run ARGS="parse my_garage1.moto"
run:
	@echo "Running debug binary..."
	@cargo run -- $(ARGS)

# Runs tests
test:
	@echo "Running tests..."
	@cargo test

# Formats the code
fmt:
	@echo "Formatting code..."
	@cargo fmt

# Runs Clippy
clippy:
	@echo "Running Clippy linter..."
	@cargo clippy -- -D warnings

# 'check' 
# It runs everything: formatting, Clippy, and tests
check: fmt clippy test
	@echo "All checks passed!"

# Generates and opens local documentation 
doc:
	@echo "Building and opening documentation..."
	@cargo doc --open

# Cleans build artifacts
clean:
	@echo "Cleaning build artifacts..."
	@cargo clean