diff --git a/build_scripts/build.bat b/build_scripts/build.bat index 1ab217a..20a3ecc 100644 --- a/build_scripts/build.bat +++ b/build_scripts/build.bat @@ -6,7 +6,6 @@ REM Output: dist\windows\TheGothCardgameCollection.exe REM Usage: build_scripts\build.bat [--current | --all | --clean] REM ============================================================================= -REM Immer ins Projekt-Hauptverzeichnis wechseln (auch bei Doppelklick auf build.bat) cd /d "%~dp0.." set "PROJECT_ROOT=%CD%" set "APP_NAME=TheGothCardgameCollection" @@ -25,7 +24,6 @@ echo ============================================================ echo Building %APP_NAME%.exe ^(Single-File^) -^> dist\windows\ echo ============================================================ -REM Python-Befehl ermitteln (python, py -3 oder python3) set "PY_CMD=" where python >nul 2>nul && ( python -c "import sys; sys.exit(0)" >nul 2>nul && set "PY_CMD=python" @@ -47,15 +45,11 @@ if "%PY_CMD%"=="" ( exit /b 1 ) -REM Isolierte Build-Venv anlegen & Dependencies automatisch installieren 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 ( - echo [ERROR] Konnte virtuelle Umgebung nicht erstellen. - exit /b 1 - ) + if errorlevel 1 exit /b 1 ) set "VENV_PY=%VENV_DIR%\Scripts\python.exe" @@ -63,10 +57,7 @@ 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 ( - echo [ERROR] Installation der Build-Abhaengigkeiten fehlgeschlagen. - exit /b 1 -) +if errorlevel 1 exit /b 1 set "DIST_DIR=%PROJECT_ROOT%\dist\windows" set "WORK_DIR=%PROJECT_ROOT%\build\windows" @@ -74,11 +65,11 @@ if not exist "%DIST_DIR%" mkdir "%DIST_DIR%" if not exist "%WORK_DIR%" mkdir "%WORK_DIR%" set "ICON_ARG=" -if exist "resources\images\game_icon.ico" ( - set "ICON_ARG=--icon resources\images\game_icon.ico" +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... +echo [3/3] Kompiliere kompakte Einzeldatei mit absoluten Ressourcen-Pfaden... "%VENV_PY%" -m PyInstaller ^ --noconfirm ^ --clean ^ @@ -89,8 +80,8 @@ echo [3/3] Kompiliere kompakte Einzeldatei... --workpath "%WORK_DIR%" ^ --specpath "%WORK_DIR%" ^ %ICON_ARG% ^ - --add-data "resources;resources" ^ - --add-data "games;games" ^ + --add-data "%PROJECT_ROOT%\resources;resources" ^ + --add-data "%PROJECT_ROOT%\games;games" ^ --collect-submodules games ^ --collect-submodules controller ^ --collect-submodules models ^ @@ -108,7 +99,7 @@ echo [3/3] Kompiliere kompakte Einzeldatei... --exclude-module pytest ^ --exclude-module unittest ^ --exclude-module pydoc ^ - main.py + "%PROJECT_ROOT%\main.py" if errorlevel 1 ( echo [ERROR] PyInstaller-Build fehlgeschlagen! @@ -121,12 +112,7 @@ echo. echo [DONE] Fertige ausfuehrbare Datei liegt bereit unter: echo dist\windows\%APP_NAME%.exe -REM Optionaler Linux-Build via WSL, falls --all uebergeben wurde if /I "%MODE%"=="--all" ( - echo. - echo ------------------------------------------------------------ - echo Pruefe optionalen Linux-Build via WSL... - echo ------------------------------------------------------------ where wsl >nul 2>nul if not errorlevel 1 ( echo [WSL] Starte Linux-Build -^> dist/linux/%APP_NAME% ... @@ -137,4 +123,4 @@ if /I "%MODE%"=="--all" ( ) endlocal -exit /b 0 +exit /b 0 \ No newline at end of file diff --git a/build_scripts/build.sh b/build_scripts/build.sh index 15eece8..279f871 100644 --- a/build_scripts/build.sh +++ b/build_scripts/build.sh @@ -7,7 +7,7 @@ # ============================================================================= set -euo pipefail -# Immer ins Projekt-Hauptverzeichnis wechseln (egal von wo das Skript gestartet wird) +# Immer ins Projekt-Hauptverzeichnis wechseln SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" cd "${PROJECT_ROOT}" @@ -34,7 +34,6 @@ echo "============================================================" echo " Building ${APP_NAME} (Single-File) -> dist/${OS_NAME}/" echo "============================================================" -# Prüfen, ob python3 + tkinter auf dem Build-Rechner vorhanden sind if ! command -v python3 >/dev/null 2>&1; then echo "[ERROR] python3 nicht gefunden." exit 1 @@ -69,8 +68,8 @@ WORK_DIR="${PROJECT_ROOT}/build/${OS_NAME}" mkdir -p "${DIST_DIR}" "${WORK_DIR}" ICON_ARGS=() -if [[ -f "resources/images/game_icon.ico" ]]; then - ICON_ARGS=(--icon "resources/images/game_icon.ico") +if [[ -f "${PROJECT_ROOT}/resources/images/game_icon.ico" ]]; then + ICON_ARGS=(--icon "${PROJECT_ROOT}/resources/images/game_icon.ico") fi STRIP_ARGS=() @@ -78,7 +77,7 @@ if command -v strip >/dev/null 2>&1; then STRIP_ARGS=(--strip) fi -echo "[3/3] Kompiliere kompakte Einzeldatei..." +echo "[3/3] Kompiliere kompakte Einzeldatei mit absoluten Pfaden..." python -m PyInstaller \ --noconfirm \ --clean \ @@ -90,8 +89,8 @@ python -m PyInstaller \ --workpath "${WORK_DIR}" \ --specpath "${WORK_DIR}" \ "${ICON_ARGS[@]}" \ - --add-data "resources:resources" \ - --add-data "games:games" \ + --add-data "${PROJECT_ROOT}/resources:resources" \ + --add-data "${PROJECT_ROOT}/games:games" \ --collect-submodules games \ --collect-submodules controller \ --collect-submodules models \ @@ -109,7 +108,7 @@ python -m PyInstaller \ --exclude-module pytest \ --exclude-module unittest \ --exclude-module pydoc \ - main.py + "${PROJECT_ROOT}/main.py" deactivate @@ -132,4 +131,4 @@ if [[ "${MODE}" == "--all" && "${OS_NAME}" == "linux" ]]; then else echo "[SKIP] Wine mit Windows-Python nicht gefunden – überspringe Windows-Cross-Build." fi -fi +fi \ No newline at end of file