AMBIENT_IMAGE = /scratch/ambient-images/ambient-boot.qcow2
TARGET = --target x86_64-unknown-linux-musl

all: build test ambient.html

build:
	cargo fmt -- --check
	cargo clippy --all-targets -- -D warnings
	cargo build --all-targets $(TARGET)
	cargo test

test:
	subplot codegen ambient.subplot -o test.py
	rm -f test.log
	set -x; export TMP="$$(mktemp -d)" && echo "TMP=$$TMP" \
		trap 'rm -rf "$$TMP"' EXIT && \
		cargo install --bins --path=. --root="$$TMP" $(TARGET) && \
		python3 test.py --log test.log --env "BINDIR=$$TMP/bin" --env "IMAGE=$(AMBIENT_IMAGE)"

ambient.html: ambient.subplot ambient.md ambient.yaml
	subplot docgen ambient.subplot -o ambient.html
