comma := ,
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)
VERSION ?= $(strip $(shell grep -m1 'version = "' Cargo.toml | cut -d '"' -f2))
git.sync :
git add --all && git commit -am $(message) && git pull
sync : git.sync
audit :
cargo audit && $(MAKE) --no-print-directory clean-cache-files
doc :
ifeq ($(clean),yes)
@rm -rf target/doc/
endif
cargo doc --all-features \
$(if $(call eq,$(private),no),,--document-private-items) \
$(if $(call eq,$(manifest_path),),--manifest-path ./Cargo.toml,--manifest-path $(manifest_path)) \
$(if $(call eq,$(open),no),,--open)
lint :
cargo clippy --all-features \
$(if $(call eq,$(manifest_path),),--manifest-path ./Cargo.toml,--manifest-path $(manifest_path)) \
$(if $(call eq,$(warnings),no),-- -D warnings,)
check :
cargo check \
$(if $(call eq,$(manifest_path),),--manifest-path ./Cargo.toml,--manifest-path $(manifest_path))
normalize : fmt lint
checkmate : doc lint check
fmt :
{ find -L module -name *.rs -print0 ; } | xargs -0 rustfmt +nightly $(if $(call eq,$(check),yes),-- --check,)
up :
cargo up
clean :
cargo clean && rm -rf Cargo.lock && cargo cache -a && cargo update
test :
cargo test --all-features
all : fmt lint test
.PHONY : \
all \
audit \
docs \
lint \
check \
fmt \
normalize \
checkmate \
test \
up \
doc \
clean-cache-files
clean-cache-files:
@echo "Cleaning cache files (adding hyphen prefix for git exclusion)..."
@if [ -d "advisory-db" ]; then mv advisory-db -advisory-db 2>/dev/null || true; fi
@if [ -f "advisory-db..lock" ]; then mv advisory-db..lock -advisory-db..lock 2>/dev/null || true; fi
@if [ -d ".global-cache" ]; then mv .global-cache -.global-cache 2>/dev/null || true; fi
@if [ -d ".package-cache" ]; then mv .package-cache -.package-cache 2>/dev/null || true; fi
@if [ -d "registry" ]; then mv registry -registry 2>/dev/null || true; fi
@echo "Cache files cleaned successfully."