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_GOAL := help
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: format
format:
@echo "Formatting Rust files..."
@cargo fmt
.PHONY: test
test: format
@echo "Running tests..."
@DEBUG_SPART=$(DEBUG_SPART) cargo test -- --nocapture
.PHONY: coverage
coverage: format
@echo "Generating test coverage report..."
@DEBUG_SPART=$(DEBUG_SPART) cargo tarpaulin --out Xml --out Html
.PHONY: build
build: format
@echo "Building the project..."
@DEBUG_SPART=$(DEBUG_SPART) cargo build --release
.PHONY: run
run: build
@echo "Running the $(BINARY) binary..."
@DEBUG_SPART=$(DEBUG_SPART) ./$(BINARY)
.PHONY: clean
clean:
@echo "Cleaning up..."
@cargo clean
.PHONY: install-snap
install-snap:
@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
@echo "Installing dependencies..."
@rustup component add rustfmt clippy
@cargo install cargo-tarpaulin
@cargo install cargo-audit
.PHONY: lint
lint: format
@echo "Linting Rust files..."
@DEBUG_SPART=$(DEBUG_SPART) cargo clippy -- -D warnings
.PHONY: publish
publish:
@echo "Publishing the package to Cargo registry..."
@cargo publish --token $(CARGO_REGISTRY_TOKEN)
.PHONY: bench
bench:
@echo "Running benchmarks..."
@DEBUG_SPART=$(DEBUG_SPART) cargo bench
.PHONY: audit
audit:
@echo "Running security audit..."
@cargo audit