@echo off setlocal REM ============================================================ REM LedDisplayDeviceTest - Windows package script REM REM Usage: REM pkg_leddisplaydevicetest.bat REM pkg_leddisplaydevicetest.bat REM REM Default input: REM GrabBagPrj\build\Test\LedDisplayDeviceTest\release REM Output: REM GrabBagPrj\buildwin\LedDisplayDeviceTest REM REM Qt path (either form is accepted): REM QT_PATH=D:\Qt\5.15.2 REM QT_PATH=D:\Qt\5.15.2\msvc2019_64 REM ============================================================ set "PRJ_PATH=%~dp0" set "PRJ_PATH=%PRJ_PATH:~0,-1%" set "APP_NAME=LedDisplayDeviceTest" set "OUT_DIR=%PRJ_PATH%\buildwin\%APP_NAME%" set "DEFAULT_EXE=%PRJ_PATH%\build\Test\%APP_NAME%\release\%APP_NAME%.exe" set "README_SOURCE=%PRJ_PATH%\..\Test\%APP_NAME%\README.md" set "WINDEPLOYQT=" if not defined QT_PATH ( echo [ERROR] QT_PATH is not configured. echo Set QT_PATH to the Qt version or kit directory, for example: echo set QT_PATH=^ exit /b 1 ) if exist "%QT_PATH%\bin\windeployqt.exe" ( set "WINDEPLOYQT=%QT_PATH%\bin\windeployqt.exe" ) else if exist "%QT_PATH%\msvc2019_64\bin\windeployqt.exe" ( set "WINDEPLOYQT=%QT_PATH%\msvc2019_64\bin\windeployqt.exe" ) else ( echo [ERROR] windeployqt.exe was not found under QT_PATH: echo %QT_PATH% echo Configure QT_PATH correctly and run this script again. exit /b 1 ) if not "%~1"=="" ( set "EXE_SOURCE=%~f1" ) else ( set "EXE_SOURCE=%DEFAULT_EXE%" ) if not exist "%EXE_SOURCE%" ( echo [ERROR] Executable not found: echo %EXE_SOURCE% echo. echo Build the Release target first, or pass the executable path: echo %~nx0 ^ exit /b 1 ) if not exist "%README_SOURCE%" ( echo [ERROR] README not found: echo %README_SOURCE% exit /b 2 ) if not exist "%OUT_DIR%" mkdir "%OUT_DIR%" if errorlevel 1 ( echo [ERROR] Failed to create output directory: echo %OUT_DIR% exit /b 3 ) powershell -NoProfile -Command ^ "Get-ChildItem -LiteralPath '%OUT_DIR%' -Force | Remove-Item -Recurse -Force" if errorlevel 1 ( echo [ERROR] Failed to clean output directory: echo %OUT_DIR% exit /b 4 ) copy /y "%EXE_SOURCE%" "%OUT_DIR%\%APP_NAME%.exe" >nul if errorlevel 1 ( echo [ERROR] Failed to copy executable. exit /b 5 ) copy /y "%README_SOURCE%" "%OUT_DIR%\README.md" >nul if errorlevel 1 ( echo [ERROR] Failed to copy README.md. exit /b 6 ) "%WINDEPLOYQT%" --release --no-translations "%OUT_DIR%\%APP_NAME%.exe" if errorlevel 1 ( echo [ERROR] windeployqt failed. exit /b 7 ) echo. echo === %APP_NAME% Windows packaging completed === echo Output directory: %OUT_DIR% echo. echo Qt runtime files were deployed with windeployqt. echo The target computer must have the Microsoft Visual C++ echo 2015-2022 Redistributable ^(x64^) installed. echo. endlocal exit /b 0