.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/')
FEATURES ?=
.PHONY: install-rust
install-rust:
rustup toolchain install $(RUST_VERSION)
rustup component add rustfmt clippy --toolchain $(RUST_VERSION)
.PHONY: fmt
fmt:
cargo +$(RUST_VERSION) fmt --all
.PHONY: fmt-check
fmt-check:
cargo +$(RUST_VERSION) fmt --all --check
.PHONY: clippy
clippy:
ifeq ($(FEATURES),)
cargo +$(RUST_VERSION) clippy -- -D warnings -W clippy::pedantic
else
cargo +$(RUST_VERSION) clippy --features "$(FEATURES)" -- -D warnings -W clippy::pedantic
endif
.PHONY: clippy-all
clippy-all:
@for features in "" "tls" "log" "defmt" "tls,log" "tls,defmt"; do \
echo "Running clippy with features: $$features"; \
cargo +$(RUST_VERSION) clippy --features "$$features" -- -D warnings -W clippy::pedantic; \
done
.PHONY: test
test:
ifeq ($(FEATURES),)
cargo +$(RUST_VERSION) test
else
cargo +$(RUST_VERSION) test --features "$(FEATURES)"
endif
.PHONY: test-all
test-all:
@for features in "" "tls" "log" "defmt" "tls,log" "tls,defmt"; do \
echo "Running tests with features: $$features"; \
cargo +$(RUST_VERSION) test --features "$$features"; \
done
.PHONY: build
build:
cargo +$(RUST_VERSION) build
.PHONY: build-release
build-release:
cargo +$(RUST_VERSION) build --release
.PHONY: doc
doc:
cargo +$(RUST_VERSION) doc --no-deps
.PHONY: doc-open
doc-open:
cargo +$(RUST_VERSION) doc --no-deps --open
.PHONY: clean
clean:
cargo clean
.PHONY: ci
ci: fmt-check clippy-all test-all
.PHONY: pre-commit
pre-commit: fmt clippy-all test-all
.PHONY: verify-version
verify-version:
@echo "Checking crate configuration..."
@VERSION=$$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/'); \
echo " Version: $$VERSION"; \
EDITION=$$(grep '^edition = ' Cargo.toml | head -1 | sed 's/edition = "\(.*\)"/\1/'); \
echo " Edition: $$EDITION"; \
RUST_VER=$$(grep '^rust-version = ' Cargo.toml | head -1 | sed 's/rust-version = "\(.*\)"/\1/'); \
echo " Rust version: $$RUST_VER"
.PHONY: publish-dry-run
publish-dry-run:
cargo +$(RUST_VERSION) publish --dry-run
.PHONY: publish
publish:
cargo +$(RUST_VERSION) publish
.PHONY: release
release:
@VERSION=$$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/'); \
echo "Creating tag v$$VERSION..."; \
git tag "v$$VERSION"; \
git push origin "v$$VERSION"
.PHONY: update-deps
update-deps:
cargo update
.PHONY: all
all: ci doc