@echo off
rem ===========================================================================
rem  Paper Atlas - build a self-contained program (Windows)
rem
rem    build.bat              build dist\PaperAtlas.exe
rem    build.bat --zip        also create a shareable zip
rem    build.bat --check      only show the build plan
rem
rem  The .exe needs no Python on the target machine.  It must be built on
rem  Windows (a Linux binary cannot run here and vice versa).
rem ===========================================================================
setlocal
cd /d "%~dp0"
title Paper Atlas - build standalone program

set "PY="
if exist ".venv\Scripts\python.exe" set "PY=.venv\Scripts\python.exe"
if not defined PY (
  where py >nul 2>nul && set "PY=py -3"
)
if not defined PY (
  where python >nul 2>nul && set "PY=python"
)
if not defined PY (
  echo.
  echo   [!] Python was not found. Run start.bat once ^(it installs its own Python^),
  echo       or install Python 3.10+ from https://www.python.org/downloads/
  echo.
  pause
  exit /b 1
)

%PY% build.py %*
set "CODE=%ERRORLEVEL%"
if not "%CODE%"=="0" (
  echo.
  echo   [!] Build failed with code %CODE%.
  echo.
  pause
)
endlocal