TARGET=target/debug/
TARGET_HTML=html
NAME=$(shell grep -E "^name" Cargo.toml|head -n1|awk -F'"' '$$0=$$2')
VERSION=$(shell grep -E "^version" Cargo.toml|head -n1|awk -F'"' '$$0=$$2')
.PHONY: help license copyright test
help:
$(info $(NAME) Makefile (v$(VERSION)))
$(info )
$(info Available commands:)
$(info )
@grep '^[[:alnum:]_-]*:.* | sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'
compile: check-setup
@cargo build
run:
@RUST_BACKTRACE=full RUST_LOG=info cargo run
clean:
@rm -rf "$(TARGET_HTML)"
@cargo clean
check-setup:
@type rustup >/dev/null 2>&1 || (echo "Run 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh' first." >&2 ; exit 1)
@type rustc >/dev/null 2>&1 || (echo "Run 'curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh' first." >&2 ; exit 1)
coverage:
@type grcov >/dev/null 2>&1 || (echo "Run 'cargo install grcov' first." >&2 ; exit 1)
@cargo clean
@CARGO_INCREMENTAL=0 RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" cargo build
@CARGO_INCREMENTAL=0 RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" cargo test
@grcov $(TARGET) -t html --ignore "/*" -s . --llvm --branch --ignore-not-existing -o $(TARGET_HTML)
@echo "Result saved to the '$(TARGET_HTML)' folder"
test:
@cargo test
license:
@type cargo-license >/dev/null 2>&1 || (echo "Run 'cargo install cargo-license' first." >&2 ; exit 1)
@cargo-license
lint:
@cargo fix
@cargo clippy --fix -Z unstable-options
@cargo clippy --all-targets --all-features -- -D warnings
test-fuzzy:
$(info Todo: setup cargo-fuzz)
@true
style:
@cargo fmt
doc:
@cargo doc --no-deps --open
copyright:
@find . -iname "*.rs" -exec bash -c "if ! grep -q Copyright "{}"; then cat COPYRIGHT {} > {}.new && mv {}.new {} ; fi" \;
feedback:
@open https://github.com/alexanderwillner/$(NAME)/issues
install:
@cargo install --path .
release: test
@git status
@echo "Press enter to release $(NAME) v$(VERSION)..."
@read
@RUSTFLAGS="-Clink-arg=-s -Cpanic=abort" cargo build --release
@cargo publish
@cd target/release && tar -czf $(NAME)-$(VERSION)-mac.tar.gz $(NAME)
@shasum -a 256 target/release/$(NAME)-$(VERSION)-mac.tar.gz
@open .
@open ../homebrew-tap
@hub release create -a target/release/$(NAME)-$(VERSION)-mac.tar.gz -m '$(VERSION)' v$(VERSION)
@open https://github.com/AlexanderWillner/$(NAME)/releases/