@echo off setlocal EnableDelayedExpansion REM ============================================================================= REM The Goth Cardgame Collection - One-File Build Script (Windows) REM Output: dist\windows\TheGothCardgameCollection.exe REM Usage: build_scripts\build.bat [--current | --all | --clean] REM ============================================================================= cd /d "%~dp0.." set "PROJECT_ROOT=%CD%" set "APP_NAME=TheGothCardgameCollection" set "MODE=%~1" if "%MODE%"=="" set "MODE=--current" if /I "%MODE%"=="--clean" ( echo [CLEAN] Entferne temporaere Build-Ordner... if exist "build" rmdir /s /q "build" if exist ".venv_build_win" rmdir /s /q ".venv_build_win" echo [OK] Aufgeraeumt ^(dist\ blieb erhalten^). exit /b 0 ) echo ============================================================ echo Building %APP_NAME%.exe ^(Single-File^) -^> dist\windows\ echo ============================================================ set "PY_CMD=" where python >nul 2>nul && ( python -c "import sys; sys.exit(0)" >nul 2>nul && set "PY_CMD=python" ) if "%PY_CMD%"=="" ( where py >nul 2>nul && ( py -3 -c "import sys; sys.exit(0)" >nul 2>nul && set "PY_CMD=py -3" ) ) if "%PY_CMD%"=="" ( where python3 >nul 2>nul && ( python3 -c "import sys; sys.exit(0)" >nul 2>nul && set "PY_CMD=python3" ) ) if "%PY_CMD%"=="" ( echo [ERROR] Keine funktionierende Python-3-Installation im PATH gefunden! pause exit /b 1 ) set "VENV_DIR=%PROJECT_ROOT%\.venv_build_win" if not exist "%VENV_DIR%\Scripts\python.exe" ( echo [1/3] Erstelle isolierte Build-Umgebung ^(.venv_build_win^)... %PY_CMD% -m venv "%VENV_DIR%" if errorlevel 1 exit /b 1 ) set "VENV_PY=%VENV_DIR%\Scripts\python.exe" echo [2/3] Pruefe ^& aktualisiere Build-Abhaengigkeiten ^(PyInstaller, Pillow, Pygame^)... "%VENV_PY%" -m pip install --upgrade --quiet pip "%VENV_PY%" -m pip install --quiet pyinstaller pillow pygame if errorlevel 1 exit /b 1 set "DIST_DIR=%PROJECT_ROOT%\dist\windows" set "WORK_DIR=%PROJECT_ROOT%\build\windows" if not exist "%DIST_DIR%" mkdir "%DIST_DIR%" if not exist "%WORK_DIR%" mkdir "%WORK_DIR%" set "ICON_ARG=" if exist "%PROJECT_ROOT%\resources\images\game_icon.ico" ( set "ICON_ARG=--icon %PROJECT_ROOT%\resources\images\game_icon.ico" ) echo [3/3] Kompiliere kompakte Einzeldatei mit absoluten Ressourcen-Pfaden... "%VENV_PY%" -m PyInstaller ^ --noconfirm ^ --clean ^ --onefile ^ --windowed ^ --name "%APP_NAME%" ^ --distpath "%DIST_DIR%" ^ --workpath "%WORK_DIR%" ^ --specpath "%WORK_DIR%" ^ %ICON_ARG% ^ --add-data "%PROJECT_ROOT%\resources;resources" ^ --add-data "%PROJECT_ROOT%\games;games" ^ --collect-submodules games ^ --collect-submodules controller ^ --collect-submodules models ^ --collect-submodules view ^ --collect-submodules resources ^ --hidden-import tkinter ^ --hidden-import tkinter.ttk ^ --hidden-import tkinter.font ^ --hidden-import sqlite3 ^ --hidden-import PIL._tkinter_finder ^ --exclude-module matplotlib ^ --exclude-module numpy ^ --exclude-module scipy ^ --exclude-module pandas ^ --exclude-module pytest ^ --exclude-module unittest ^ --exclude-module pydoc ^ "%PROJECT_ROOT%\main.py" if errorlevel 1 ( echo [ERROR] PyInstaller-Build fehlgeschlagen! exit /b 1 ) if exist "%WORK_DIR%" rmdir /s /q "%WORK_DIR%" echo. echo [DONE] Fertige ausfuehrbare Datei liegt bereit unter: echo dist\windows\%APP_NAME%.exe if /I "%MODE%"=="--all" ( where wsl >nul 2>nul if not errorlevel 1 ( echo [WSL] Starte Linux-Build -^> dist/linux/%APP_NAME% ... wsl bash ./build_scripts/build.sh --current ) else ( echo [SKIP] WSL nicht verfuegbar - ueberspringe Linux-Build. ) ) endlocal exit /b 0