.PHONY: all build release test coverage lint fmt fmt-check check run install-hooks install uninstall ci publish clean rules-audit deny
INSTALL_PREFIX ?= $(HOME)/.local
INSTALL_BIN := $(INSTALL_PREFIX)/bin
CARGO_TARGET_DIR ?= target
export CARGO_TARGET_DIR
all: check
build:
cargo build
release:
cargo build --release
test:
cargo test
TARPAULIN_PIN := 0.35.2
coverage:
@have=$$(cargo tarpaulin --version 2>/dev/null | awk '{print $$NF}'); \
if [ "$$have" != "$(TARPAULIN_PIN)" ]; then \
echo "tarpaulin $(TARPAULIN_PIN) required (have: $${have:-none}); see tarpaulin.toml" >&2; \
echo " cargo install cargo-tarpaulin --version $(TARPAULIN_PIN) --locked" >&2; \
exit 1; \
fi
cargo tarpaulin --fail-under 100 --skip-clean --engine llvm --out Stdout
lint:
cargo clippy --all-targets -- -D warnings
$(MAKE) rules-audit
$(MAKE) deny
deny:
cargo deny check
rules-audit:
ast-grep scan src
@if ast-grep scan rules/fixtures >/dev/null 2>&1; then \
echo "rules-audit: rules/fixtures was NOT flagged — a rule has regressed" >&2; \
exit 1; \
fi
@echo "rules-audit: src clean; fixtures flagged (all rules live)"
fmt:
cargo fmt
fmt-check:
cargo fmt --check
check: fmt-check lint coverage
run:
@if [ -n "$(WS)" ]; then \
cargo run --quiet -- --workspace "$(WS)"; \
else \
cargo run --quiet; \
fi
install-hooks:
git config core.hooksPath .githooks
@echo "hooks: core.hooksPath -> .githooks"
install: release
@mkdir -p "$(INSTALL_BIN)"
@install -m 0755 $(CARGO_TARGET_DIR)/release/yog "$(INSTALL_BIN)/yog"
@echo "installed $(INSTALL_BIN)/yog"
@echo "note: the window drives the 'lernie' binary; install it from the lernie repo."
uninstall:
@rm -f "$(INSTALL_BIN)/yog" && echo "removed $(INSTALL_BIN)/yog"
ci: check
publish:
cargo publish --dry-run --locked
ifeq ($(CONFIRM),yes)
cargo publish --locked
else
@echo "dry-run passed. Publishing is an explicit decision: re-run with 'make publish CONFIRM=yes'."
endif
clean:
cargo clean