change_code/build_advanced.bat

151 lines
3.2 KiB
Batchfile

@echo off
chcp 65001 >nul
title Build UFT30 ChangeCode - Advanced
echo.
echo ==========================================
echo Build UFT30 ChangeCode (Advanced)
echo ==========================================
echo.
REM Set paths
set QT_PATH=D:\01.InstallInfo\InstallPath\QT\6.6.2\mingw_64
set MINGW_PATH=D:\01.InstallInfo\InstallPath\QT\Tools\mingw1120_64
REM Check paths
if not exist "%QT_PATH%\bin\qmake.exe" (
echo ERROR: Cannot find qmake.exe
echo Please check QT_PATH variable
pause
exit /b 1
)
if not exist "%MINGW_PATH%\bin\mingw32-make.exe" (
echo ERROR: Cannot find mingw32-make.exe
echo Please check MINGW_PATH variable
pause
exit /b 1
)
REM Set PATH
set PATH=%QT_PATH%\bin;%MINGW_PATH%\bin;%PATH%
echo [OK] Environment configured
echo.
:MENU
echo Please select build type:
echo 1 - Debug (with debug info)
echo 2 - Release (optimized for release)
echo 3 - Both (Debug + Release)
echo 4 - Exit
echo.
set /p BUILD_TYPE="Enter option (1-4): "
if "%BUILD_TYPE%"=="1" goto BUILD_DEBUG
if "%BUILD_TYPE%"=="2" goto BUILD_RELEASE
if "%BUILD_TYPE%"=="3" goto BUILD_BOTH
if "%BUILD_TYPE%"=="4" goto EXIT_SCRIPT
echo ERROR: Invalid option, please try again
echo.
goto MENU
:BUILD_DEBUG
echo.
echo [Selected] Debug version
call :DO_BUILD Debug
goto END_SUCCESS
:BUILD_RELEASE
echo.
echo [Selected] Release version
call :DO_BUILD Release
goto END_SUCCESS
:BUILD_BOTH
echo.
echo [Selected] Both versions
echo.
call :DO_BUILD Debug
echo.
call :DO_BUILD Release
goto END_SUCCESS
:EXIT_SCRIPT
echo.
echo [Exit] Script terminated
pause
exit /b 0
:DO_BUILD
set BUILD_NAME=%~1
echo.
echo ==========================================
echo Building %BUILD_NAME% version
echo ==========================================
REM Check and close running program
echo.
echo [1/4] Checking running program...
tasklist /FI "IMAGENAME eq Uft30ChangeCode.exe" 2>NUL | find /I /N "Uft30ChangeCode.exe">NUL
if "%ERRORLEVEL%"=="0" (
echo [WARN] Program is running, closing...
taskkill /F /IM "Uft30ChangeCode.exe" >nul 2>&1
timeout /t 1 /nobreak >nul
echo [OK] Program closed
)
REM Clean old files
echo.
echo [2/4] Cleaning old build files...
if exist Makefile del /Q Makefile
if exist Makefile.Debug del /Q Makefile.Debug
if exist Makefile.Release del /Q Makefile.Release
if exist .qmake.stash del /Q .qmake.stash
if exist debug rmdir /S /Q debug 2>nul
if exist release rmdir /S /Q release 2>nul
echo [OK] Old files cleaned
REM Run qmake
echo.
echo [3/4] Running qmake...
qmake Uft30ChangeCode.pro -spec win32-g++
if errorlevel 1 (
echo ERROR: qmake failed
exit /b 1
)
echo [OK] qmake done
REM Compile
echo.
echo [4/4] Compiling...
if "%BUILD_NAME%"=="Debug" (
mingw32-make debug
) else (
mingw32-make release
)
if errorlevel 1 (
echo ERROR: Compilation failed
exit /b 1
)
echo [OK] %BUILD_NAME% version compiled!
goto :eof
:END_SUCCESS
echo.
echo ==========================================
echo Build SUCCESSFUL!
echo ==========================================
echo.
echo Output: bin\Uft30ChangeCode.exe
echo.
if exist "bin\uf2touft3\uf2touft3.exe" (
echo [OK] uf2touft3.exe found, everything is ready!
) else (
echo [WARN] Please make sure bin\uf2touft3\uf2touft3.exe exists
)
echo.
pause