JOLT_VERSION = v0.14.0-stable
JOLT_URL = https://github.com/godot-jolt/godot-jolt/releases/download/${JOLT_VERSION}/godot-jolt_${JOLT_VERSION}.zip
JOLT_DIR = ./godot/jolt

install_jolt:
	rm -rf ${JOLT_DIR}
	$(eval DOWNLOAD := $(shell mktemp -d))
	$(eval UNPACK := $(shell mktemp -d))
	curl -L ${JOLT_URL} --output $(DOWNLOAD)/jolt.zip
	unzip $(DOWNLOAD)/jolt.zip -d $(UNPACK)
	mv $(UNPACK)/addons/* ${JOLT_DIR}
	rm -rf $(DOWNLOAD)
	rm -rf $(UNPACK)


rust_build:
	cd rust && cargo build

rust_fmt:
	cd rust && cargo fmt


GODOT_TOOLS ?= $(shell pwd)/godot_tools

godot_tools:
	test -s $(GODOT_TOOLS)/bin/activate || python3 -m venv $(GODOT_TOOLS)
	source $(GODOT_TOOLS)/bin/activate  &&\
		python3 -m pip install "gdtoolkit==4.*"

godot_lint: godot_tools
	$(GODOT_TOOLS)/bin/gdlint ./godot

godot_fmt: godot_tools
	$(GODOT_TOOLS)/bin/gdformat ./godot