# Entry points. Every target is safe to run more than once.

PY  ?= venv/bin/python
PIP ?= venv/bin/pip

.PHONY: help venv deps deps-nocad toolchain verify-oracle regenerate-oracle test test-nocad clean

help:
	@echo "venv              create the virtualenv (Python 3.11)"
	@echo "deps              install base + CAD requirements"
	@echo "deps-nocad        install base requirements only"
	@echo "toolchain         build the pinned reference toolchain image"
	@echo "verify-oracle     check the committed oracle is intact"
	@echo "regenerate-oracle rebuild the oracle inside the pinned image"
	@echo "test              pytest -n auto"
	@echo "test-nocad        the separability check: suite must pass without CAD"

venv:
	test -d venv || python3 -m venv venv
	$(PIP) install --upgrade pip

deps: venv
	$(PIP) install -r requirements-base.txt -r requirements-cad.txt
	$(PIP) install -e .

deps-nocad: venv
	$(PIP) install -r requirements-base.txt
	$(PIP) install -e .

toolchain:
	docker build -t mechcomp/reference-toolchain:8.0.0 tools/reference-toolchain

verify-oracle:
	python3 fixtures/strap-beam-8.0.0/make_fixtures.py --verify

regenerate-oracle: toolchain
	./tools/reference-toolchain/verify.sh --full

test:
	$(PY) -m pytest -n auto

test-nocad:
	$(PY) -m pytest -n auto -k "not cad"

clean:
	rm -rf .pytest_cache src/*.egg-info
	find . -name __pycache__ -type d -prune -exec rm -rf {} +
