.PHONY: help
help:
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
RUST_VERSION := $(shell grep 'rust-version = ' Cargo.toml | head -1 | sed 's/.*rust-version = "\(.*\)"/\1/')
.PHONY: install-rust
install-rust:
rustup toolchain install $(RUST_VERSION)
rustup component add rustfmt clippy --toolchain $(RUST_VERSION)
.PHONY: check
check:
cargo +$(RUST_VERSION) check --all-features --workspace
.PHONY: fmt
fmt:
cargo +$(RUST_VERSION) fmt --all
.PHONY: fmt-check
fmt-check:
cargo +$(RUST_VERSION) fmt --all --check
.PHONY: clippy
clippy:
cargo +$(RUST_VERSION) clippy --all-features --all-targets -- -D warnings
.PHONY: test
test:
cargo +$(RUST_VERSION) test --all-features
.PHONY: test-doc
test-doc:
cargo +$(RUST_VERSION) test --doc --all-features
.PHONY: bench
bench:
cargo +$(RUST_VERSION) bench --all-features
.PHONY: bench-test
bench-test:
cargo +$(RUST_VERSION) bench --all-features -- --test
.PHONY: examples
examples:
@echo "Running basic example..."
cargo +$(RUST_VERSION) run --example basic
@echo "Running monotonic example..."
cargo +$(RUST_VERSION) run --example monotonic
@echo "Running derive_wrapper example..."
cargo +$(RUST_VERSION) run --example derive_wrapper --features derive
@echo "Running macros example..."
cargo +$(RUST_VERSION) run --example macros --features macros
@echo "Running combined_features example..."
cargo +$(RUST_VERSION) run --example combined_features --features derive,macros
@echo "Running derive_features example..."
cargo +$(RUST_VERSION) run --example derive_features --features derive,serde,uuid,sqlx,postgres-types
@echo "Running serde_example..."
cargo +$(RUST_VERSION) run --example serde_example --features serde
@echo "Running uuid_conversion example..."
cargo +$(RUST_VERSION) run --example uuid_conversion --features uuid
@echo "Running rkyv_example..."
cargo +$(RUST_VERSION) run --example rkyv_example --features rkyv
@echo "Running postgres_types_example..."
cargo +$(RUST_VERSION) run --example postgres_types_example --features postgres-types
@echo "Running chrono_example..."
cargo +$(RUST_VERSION) run --example chrono_example --features chrono
@echo "Running jiff_example..."
cargo +$(RUST_VERSION) run --example jiff_example --features jiff
.PHONY: build
build:
cargo +$(RUST_VERSION) build --all-features --workspace
.PHONY: build-release
build-release:
cargo +$(RUST_VERSION) build --all-features --workspace --release
.PHONY: doc
doc:
cargo +$(RUST_VERSION) doc --all-features --workspace --no-deps
.PHONY: doc-open
doc-open:
cargo +$(RUST_VERSION) doc --all-features --workspace --no-deps --open
.PHONY: clean
clean:
cargo clean
.PHONY: ci
ci: fmt-check clippy test test-doc bench-test examples
.PHONY: pre-commit
pre-commit: fmt clippy test
.PHONY: verify-version
verify-version:
@echo "Checking workspace configuration..."
@VERSION=$$(grep '^\s*version = ' Cargo.toml | head -1 | sed 's/.*version = "\(.*\)"/\1/'); \
echo " Workspace version: $$VERSION"; \
EDITION=$$(grep '^\s*edition = ' Cargo.toml | head -1 | sed 's/.*edition = "\(.*\)"/\1/'); \
echo " Workspace edition: $$EDITION"; \
RUST_VER=$$(grep '^\s*rust-version = ' Cargo.toml | head -1 | sed 's/.*rust-version = "\(.*\)"/\1/'); \
echo " Workspace rust-version: $$RUST_VER"; \
echo ""; \
echo "Checking sub-crates..."; \
DERIVE_CHECK=$$(grep 'version.workspace = true' nulid_derive/Cargo.toml > /dev/null && echo "workspace ($$VERSION)" || grep '^version = ' nulid_derive/Cargo.toml | sed 's/version = "\(.*\)"/\1/'); \
echo " nulid_derive version: $$DERIVE_CHECK"; \
MACROS_CHECK=$$(grep 'version.workspace = true' nulid_macros/Cargo.toml > /dev/null && echo "workspace ($$VERSION)" || grep '^version = ' nulid_macros/Cargo.toml | sed 's/version = "\(.*\)"/\1/'); \
echo " nulid_macros version: $$MACROS_CHECK"
.PHONY: publish-dry-run
publish-dry-run:
@echo "Dry run: Publishing nulid_derive..."
cd nulid_derive && cargo publish --dry-run
@echo "Dry run: Publishing nulid_macros..."
cd nulid_macros && cargo publish --dry-run
@echo "Dry run: Publishing nulid..."
cargo publish --dry-run --all-features
.PHONY: publish
publish:
@echo "Publishing nulid_derive..."
cd nulid_derive && cargo publish
@echo "Waiting for crates.io propagation..."
sleep 30
@echo "Publishing nulid_macros..."
cd nulid_macros && cargo publish
@echo "Waiting for crates.io propagation..."
sleep 30
@echo "Publishing nulid..."
cargo publish --all-features
.PHONY: update-deps
update-deps:
cargo update
.PHONY: all
all: ci doc