# Copyright 2026 Stephen Bouche
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Two steps, as for the other Lua packages: luapack.py writes the script
# container with the Lua flag set, and vesc_tool embeds it through pkgLua.
# VE points at the vesc_express checkout the packer comes from.

VESC_TOOL ?= vesc_tool
VE ?= $(firstword $(wildcard ../../vesc_express ../../express))
LUAPACK = $(VE)/tools/luapack.py

all: jk_bms_lua.vescpkg

jk_bms_lua.vescpkg: jk_bms.luapkg README.md pkgdesc.qml
	$(VESC_TOOL) --buildPkgFromDesc pkgdesc.qml --testPkgDesc 'vesc:test'

jk_bms.luapkg: jk_bms.lua
	python3 $(LUAPACK) jk_bms.lua -o $@

test:
	./test/run.sh

clean:
	rm -f jk_bms_lua.vescpkg jk_bms.luapkg

.PHONY: all clean test
