Skip to content

Commit

Permalink
Add generic build script
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
  • Loading branch information
kostyanf14 authored and lstipakov committed Dec 28, 2021
1 parent 41dfbdc commit c1bd516
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
107 changes: 107 additions & 0 deletions build_all.bat
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions build_all_nosdv.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
setlocal
SET BUILD_DISABLE_SDV=Yes
call build_all.bat
28 changes: 28 additions & 0 deletions clean.bat
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c1bd516

Please sign in to comment.