all: build test

reset:
	powershell -executionpolicy bypass .\scripts\reset_build.ps1

%.cpp : %.rl
	ragel -o $@ $<

build: ansi_parser.cpp lel_parser.cpp
	meson compile -j 10 -C builddir

release_build:
	meson --wipe builddir -Db_ndebug=true --buildtype release
	meson compile -j 10 -C builddir

debug_build:
	meson setup --wipe builddir --buildtype debug
	meson compile -j 10 -C builddir

tracy_build:
	meson setup --wipe builddir --buildtype debugoptimized -Dtracy_enable=true -Dtracy:on_demand=true
	meson compile -j 10 -C builddir

test: build
	./builddir/runtests "[ai]"

run: build test
	powershell "cp ./builddir/zedcaster.exe ."
	./zedcaster

debug: build
	gdb --nx -x .gdbinit --ex run --args builddir/zedcaster.exe

debug_run: build
	gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/zedcaster.exe

debug_walk: build test
	gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/zedcaster.exe t

clean:
	meson compile --clean -C builddir

debug_test: build
	gdb --nx -x .gdbinit --ex run --args builddir/runtests.exe -e

win_installer:
	powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" win_installer.ifp'