CARGO ?= cargo
SMHASHER3_DIR ?= $(HOME)/Development/smhasher3
PKG_FFI := axhash-ffi
PKG_CORE := axhash-core
PKG_RUST := axhash
.DEFAULT_GOAL := help
.PHONY: help
help:
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m<target>\033[0m\n"} \
/^[a-zA-Z][a-zA-Z0-9_-]*:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 } \
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) }' $(MAKEFILE_LIST)
.PHONY: version
version:
@grep -E '^version =' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/Workspace version: \1/'
.PHONY: build
build:
$(CARGO) build --workspace --release
.PHONY: check
check:
$(CARGO) check --workspace --all-targets
.PHONY: ffi
ffi:
$(CARGO) build --release -p $(PKG_FFI)
@echo ""
@echo "Output:"
@ls -lh target/release/libaxhash_ffi.* 2>/dev/null || true
.PHONY: no-std
no-std:
$(CARGO) build -p $(PKG_CORE) --no-default-features
.PHONY: test
test:
$(CARGO) test --workspace
.PHONY: test-release
test-release:
$(CARGO) test --workspace --release
.PHONY: parity
parity:
$(CARGO) test -p $(PKG_CORE) --lib backend_parity -- --nocapture
.PHONY: fmt
fmt:
$(CARGO) fmt --all
.PHONY: fmt-check
fmt-check:
$(CARGO) fmt --all -- --check
.PHONY: lint
lint:
$(CARGO) clippy --workspace --lib --all-features -- -D warnings
.PHONY: lint-all
lint-all:
$(CARGO) clippy --workspace --all-targets --all-features -- -D warnings
.PHONY: bench
bench: clean-target
bash scripts/bench.sh
.PHONY: bench-quick
bench-quick:
bash scripts/bench.sh
.PHONY: bench-throughput
bench-throughput:
bash scripts/bench.sh throughput
.PHONY: bench-latency
bench-latency:
bash scripts/bench.sh latency
.PHONY: bench-streaming
bench-streaming:
bash scripts/bench.sh streaming
.PHONY: bench-hashmap
bench-hashmap:
bash scripts/bench.sh hashmap
.PHONY: bench-concurrent
bench-concurrent:
bash scripts/bench.sh concurrent
.PHONY: bench-report
bench-report:
@if [ -f target/criterion/report/index.html ]; then \
(command -v open >/dev/null && open target/criterion/report/index.html) || \
(command -v xdg-open >/dev/null && xdg-open target/criterion/report/index.html) || \
echo "Open manually: target/criterion/report/index.html"; \
else \
echo "No criterion report found. Run 'make bench' first."; \
fi
.PHONY: smhasher
smhasher: ffi
@if [ ! -d "$(SMHASHER3_DIR)/build" ]; then \
echo "SMHasher3 build dir not found at $(SMHASHER3_DIR)/build"; \
echo "Either set SMHASHER3_DIR=/path/to/smhasher3, or build it first:"; \
echo " cd $(SMHASHER3_DIR) && mkdir -p build && cd build && cmake .. && make -j8"; \
exit 1; \
fi
cd $(SMHASHER3_DIR)/build && make SMHasher3 -j8
$(SMHASHER3_DIR)/build/SMHasher3 AxHash_64 | tail -25
.PHONY: smhasher-verify
smhasher-verify: ffi
cd $(SMHASHER3_DIR)/build && make SMHasher3 -j8
$(SMHASHER3_DIR)/build/SMHasher3 --test=VerifyAll 2>&1 | grep -i axhash
.PHONY: doc
doc:
$(CARGO) doc --workspace --no-deps --open
.PHONY: doc-build
doc-build:
$(CARGO) doc --workspace --no-deps
.PHONY: ci
ci: fmt-check lint test no-std
@echo ""
@echo "CI checks passed locally."
.PHONY: pre-release
pre-release: ci parity smhasher-verify
@echo ""
@echo "Pre-release validation complete:"
@echo " - fmt-check OK"
@echo " - clippy OK"
@echo " - tests pass"
@echo " - no_std OK"
@echo " - backend parity OK"
@echo " - SMHasher3 verification OK"
@echo ""
@echo "Next steps:"
@echo " make dry-publish @echo " git tag v\$$(grep -E '^version =' Cargo.toml | head -1 | sed 's/version = \"\\(.*\\)\"/\\1/')"
@echo " git push --tags
.PHONY: dry-publish
dry-publish:
$(CARGO) publish -p $(PKG_CORE) --dry-run
$(CARGO) publish -p $(PKG_RUST) --dry-run
$(CARGO) publish -p $(PKG_FFI) --dry-run
.PHONY: package
package: ffi
@TRIPLE=$$(rustc -vV | sed -n 's/host: //p'); \
echo "Packaging for $$TRIPLE"; \
python scripts/package-release.py "$$TRIPLE" release "$$PWD/dist"
@echo ""
@echo "Local release archive in: dist/"
@ls -lh dist/
.PHONY: clean
clean:
$(CARGO) clean
.PHONY: clean-target
clean-target:
rm -rf target/release target/criterion
@find target -maxdepth 2 -name release -type d -exec rm -rf {} + 2>/dev/null || true
.PHONY: clean-dist
clean-dist:
rm -rf dist/
.PHONY: update
update:
$(CARGO) update
.PHONY: tree
tree:
$(CARGO) tree --workspace --depth 1