From c1bd516fa148e7ccde730ff681c519111082a7d4 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Thu, 23 Dec 2021 17:40:44 -0800 Subject: [PATCH] Add generic build script Signed-off-by: Kostiantyn Kostiuk --- build_all.bat | 107 ++++++++++++++++++++++++++++++++++++++++++++ build_all_nosdv.bat | 4 ++ clean.bat | 28 ++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 build_all.bat create mode 100644 build_all_nosdv.bat create mode 100644 clean.bat diff --git a/build_all.bat b/build_all.bat new file mode 100644 index 0000000..ff84a10 --- /dev/null +++ b/build_all.bat @@ -0,0 +1,107 @@ +@echo off +setlocal + +if "%CODEQL_HOME%"=="" set CODEQL_HOME=c:\codeql-home +set CODEQL_BIN=%CODEQL_HOME%\codeql\codeql.cmd + +if "%EWDK11_DIR%"=="" set EWDK11_DIR=c:\ewdk11 + +call "%EWDK11_DIR%\BuildEnv\SetupBuildEnv.cmd" + +set SOLUTION_FILE=ovpn-dco-win.sln +set DRIVER_PROJECT_FILE=ovpn-dco-win.vcxproj + +for %%C in ( Release Debug ) do ( + for %%P in ( x64 x86 ) do ( + echo Building %SOLUTION_FILE%, configuration %%C, platform %%P + call :runbuild %SOLUTION_FILE% %%C %%P + ) +) + +if not "%BUILD_DISABLE_SDV%"=="" ( + echo Skipping SDV build because BUILD_DISABLE_SDV is set + goto :end +) + +echo Running SDV for %DRIVER_PROJECT_FILE%, configuration "Release", platform x64 +call :runsdv %DRIVER_PROJECT_FILE% "Release" x64 +call :runql %DRIVER_PROJECT_FILE% "Release" x64 +call :runca %DRIVER_PROJECT_FILE% "Release" x64 + +call :rundvl %DRIVER_PROJECT_FILE% "Release" x64 + +:end: + +if "%BUILD_FAILED%"=="1" exit /B 1 +exit /B 0 + +:runbuild: +:: %1 - build file (as "ovpn-dco-win.sln") +:: %2 - configuration (as "Release") +:: %3 - platform (as x64) +msbuild.exe "%~1" /p:Configuration="%~2" /P:Platform=%3 +goto :eof + +:runsdv +msbuild.exe "%~1" /t:clean /p:Configuration="%~2" /P:Platform=%3 + +IF ERRORLEVEL 1 ( + set BUILD_FAILED=1 +) + +msbuild.exe "%~1" /t:sdv /p:inputs="/clean" /p:Configuration="%~2" /P:Platform=%3 + +IF ERRORLEVEL 1 ( + set BUILD_FAILED=1 +) + +msbuild.exe "%~1" /t:sdv /p:inputs="/check /devenv" /p:Configuration="%~2" /P:Platform=%3 + +IF ERRORLEVEL 1 ( + set BUILD_FAILED=1 +) + +goto :eof + +:runql + +echo "Removing previously created rules database" +rmdir /s/q codeql_db + +echo call "%EWDK11_DIR%\BuildEnv\SetupBuildEnv.cmd" > %~dp1\codeql.build.bat +echo msbuild.exe "%~dp1\%~1" /t:rebuild /p:Configuration="%~2" /P:Platform=%3 >> %~dp1\codeql.build.bat + +call %CODEQL_BIN% database create -l=cpp -s=%~dp1 -c "%~dp1\codeql.build.bat" %~dp1\codeql_db -j 0 + +IF ERRORLEVEL 1 ( + set CODEQL_FAILED=1 + set BUILD_FAILED=1 +) + +IF "%CODEQL_FAILED%" NEQ "1" ( + call %CODEQL_BIN% database analyze %~dp1\codeql_db windows_driver_recommended.qls --format=sarifv2.1.0 --output=%~dp1\%DRIVER_PROJECT_FILE%.sarif -j 0 +) + +IF ERRORLEVEL 1 ( + set BUILD_FAILED=1 +) + +goto :eof + +:runca +msbuild.exe "%~1" /p:Configuration="%~2" /P:Platform=%3 /P:RunCodeAnalysisOnce=True + +IF ERRORLEVEL 1 ( + set BUILD_FAILED=1 +) + +goto :eof + +:rundvl +msbuild.exe "%~1" /t:dvl /p:Configuration="%~2" /P:Platform=%3 + +IF ERRORLEVEL 1 ( + set BUILD_FAILED=1 +) + +goto :eof \ No newline at end of file diff --git a/build_all_nosdv.bat b/build_all_nosdv.bat new file mode 100644 index 0000000..6d83129 --- /dev/null +++ b/build_all_nosdv.bat @@ -0,0 +1,4 @@ +@echo off +setlocal +SET BUILD_DISABLE_SDV=Yes +call build_all.bat diff --git a/clean.bat b/clean.bat new file mode 100644 index 0000000..9d3d1e4 --- /dev/null +++ b/clean.bat @@ -0,0 +1,28 @@ +@echo off +setlocal + +call :rmdir .\Win32 +call :rmdir .\x64 +call :rmdir .\Debug +call :rmdir .\Release + +call :rmdir .\ovpn-cli\x64 +call :rmdir .\ovpn-cli\Debug +call :rmdir .\ovpn-cli\Release + +call :rmdir .\sdv +call :rmdir .\sdv.temp +call :rmdir .\codeql_db +call :rmfiles *.dvl.xml *.sarif codeql.build.bat +call :rmfiles *.log +goto :eof + +:rmdir +if exist "%~1" rmdir "%~1" /s /q +goto :eof + +:rmfiles +if "%~1"=="" goto :eof +if exist "%~1" del /f "%~1" +shift +goto rmfiles