SOURCE_FILES := $(shell grep "import '" src/main.lua | grep -v CoreLibs | sed "s/.*'\(.*\)'.*/src\/\1/") src/main.lua
GENERATED_FILES := src/assets.lua

all:
	pdc --skip-unknown src BatterUp.pdx

assets:
	lua lib/preprocess-cl.lua src/assets.lua2p

check: assets
	stylua -c --indent-type Spaces -g "*.lua" -g "!${GENERATEED_FILES}" src/
	cat __stub.ext.lua <(sed 's/^function/-- selene: allow(unused_variable)\nfunction/' ${PLAYDATE_SDK_PATH}/CoreLibs/__types.lua) ${SOURCE_FILES} | grep -v '^import' | sed 's/<const>//g' | selene -

test: check
	(cd src; find ./test -name '*lua' | xargs -L1 lua)

lint:
	stylua --indent-type Spaces -g "*.lua" -g "!${GENERATEED_FILES}" src/
