@echo off :: GPCT-standalone Build Script :: UTF-8 encoding fix chcp 65001 >nul 2>&1 echo ============================================ echo GPCT-standalone Build Script echo ============================================ echo. :: Set variables set "PROJECT_DIR=C:\PPRO\TG-PlatformPlus" set "VENV_DIR=%PROJECT_DIR%\venv" set "DIST_DIR=%PROJECT_DIR%\dist" set "BUILD_DIR=%PROJECT_DIR%\build" set "SPEC_FILE=%PROJECT_DIR%\spec\GPCT-standalone.spec" echo Project Directory: %PROJECT_DIR% echo Virtual Environment: %VENV_DIR% echo. :: Check virtual environment if not exist "%VENV_DIR%\Scripts\python.exe" ( echo [ERROR] Virtual environment not found: %VENV_DIR% echo Please ensure venv is created and dependencies are installed. pause exit /b 1 ) :: Clean old build files echo [Step 1/5] Cleaning old build files... if exist "%DIST_DIR%" ( rmdir /s /q "%DIST_DIR%" echo - Removed dist directory ) if exist "%BUILD_DIR%" ( rmdir /s /q "%BUILD_DIR%" echo - Removed build directory ) :: Check version echo. echo [Step 2/5] Checking version info... "%VENV_DIR%\Scripts\python.exe" -c "import json; d=json.load(open(r'%PROJECT_DIR%\version.json')); print(' Version:', d['version']); print(' Release:', d.get('releaseTime', 'N/A'))" :: Run PyInstaller echo. echo [Step 3/5] Building with PyInstaller... echo Using spec file: %SPEC_FILE% "%VENV_DIR%\Scripts\python.exe" -m PyInstaller "%SPEC_FILE%" --clean if errorlevel 1 ( echo. echo [ERROR] PyInstaller build failed! pause exit /b 1 ) :: Copy additional files echo. echo [Step 4/5] Copying additional files... :: Create dataFile directory if not exist "%DIST_DIR%\GPCT-standalone\_internal\dataFile" ( mkdir "%DIST_DIR%\GPCT-standalone\_internal\dataFile" ) :: Copy config files copy /y "%PROJECT_DIR%\dataFile\config.json" "%DIST_DIR%\GPCT-standalone\_internal\dataFile\" >nul 2>&1 if not errorlevel 1 echo - Copied config.json copy /y "%PROJECT_DIR%\dataFile\data.db" "%DIST_DIR%\GPCT-standalone\_internal\dataFile\" >nul 2>&1 if not errorlevel 1 echo - Copied data.db :: Copy dog DLL copy /y "%PROJECT_DIR%\Syunew3D_x64.dll" "%DIST_DIR%\GPCT-standalone\_internal\" >nul 2>&1 if not errorlevel 1 echo - Copied Syunew3D_x64.dll :: Copy influxd.exe copy /y "%PROJECT_DIR%\influxd.exe" "%DIST_DIR%\GPCT-standalone\_internal\" >nul 2>&1 if not errorlevel 1 echo - Copied influxd.exe :: Verify build echo. echo [Step 5/5] Verifying build... if exist "%DIST_DIR%\GPCT-standalone\GPCT-standalone.exe" ( echo - Build successful! for %%I in ("%DIST_DIR%\GPCT-standalone\GPCT-standalone.exe") do ( echo - Executable size: %%~zI bytes ) ) else ( echo [ERROR] Build verification failed! pause exit /b 1 ) echo. echo ============================================ echo Build Complete! echo Output: %DIST_DIR%\GPCT-standalone echo ============================================ pause