CARGO ?= cargo
FILE ?=
MONITOR ?=
KEYSTONE ?=
OPACITY ?=
PROFILE ?=
v ?=
.DEFAULT_GOAL := help
.PHONY: help build test check fmt clippy doc clean release \
show monitors identify corner-pin require-cargo require-manifest \
require-file require-version
require-cargo:
@command -v $(CARGO) >/dev/null 2>&1 || { \
echo "error: $(CARGO) not found. Install Rust from https://rustup.rs"; \
exit 1; }
require-manifest: require-cargo
@$(CARGO) metadata --no-deps --format-version 1 >/dev/null 2>&1 || { \
echo "error: Cargo.toml does not parse. Run '$(CARGO) metadata' to see why."; \
exit 1; }
require-file:
@test -n "$(FILE)" || { \
echo "error: no file. Usage: make $(MAKECMDGOALS) FILE=poster.png"; \
exit 1; }
@test -f "$(FILE)" || { \
echo "error: $(FILE) does not exist."; \
exit 1; }
require-version:
@test -n "$(v)" || { \
echo "error: no version. Usage: make release v=0.2.0"; \
exit 1; }
@printf '%s' '$(v)' \
| grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$$' || { \
echo "error: '$(v)' is not a semver version (x.y.z)"; \
exit 1; }
show: require-manifest require-file
@MONITOR=$(MONITOR) KEYSTONE=$(KEYSTONE) OPACITY=$(OPACITY) \
$(CARGO) run $(PROFILE) --features window,image --example show -- "$(FILE)"
monitors: require-manifest
@LIST=1 $(CARGO) run $(PROFILE) --quiet --features window,image --example show
identify: require-manifest require-file
$(CARGO) run $(PROFILE) --example identify -- "$(FILE)"
corner-pin: require-manifest
$(CARGO) run $(PROFILE) --quiet --example corner_pin
build: require-manifest
$(CARGO) build $(PROFILE)
test: require-manifest
$(CARGO) test --features render
test-core: require-manifest
$(CARGO) test --no-default-features
check: require-manifest
$(CARGO) check --no-default-features
$(CARGO) check
$(CARGO) check --features render
$(CARGO) check --features window --all-targets
fmt: require-cargo
$(CARGO) fmt
clippy: require-manifest
$(CARGO) clippy --features window,image --all-targets -- -D warnings
doc: require-manifest
$(CARGO) doc --no-deps --features window,image
clean:
$(CARGO) clean
release: require-version require-manifest
@awk -v ver='$(v)' ' \
/^\[/ { in_pkg = ($$0 == "[package]") } \
in_pkg && !done && /^version[[:space:]]*=/ { \
print "version = \"" ver "\""; done = 1; next } \
{ print } \
' Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
@grep -Fqx 'version = "$(v)"' Cargo.toml || { \
echo "error: Cargo.toml still does not say $(v)."; exit 1; }
@sed -i.bak -E 's/^vtome = \{ version = "[^"]*"/vtome = { version = "$(v)"/' \
README.md && rm -f README.md.bak
@$(CARGO) metadata --format-version 1 >/dev/null
@echo "==> $(v): Cargo.toml, Cargo.lock, README.md"
@echo " Review the diff, then commit."
help:
@echo "vtome — Video Translucent Optimized MacGyver Engine"
@echo ""
@grep -E '^## ' $(MAKEFILE_LIST) \
| sed -e 's/^## //' -e 's/:/:|/' \
| awk -F'|' '{ printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }'
@echo ""
@echo " Put an image or a video on a specific monitor — or on a specific"
@echo " quadrilateral of one. See planning/TODO.md for what is left."
@echo ""
@echo " make monitors"
@echo " make show FILE=poster.png MONITOR=1 KEYSTONE=0.15"
@echo " make identify FILE=clip.mp4"