ALL_SOURCES = $(shell git ls-files .)
RS_SOURCES = $(filter %.rs, $(ALL_SOURCES))
TOML_SOURCES = $(filter %.toml, $(ALL_SOURCES))
CARGO_SOURCES = $(RS_SOURCES) $(TOML_SOURCES)
TEST_FLAGS = RUST_BACKTRACE=1
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
fmt: .make.fmt
.make.fmt: .cargo/config.toml $(CARGO_SOURCES)
cargo fmt -- --check
touch $@
refmt: .make.refmt
.make.refmt: .cargo/config.toml $(CARGO_SOURCES)
cargo fmt
touch $@
check: .make.check
.make.check: .cargo/config.toml $(CARGO_SOURCES)
cargo check --tests
touch $@
clippy: .make.clippy
.make.clippy: .cargo/config.toml .make.check
cargo clippy -- --no-deps
touch $@
build: .make.build
.make.build: .cargo/config.toml $(CARGO_SOURCES)
cargo build
cargo test --no-run
touch $@
test: .make.test
.make.test: .cargo/config.toml .make.build
$(TEST_FLAGS) cargo test -- --nocapture
touch $@
retest: .cargo/config.toml
$(TEST_FLAGS) cargo test -- --nocapture
coverage: .make.coverage
.make.coverage: .make.test
mv .cargo/config.toml .cargo/_config.toml
rm -f tarpaulin*
$(TEST_FLAGS) cargo tarpaulin --skip-clean --out Xml
mv .cargo/_config.toml .cargo/config.toml
touch $@
ca: .make.ca
.make.ca: .cargo/config.toml .make.coverage
cargo coverage-annotations
touch $@
doc: .make.doc
.make.doc: .cargo/config.toml $(ALL_SOURCES)
cargo doc --no-deps touch $@
outdated: .make.outdated
.make.outdated: .cargo/config.toml $(TOML_SOURCES)
cargo outdated --root-deps-only --exit-code 1
touch $@
audit: .make.audit
.make.audit: .cargo/config.toml $(TOML_SOURCES)
cargo audit
touch $@
common: fmt clippy test ca doc
dev: refmt tags common outdated audit
staged:
@if git status . | grep -q 'Changes not staged\|Untracked files'; then git status; false; else true; fi
pc: staged common outdated audit
pre-publish: .cargo/config.toml
cargo publish --dry-run
ci: common pre-publish
publish: ci
cargo publish
tags: $(RS_SOURCES)
ctags --recurse .
clobber:
rm -f .make.* tags
rm -rf .cargo target
clean:
rm -f .make.* tags tarpaulin*
rm -rf .cargo `find target -name '*clacks*'`
.cargo/config.toml:
mkdir -p .cargo
echo '[build]' > $@
cargo tarpaulin --print-rust-flags | tail -1 | sed 's/RUSTFLAGS/rustflags/' >> $@