| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- .POSIX:
- # Install prefix
- PREFIX = $(HOME)/.cargo
- # Cargo binary
- CARGO = cargo +nightly
- # Compile target
- RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
- # Uncomment when doing musl static builds
- #RUSTFLAGS = -C target-feature=+crt-static -C link-self-contained=yes
- SRC = \
- Cargo.toml \
- $(shell find src -type f -name '*.rs') \
- BIN = $(shell grep '^name = ' Cargo.toml | cut -d' ' -f3 | tr -d '"')
- all: $(BIN)
- $(BIN): $(SRC)
- RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(RUST_TARGET) --release --package $@
- cp -f target/$(RUST_TARGET)/release/$@ $@
- fmt:
- $(CARGO) fmt --all
- check:
- RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) hack check --target=$(RUST_TARGET) \
- --release --feature-powerset --workspace
- clippy:
- RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
- --release --all-features --workspace --tests
- fix:
- RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
- --release --all-features --workspace --tests --fix --allow-dirty
- rustdoc:
- RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) doc --target=$(RUST_TARGET) \
- --release --all-features --workspace --document-private-items --no-deps
- test:
- RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \
- --release --all-features --workspace
- coverage:
- RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) llvm-cov --target=$(RUST_TARGET) \
- --release --all-features --workspace --html
- clean:
- RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) --release --package $(BIN)
- rm -f $(BIN)
- distclean: clean
- rm -rf target
- install: all
- mkdir -p $(DESTDIR)$(PREFIX)/bin
- cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
- chmod 755 $(DESTDIR)$(PREFIX)/bin/$(BIN)
- uninstall:
- rm -f $(DESTDIR)$(PREFIX)/bin/$(BIN)
- .PHONY: all fmt check clippy fix rustdoc test coverage clean distclean install uninstall
|