.PHONY: help all clean test build release lint typecheck fmt check-fmt check-ripgrep check-static-regexes check-verification-ledger check-prover-tools verus-install verus verus-selftest verus-mutation markdownlint nixie mutants
APP ?= mdtablefix
CARGO ?= $(or $(shell command -v cargo 2>/dev/null),$(HOME)/.cargo/bin/cargo)
BUILD_JOBS ?=
MUTANTS_JOBS ?= 3
MUTANTS_TMPDIR ?= $(HOME)/.cache/mdtablefix/mutants/$(notdir $(CURDIR))
CLIPPY_FLAGS ?= --workspace --all-targets --all-features -- -D warnings
MDLINT ?= $(shell command -v markdownlint-cli2 2>/dev/null || printf '%s' "$$HOME/.bun/bin/markdownlint-cli2")
MDTABLEFIX ?= mdtablefix
MDTABLEFIX_SELECT = --git --include-untracked
MDTABLEFIX_RULES = --wrap --renumber --breaks --ellipsis --fences
NIXIE ?= nixie
RG ?= rg
PROVER_TOOLS ?= uvx --from git+https://github.com/leynos/rust-prover-tools@$(shell cat tools/rust-prover-tools/REF) prover-tools
VERUS_RUN ?= env -u RUSTUP_TOOLCHAIN $(PROVER_TOOLS) verus run --repo-root .
build: target/debug/$(APP)
release: target/release/$(APP)
all: release
clean:
$(CARGO) clean
test:
RUSTFLAGS="-D warnings" $(CARGO) test --workspace --all-targets --all-features $(BUILD_JOBS)
RUSTFLAGS="-D warnings" $(CARGO) test --workspace --doc --all-features $(BUILD_JOBS)
target/%/$(APP):
$(CARGO) build $(BUILD_JOBS) $(if $(findstring release,$(@)),--release) --bin $(APP)
lint: check-static-regexes check-verification-ledger
$(CARGO) clippy $(CLIPPY_FLAGS)
typecheck:
$(CARGO) check --workspace --all-targets --all-features $(BUILD_JOBS)
fmt:
$(CARGO) fmt --all
$(MDTABLEFIX) --in-place $(MDTABLEFIX_SELECT) $(MDTABLEFIX_RULES)
$(MDLINT) --fix "**/*.md"
check-fmt:
$(CARGO) fmt --all -- --check
$(MDTABLEFIX) --check $(MDTABLEFIX_SELECT) $(MDTABLEFIX_RULES)
check-ripgrep:
@command -v "$(firstword $(RG))" >/dev/null 2>&1 || { \
echo "ripgrep (rg) is required for static-regex linting" >&2; \
exit 1; \
}
check-static-regexes: check-ripgrep
@RG='$(RG)' scripts/check-static-regexes.sh .
check-verification-ledger: check-ripgrep
@RG='$(RG)' scripts/check-verification-ledger.sh .
check-prover-tools:
@command -v "$(firstword $(PROVER_TOOLS))" >/dev/null 2>&1 || { \
echo "prover-tools runner ($(firstword $(PROVER_TOOLS))) is required for Verus verification" >&2; \
exit 1; \
}
verus-install: check-prover-tools
$(PROVER_TOOLS) verus install --repo-root .
verus: verus-install
$(VERUS_RUN) --proof-file verus/lib.rs
verus-selftest: verus-install
@output="$$(mktemp)"; \
if $(VERUS_RUN) --proof-file verus/smoke.rs >"$$output" 2>&1; then \
cat "$$output"; \
rm -f "$$output"; \
echo "Verus smoke proof unexpectedly succeeded" >&2; \
exit 1; \
fi; \
if ! grep -Fq "Verus proofs failed" "$$output"; then \
cat "$$output"; \
rm -f "$$output"; \
echo "Verus smoke proof did not reach the verifier" >&2; \
exit 1; \
fi; \
cat "$$output"; \
rm -f "$$output"
verus-mutation: verus-install
VERUS_RUN='$(VERUS_RUN)' scripts/check-classifier-mutation.sh .
markdownlint:
$(MDLINT) "**/*.md"
nixie:
nixie --no-sandbox
mutants:
@ @ @ @ @ @ @ @mkdir -p $(MUTANTS_TMPDIR)
TMPDIR=$(MUTANTS_TMPDIR) $(CARGO) mutants -j $(MUTANTS_JOBS)
help:
@grep -E '^[a-zA-Z_-]+:.*?##' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS=":"; printf "Available targets:\n"} {printf " %-20s %s\n", $$1, $$2}'