.PHONY: all publish test fmt clean tools tool_rust tool_fmt tool_readme
RUSTFLAGS += -D warnings
SHELL = /usr/bin/env sh
ENV = RUSTFLAGS='$(RUSTFLAGS)' CARGO_BUILD_JOBS='$(shell nproc || sysctl -n hw.physicalcpu)' NUM_JOBS='$(shell nproc || sysctl -n hw.physicalcpu)' CARGO_INCREMENTAL='1'
all: test
publish: tools
git diff --exit-code
cargo publish
VER="v$$(grep version Cargo.toml | cut -d ' ' -f 3 | cut -d \" -f 2)"; git tag -a $$VER -m $$VER
git push --tags
test: tools
$(ENV) cargo fmt -- --check
$(ENV) cargo clippy -- \
-A clippy::nursery -A clippy::style -A clippy::cargo \
-A clippy::pedantic -A clippy::restriction \
-D clippy::complexity -D clippy::perf -D clippy::correctness
$(ENV) RUST_BACKTRACE=1 cargo test
$(ENV) cargo readme -o README.md
@if [ "${CI}x" != "x" ]; then git diff --exit-code; fi
fmt: tools
cargo fmt
clean:
$(ENV) cargo clean
tools: tool_rust tool_fmt tool_clippy tool_readme
tool_rust:
@if rustup --version >/dev/null 2>&1; then \
echo "# Makefile rustup override set stable; \
else \
echo "# Makefile fi;
tool_fmt: tool_rust
@if ! (cargo fmt --version); \
then \
if rustup --version >/dev/null 2>&1; then \
echo "# Makefile rustup component add rustfmt-preview; \
else \
echo "# Makefile exit 1; \
fi; \
else \
echo "# Makefile fi;
tool_clippy: tool_rust
@if ! (cargo clippy --version); \
then \
if rustup --version >/dev/null 2>&1; then \
echo "# Makefile rustup component add clippy-preview; \
else \
echo "# Makefile exit 1; \
fi; \
else \
echo "# Makefile fi;
tool_readme: tool_rust
@if ! (cargo readme --version); \
then \
cargo install cargo-readme; \
else \
echo "# Makefile fi;