@ECHO OFF REM //======================================================================== REM // Copyright (c) Technische Software Entwicklung Plazotta © 2021 REM // REM // DESCRIPTION: REM // Batch Building a VS2017 INtime Project, running the Unittest and finally start the install step REM // REM // HISTORY: REM // 27.07.2021 / DM REM // Module created. REM // Refactored for INtime with PP's Windows Template. REM //======================================================================== setlocal setlocal enabledelayedexpansion pushd . REM ======================================================================= REM Check Parameter REM ======================================================================= set TestFiles=%3 set TestFiles=%TestFiles:"=% @if "%1"=="" goto HELP @if "%2"=="" goto HELP @if "%TestFiles%"=="" goto NO_PARSE set TestFiles=%TestFiles:,= % :NO_PARSE REM ======================================================================= REM Show Parameter REM ======================================================================= echo ======================================================================= echo Build Parameter echo ======================================================================= echo Project = %1 echo Configuration = %2 echo Unit Test Executable = %TestFiles% echo ======================================================================= echo . REM ======================================================================= REM Setup the VS2017 environment REM ======================================================================= call "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\vsdevcmd" REM REM ======================================================================= REM Rebuild the project REM ======================================================================= cd ..\..\..\BuildResults\msvc2017_INtime devenv %1.sln /rebuild %2 IF %ERRORLEVEL% NEQ 0 goto ERROR REM REM ======================================================================= REM Before running the unit tests delete the LdrtaResult file REM to be sure the loop can work properly REM ======================================================================= del /f ..\..\AutoBuild\INtime\scripts\LdrtaResult.txt REM REM ======================================================================= REM Run all unit tests REM ======================================================================= for %%f in (%TestFiles%) do ( start ldrta.exe %2\bin\%%f.rta if !ERRORLEVEL! NEQ 0 goto ERROR ) REM REM ======================================================================= REM Loop for recognizing the creation of the LdrtaResult file. REM After check unit tests were successfully, otherwise error REM ======================================================================= cd ..\..\AutoBuild\INtime\scripts set /a CounterEnd=120 set /a Counter=0 set /a OkResult=0 set LdrtaFile=LdrtaResult.txt :LOOP echo Checking if the unit tests have created the result file if exist "%LdrtaFile%" ( echo File was created set /p Result=<"%LdrtaFile%" goto FILECREATED ) else ( echo File was not created goto FILENOTCREATED ) :FILECREATED if %Result% EQU %OkResult% ( echo Continueing AllBuild process goto CONTINUE ) else ( echo Unit tests failed ... goto ERROR ) :FILENOTCREATED if %Counter% EQU %CounterEnd% ( goto ERROR ) else ( set /a Counter=%Counter%+1 timeout /t 2 /nobreak echo Timeout corresponds to 2 seconds set /a CounterX2=%Counter%*2 echo Current total timeout counter: %CounterX2% goto LOOP ) REM REM ======================================================================= REM Install files REM ======================================================================= :CONTINUE cd ..\..\..\BuildResults\msvc2017_INtime devenv %1.sln /build %2 /Project INSTALL IF %ERRORLEVEL% NEQ 0 goto ERROR goto END REM REM ======================================================================= REM Error REM ======================================================================= :ERROR echo Error during build ... exit /b 1 REM REM ======================================================================= REM HELP REM ======================================================================= :HELP echo Usage BuildVs2017INtimeProject [ProjectName] [Configuration] [UnitTestExe] echo . :END exit /b 0