# Makefile for east-asian-width Rust project

.PHONY: help build test check clean generate doc fmt clippy install publish prepare-release

# Default target
help:
	@echo "Available targets:"
	@echo "  build          - Build the library"
	@echo "  test           - Run all tests"
	@echo "  check          - Check code without building"
	@echo "  clean          - Clean build artifacts"
	@echo "  generate       - Generate Unicode lookup tables"
	@echo "  doc            - Generate documentation"
	@echo "  fmt            - Format code"
	@echo "  clippy         - Run clippy linter"
	@echo "  install        - Install the library locally"
	@echo "  publish        - Publish to crates.io (dry-run)"
	@echo "  prepare-release - Prepare for release (format, test, doc)"

# Build the library
build:
	cargo build --release

# Run all tests
test:
	cargo test

# Check code without building
check:
	cargo check

# Clean build artifacts
clean:
	cargo clean
	rm -f src/lookup.rs
	rm -f data/EastAsianWidth.txt

# Generate Unicode lookup tables
generate:
	cargo run --bin generate --features build-deps

# Generate documentation
doc:
	cargo doc --no-deps --open

# Format code
fmt:
	cargo fmt

# Run clippy linter
clippy:
	cargo clippy -- -D warnings

# Install the library locally
install:
	cargo install --path .

# Publish to crates.io (dry-run first)
publish:
	cargo publish --dry-run
	@echo "Run 'cargo publish' to actually publish"

# Prepare for release
prepare-release: fmt clippy test doc
	@echo "Project is ready for release!"
	@echo "Don't forget to:"
	@echo "  1. Update version in Cargo.toml"
	@echo "  2. Update CHANGELOG.md"
	@echo "  3. Commit changes"
	@echo "  4. Create git tag"
	@echo "  5. Run 'make publish'"

# Development workflow
dev: generate test clippy

# CI workflow
ci: fmt clippy test doc

# Quick development check
quick: check test
