@echo off
rem Builds dist\macropad.exe: one file, no console, tray icon, asks for admin rights, sensors built in.
rem The same build runs on GitHub (ci/build_exe.yml); use this only to build on your own Windows PC.
rem Needs uv once: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
cd /d "%~dp0"
where uv >nul 2>nul || (echo uv not found. Install it first, see the line above. & pause & exit /b 1)
if not exist build mkdir build
uv run --python 3.12 --with pillow --with pystray python -c "import win_app; win_app.icon_image().save(r'build\macropad.ico', sizes=[(16,16),(32,32),(48,48),(64,64)])"
uvx --python 3.12 --with pyserial --with pynput --with psutil --with HardwareMonitor --with pystray --with pillow pyinstaller --noconfirm --onefile --windowed --uac-admin --name macropad --icon "%~dp0build\macropad.ico" --hidden-import pynput.keyboard._win32 --hidden-import pynput.mouse._win32 --hidden-import pystray._win32 --hidden-import win_app --collect-all HardwareMonitor --collect-all clr_loader --collect-all pythonnet --add-data "%~dp0macropad_nano.hex;." --add-data "%~dp0macropad_games.hex;." --add-data "%~dp0config.toml;." --distpath dist --workpath build --specpath build macropad_helper.py
if errorlevel 1 (echo Build failed. & pause & exit /b 1)
echo.
echo Done: dist\macropad.exe. Settings and the log go to %%APPDATA%%\Macropad on first start.
pause
