.PHONY: check login publish yank test build doc expand fmt check-fmt clippy fmt-dprint check-dprint pr-checks TOP := $(shell git rev-parse --show-toplevel) NIX_SHELL_FLAGS := $(TOP)/shell.nix NIX_SHELL = $(shell cmd="`which cached-nix-shell` $(NIX_SHELL_FLAGS) --run" || cmd="`which nix-shell` $(NIX_SHELL_FLAGS) --run" || cmd="`which bash` -c"; echo $$cmd) DPRINT_CARGO_TOML_FILES = $(patsubst %/Cargo.toml,%,$(shell $(NIX_SHELL) 'dprint output-file-paths' | grep 'Cargo\.toml')) MANIFEST_FILE = $(shell find . .. ../.. ../../.. ../../../.. ../../../../.. -type f -name Cargo.toml | head -n 1) MANIFEST_DIR = $(shell dirname $(MANIFEST_FILE)) FLAGS := --release PUBLISH_FLAGS := --dry-run check: $(NIX_SHELL) 'SKIP_WASM_BUILD=1; cargo check $(FLAGS)' login: $(NIX_SHELL) 'cargo login' publish: $(NIX_SHELL) 'cargo publish $(PUBLISH_FLAGS)' yank: $(NIX_SHELL) 'cargo yank --version 0.1.0' test: $(NIX_SHELL) 'SKIP_WASM_BUILD=1; cargo test $(FLAGS) -- --show-output' build: $(NIX_SHELL) 'cargo build $(FLAGS)' doc: $(NIX_SHELL) 'cargo doc $(FLAGS)' expand: $(NIX_SHELL) 'cargo expand $(FLAGS)' fmt: $(NIX_SHELL) 'cd $(MANIFEST_DIR); cargo fmt' check-fmt: $(NIX_SHELL) 'cd $(MANIFEST_DIR); cargo fmt --check' clippy: $(NIX_SHELL) 'SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy --all-targets $(FLAGS)' fmt-dprint: NIX_SHELL_FLAGS := -p dprint -p cargo-sort fmt-dprint: $(NIX_SHELL) 'dprint fmt' set -xe; \ for dir in $(DPRINT_CARGO_TOML_FILES); \ do $(NIX_SHELL) "cd $$dir && cargo-sort -g"; done check-dprint: NIX_SHELL_FLAGS := -p dprint -p cargo-sort check-dprint: $(NIX_SHELL) 'dprint check' set -xe; \ for dir in $(DPRINT_CARGO_TOML_FILES); \ do $(NIX_SHELL) "cd $$dir && cargo-sort -g -c"; done pr-checks: check-dprint check-fmt clippy test