.PHONY: all build test test-all test-db test-ci docker-ci clean lint fmt install
CARGO := cargo
BIN := ./target/release/promocrypt
all: build test
build:
$(CARGO) build --release
test:
$(CARGO) test
test-all: build
./scripts/test-all.sh
test-db: build
./scripts/test-database.sh
test-ci:
./scripts/simulate-ci.sh
docker-ci:
docker-compose -f docker-compose.test.yml up --build --abort-on-container-exit
lint:
$(CARGO) fmt --check
$(CARGO) clippy -- -D warnings
fmt:
$(CARGO) fmt
clean:
$(CARGO) clean
rm -rf dist/
rm -rf test-results/
build-linux-x86_64:
$(CARGO) build --release --target x86_64-unknown-linux-gnu
build-linux-arm64:
cross build --release --target aarch64-unknown-linux-gnu
build-macos-arm64:
$(CARGO) build --release --target aarch64-apple-darwin
build-macos-x86_64:
$(CARGO) build --release --target x86_64-apple-darwin
build-windows-x86_64:
cross build --release --target x86_64-pc-windows-gnu
package: build
mkdir -p dist
@OS=$$(uname -s | tr '[:upper:]' '[:lower:]'); \
ARCH=$$(uname -m); \
case "$$ARCH" in x86_64|amd64) ARCH="x86_64";; arm64|aarch64) ARCH="arm64";; esac; \
ARTIFACT="promocrypt-$$OS-$$ARCH"; \
mkdir -p "$$ARTIFACT"; \
cp $(BIN) "$$ARTIFACT/"; \
cp README.md LICENSE "$$ARTIFACT/" 2>/dev/null || true; \
mkdir -p "$$ARTIFACT/completions"; \
$(BIN) completions bash > "$$ARTIFACT/completions/promocrypt.bash"; \
$(BIN) completions zsh > "$$ARTIFACT/completions/_promocrypt"; \
$(BIN) completions fish > "$$ARTIFACT/completions/promocrypt.fish"; \
$(BIN) completions powershell > "$$ARTIFACT/completions/_promocrypt.ps1"; \
tar -czvf "dist/$$ARTIFACT.tar.gz" "$$ARTIFACT"; \
rm -rf "$$ARTIFACT"; \
echo "Created: dist/$$ARTIFACT.tar.gz"
install: build
install -m 755 $(BIN) /usr/local/bin/promocrypt
test-one:
$(CARGO) test $(TEST) -- --nocapture
check: fmt lint build
@echo "All checks passed!"
help:
@echo "Available targets:"
@echo " all - Build and run tests (default)"
@echo " build - Build release binary"
@echo " test - Run cargo tests"
@echo " test-all - Run comprehensive test suite"
@echo " test-db - Run database integration tests"
@echo " test-ci - Simulate full CI pipeline"
@echo " docker-ci - Run tests in Docker containers"
@echo " lint - Run format check and clippy"
@echo " fmt - Format code"
@echo " clean - Clean build artifacts"
@echo " package - Create release package"
@echo " install - Install to /usr/local/bin"
@echo " check - Quick check (format, lint, build)"
@echo " help - Show this help"