SlunkCrypt/mk-profiled.cmd

54 lines
2.8 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
set ECHO="%~dp0.\etc\utils\win32\cecho.exe"
if "%MSVC_PATH%"=="" (
set "MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC"
)
if not exist "%MSVC_PATH%\Auxiliary\Build\vcvarsall.bat" (
%ECHO% red "\nMSVC not found. Please check MSVC_PATH and try again^!\n"
pause
goto:eof
)
for %%p in (x86,x64) do (
call "%MSVC_PATH%\Auxiliary\Build\vcvarsall.bat" %%p
set "TEMP_NAME=!RANDOM!-!RANDOM!"
%ECHO% white "\n------------------------------------------------------------------------------"
%ECHO% white "Clean [%%p]"
%ECHO% white "------------------------------------------------------------------------------\n"
MSBuild.exe /property:Configuration=Release /property:Platform=%%p /target:Clean /verbosity:normal "%~dp0\Slunk.sln"
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
%ECHO% white "\n------------------------------------------------------------------------------"
%ECHO% white "Instrument [%%p]"
%ECHO% white "------------------------------------------------------------------------------\n"
MSBuild.exe /property:Configuration=Release /property:Platform=%%p /property:WholeProgramOptimization=PGInstrument /property:LinkTimeCodeGeneration=PGInstrument /target:Rebuild /verbosity:normal "%~dp0\Slunk.sln"
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
%ECHO% white "\n------------------------------------------------------------------------------"
%ECHO% white "Profiling [%%p]"
%ECHO% white "------------------------------------------------------------------------------\n"
"%~dp0.\etc\utils\win32\rand.exe" | "%~dp0.\etc\utils\win32\head.exe" -c 104857600 > "%TMP%\!TEMP_NAME!.dat"
if not "%ERRORLEVEL%"=="0" goto:BuildFailed
"%~dp0.\bin\%%p\Release\slunkcrypt.exe" --self-test
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
"%~dp0.\bin\%%p\Release\slunkcrypt.exe" --encrypt "q4cmK7FEK7@v" "%TMP%\!TEMP_NAME!.dat" "%TMP%\!TEMP_NAME!.enc"
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
"%~dp0.\bin\%%p\Release\slunkcrypt.exe" --decrypt "q4cmK7FEK7@v" "%TMP%\!TEMP_NAME!.enc" "%TMP%\!TEMP_NAME!.out"
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
del /F "%TMP%\!TEMP_NAME!.dat" "%TMP%\!TEMP_NAME!.enc" "%TMP%\!TEMP_NAME!.out"
%ECHO% white "\n------------------------------------------------------------------------------"
%ECHO% white "Re-compile [%%p]"
%ECHO% white "------------------------------------------------------------------------------\n"
MSBuild.exe /property:Configuration=Release /property:Platform=%%p /property:WholeProgramOptimization=PGOptimize /property:LinkTimeCodeGeneration=PGOptimization /target:Build /verbosity:normal "%~dp0\Slunk.sln"
if not "!ERRORLEVEL!"=="0" goto:BuildFailed
)
%ECHO% green "\nBuild completed successfully.\n"
pause
goto:eof
:BuildFailed
%ECHO% red "\nBuild has failed ^!^!^!\n"
pause