CARGO ?= cargo
BIN := rq
.DEFAULT_GOAL := help
.PHONY: help build release install uninstall test check dogfood bench recall fuzz lint fmt clean
help:
@echo "rq targets:"
@echo " make build dev build → target/debug/$(BIN)"
@echo " make release optimized build → target/release/$(BIN)"
@echo " make install cargo install --path . (→ ~/.cargo/bin)"
@echo " make uninstall cargo uninstall $(BIN)"
@echo " make test cargo test"
@echo " make check pre-push gate: fmt + clippy + tests"
@echo " make dogfood run rq on real source (Q=<query>, REPO=<path>, ARGS=<flags>)"
@echo " make bench search-latency benchmark (REPO=. by default)"
@echo " make recall fuzzy-ranking recall on pinned corpora (BASE=<ref>, ARGS=<flags>)"
@echo " make fuzz name index vs scorer on random names (N=<names>, SEED=<n>)"
@echo " make lint cargo fmt --check && cargo clippy"
@echo " make fmt cargo fmt"
@echo " make clean cargo clean"
build:
$(CARGO) build
release:
$(CARGO) build --release
install:
$(CARGO) install --path .
uninstall:
$(CARGO) uninstall $(BIN)
test:
$(CARGO) test
check:
@script/check.sh
REPO ?= .
Q ?= Store
ARGS ?=
DOGFOOD_DB := $(CURDIR)/target/dogfood.db
dogfood: build
@rm -f "$(DOGFOOD_DB)" "$(DOGFOOD_DB)-wal" "$(DOGFOOD_DB)-shm"
@RQ_DB="$(DOGFOOD_DB)" ./target/debug/$(BIN) --index "$(REPO)" >/dev/null
@cd "$(REPO)" && RQ_DB="$(DOGFOOD_DB)" $(CURDIR)/target/debug/$(BIN) $(Q) $(ARGS)
bench:
RQ_BENCH_REPO="$(REPO)" $(CARGO) test --release search_latency -- --ignored --nocapture
BASE ?=
recall: release
@CARGO="$(CARGO)" script/recall.py $(if $(BASE),--base $(BASE)) $(ARGS)
N ?= 20000
SEED ?= $(shell od -An -N6 -tu8 /dev/urandom | tr -d ' ')
fuzz:
@echo "fuzz: $(N) names, SEED=$(SEED)"
@RQ_FUZZ_NAMES=$(N) RQ_FUZZ_SEED=$(SEED) $(CARGO) test --release --lib \
the_index_takes_exactly_what_score_accepts_on_random_names
lint:
$(CARGO) fmt --check
$(CARGO) clippy --all-targets -- -D warnings
fmt:
$(CARGO) fmt
clean:
$(CARGO) clean