.PHONY: help fmt check test build build-wasm clean lint all install-tools
.DEFAULT_GOAL := help
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m
help:
@echo "$(BLUE)groth16-proofs - Development Commands$(NC)"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
@echo ""
@echo "$(YELLOW)Common workflows:$(NC)"
@echo " make all - Run all checks (fmt, lint, test)"
@echo " make build - Build native + WASM"
@echo " make dev - Quick dev cycle (fmt, check, test)"
fmt:
@echo "$(BLUE)Formatting code...$(NC)"
cargo fmt --all
fmt-check:
@echo "$(BLUE)Checking formatting...$(NC)"
cargo fmt --all -- --check
lint:
@echo "$(BLUE)Running clippy...$(NC)"
cargo clippy --all-targets --all-features -- -D warnings
test:
@echo "$(BLUE)Running tests...$(NC)"
cargo test --lib --all-features
test-all:
@echo "$(BLUE)Running all tests (including docs)...$(NC)"
cargo test --all-features
test-release:
@echo "$(BLUE)Running tests (release mode)...$(NC)"
cargo test --lib --release --all-features
check: fmt-check lint
@echo "$(GREEN)✓ Code quality checks passed$(NC)"
build:
@echo "$(BLUE)Building native binaries...$(NC)"
cargo build --release
@echo "$(GREEN)✓ generate-proof-from-witness: ./target/release/generate-proof-from-witness$(NC)"
@echo "$(GREEN)✓ convert-vk: ./target/release/convert-vk$(NC)"
build-debug:
@echo "$(BLUE)Building native binary (debug)...$(NC)"
cargo build
build-wasm:
@echo "$(BLUE)Building WASM module...$(NC)"
@command -v wasm-pack >/dev/null 2>&1 || { echo "$(YELLOW)Installing wasm-pack...$(NC)"; curl https://rustwasm.org/wasm-pack/installer/init.sh -sSf | sh; }
wasm-pack build --target web --out-dir ./pkg --release --features wasm
@echo "$(BLUE)Configuring npm package...$(NC)"
@cd pkg && node -e "\
const fs = require('fs');\
const cargoToml = fs.readFileSync('../Cargo.toml', 'utf8');\
const versionMatch = cargoToml.match(/^version\s*=\s*\"(.+)\"/m);\
if (!versionMatch) throw new Error('Could not extract version from Cargo.toml');\
const template = fs.readFileSync('../npm/package.json.template', 'utf8');\
const rendered = template.replace(/__VERSION__/g, versionMatch[1]);\
JSON.parse(rendered);\
fs.writeFileSync('package.json', rendered);\
"
@cp npm/README.md pkg/README.md
@echo "$(GREEN)✓ WASM: ./pkg/@orbinum/groth16-proofs$(NC)"
build-wasm-dev:
@echo "$(BLUE)Building WASM module (dev)...$(NC)"
@command -v wasm-pack >/dev/null 2>&1 || { echo "$(YELLOW)Installing wasm-pack...$(NC)"; curl https://rustwasm.org/wasm-pack/installer/init.sh -sSf | sh; }
wasm-pack build --target web --out-dir ./pkg --dev --features wasm
@echo "$(BLUE)Configuring npm package...$(NC)"
@cd pkg && node -e "\
const fs = require('fs');\
const cargoToml = fs.readFileSync('../Cargo.toml', 'utf8');\
const versionMatch = cargoToml.match(/^version\s*=\s*\"(.+)\"/m);\
if (!versionMatch) throw new Error('Could not extract version from Cargo.toml');\
const template = fs.readFileSync('../npm/package.json.template', 'utf8');\
const rendered = template.replace(/__VERSION__/g, versionMatch[1]);\
JSON.parse(rendered);\
fs.writeFileSync('package.json', rendered);\
"
@cp npm/README.md pkg/README.md
@echo "$(GREEN)✓ WASM (dev): ./pkg/@orbinum/groth16-proofs$(NC)"
build-all: build build-wasm
@echo "$(GREEN)✓ All builds complete$(NC)"
clean:
@echo "$(BLUE)Cleaning build artifacts...$(NC)"
cargo clean
rm -rf pkg/
@echo "$(GREEN)✓ Clean complete$(NC)"
dev: fmt lint test
@echo "$(GREEN)✓ Dev cycle complete$(NC)"
all: fmt lint test build build-wasm
@echo "$(GREEN)✓ All checks passed$(NC)"
install-tools:
@echo "$(BLUE)Installing development tools...$(NC)"
rustup component add rustfmt clippy
@command -v wasm-pack >/dev/null 2>&1 || curl https://rustwasm.org/wasm-pack/installer/init.sh -sSf | sh
@command -v cargo-release >/dev/null 2>&1 || cargo install cargo-release
@echo "$(GREEN)✓ Tools installed$(NC)"
run-example:
@echo "$(BLUE)Ensure witness.json and proving_key.ark are in current directory$(NC)"
./target/release/generate-proof-from-witness witness.json proving_key.ark
deps:
@echo "$(BLUE)Cargo dependencies:$(NC)"
cargo tree
audit:
@echo "$(BLUE)Running security audit...$(NC)"
@command -v cargo-audit >/dev/null 2>&1 || { echo "$(YELLOW)Installing cargo-audit...$(NC)"; cargo install cargo-audit; }
cargo audit
update:
@echo "$(BLUE)Updating dependencies...$(NC)"
cargo update
version:
@echo "$(BLUE)Rust Toolchain:$(NC)"
@rustc --version
@cargo --version
@rustup show active-toolchain
doc:
@echo "$(BLUE)Generating documentation...$(NC)"
cargo doc --no-deps --open