# 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. The page is
# the lisp twin's ui.qml, unchanged: the script speaks the same messages.

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

all: ha_mqtt_lua.vescpkg

ha_mqtt_lua.vescpkg: ha_mqtt.luapkg README.md pkgdesc.qml ../ha_mqtt/ui.qml
	$(VESC_TOOL) --buildPkgFromDesc pkgdesc.qml --testPkgDesc 'custom:test' --testPkgDesc 'vesc:test'

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

test:
	./test/run.sh

clean:
	rm -f ha_mqtt_lua.vescpkg ha_mqtt.luapkg

.PHONY: all clean test
