SHELL := /bin/bash
.PHONY: help all build release test test-default test-all-features \
test-no-default-features fmt fmt-check lint lint-fix doc deny \
msrv package-check check-spanish pre-push check clean release-check
MSRV := $(shell grep -m1 '^rust-version' Cargo.toml | sed -E 's/.*"([^"]*)".*/\1/')
CHECK_SPANISH_CHARS := áéíóúñÁÉÍÓÚÑ¿¡
CHECK_SPANISH_EXCLUDE := src/protocol/escaping.rs src/subscription/update.rs
CHECK_SPANISH_EXCLUDE_RE := $(shell echo $(CHECK_SPANISH_EXCLUDE) | tr ' ' '|')
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-24s\033[0m %s\n", $$1, $$2}'
all: test fmt lint build
build:
cargo build --all-features
release:
cargo build --release --all-features
test-default:
cargo test
test-all-features:
cargo test --all-features
test-no-default-features:
cargo test --no-default-features
test: test-default test-all-features test-no-default-features
fmt:
cargo fmt --all
fmt-check:
cargo fmt --all --check
lint:
cargo clippy --all-targets --all-features -- -D warnings
lint-fix:
cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged -- -D warnings
doc:
RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps
cargo test --doc --all-features
deny:
cargo deny check licenses advisories
msrv:
@if [ -z "$(MSRV)" ]; then echo "could not read rust-version from Cargo.toml"; exit 1; fi
@echo "MSRV (from Cargo.toml): $(MSRV)"
rustup toolchain install $(MSRV) --profile minimal --no-self-update
cargo +$(MSRV) build --all-features
cargo +$(MSRV) test --all-features
package-check:
@list="$$(cargo package --list --allow-dirty)"; \
forbidden="$$(printf '%s\n' "$$list" | grep -E '^(\.claude|\.agents|\.codex|rules)/' || true)"; \
if [ -n "$$forbidden" ]; then \
echo "internal tooling present in the packaged crate:"; \
echo "$$forbidden"; \
exit 1; \
fi; \
count="$$(printf '%s\n' "$$list" | wc -l | tr -d ' ')"; \
echo "package-check: OK ($$count files, no internal tooling)"
check-spanish:
@files="$$(git ls-files 'src/*.rs' 'examples/*.rs' | grep -vE '^($(CHECK_SPANISH_EXCLUDE_RE))$$')"; \
hits="$$(printf '%s\n' "$$files" | xargs rg -n '^[[:space:]]*(///|//!|//)' 2>/dev/null | rg '[$(CHECK_SPANISH_CHARS)]' || true)"; \
if [ -n "$$hits" ]; then \
echo "Spanish characters found in comments:"; \
echo "$$hits"; \
exit 1; \
fi; \
echo "check-spanish: OK"
check: test-default lint fmt-check
pre-push: fmt-check lint test release doc deny msrv package-check check-spanish
@echo "pre-push: all gates passed"
release-check: package-check deny
@version="$$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"([^"]*)".*/\1/')"; \
echo "Cargo.toml version: $$version"; \
case "$$version" in \
1.*) ;; \
*) echo "release-check: version '$$version' is not a 1.x release"; exit 1 ;; \
esac; \
case "$$version" in \
*-*) echo "release-check: version '$$version' still carries a pre-release suffix"; exit 1 ;; \
esac; \
license="$$(grep -m1 '^license' Cargo.toml | sed -E 's/.*"([^"]*)".*/\1/')"; \
if [ "$$license" != "MIT" ]; then echo "release-check: Cargo.toml license is '$$license', expected MIT"; exit 1; fi; \
if [ ! -f LICENSE ]; then echo "release-check: LICENSE file is missing"; exit 1; fi; \
if ! grep -qi "MIT" LICENSE; then echo "release-check: LICENSE does not look like MIT"; exit 1; fi; \
if ! grep -qi "GPL" CHANGELOG.md || ! grep -qi "MIT" CHANGELOG.md; then \
echo "release-check: CHANGELOG.md does not state the MIT relicensing against the GPL history"; exit 1; \
fi; \
list="$$(cargo package --list --allow-dirty)"; \
if ! printf '%s\n' "$$list" | grep -qx "LICENSE"; then \
echo "release-check: LICENSE is not present in \`cargo package --list\`"; exit 1; \
fi; \
echo "release-check: version, license, and packaging OK"
clean:
cargo clean