Skip to content

Commit

Permalink
[build] Basic fixes and extentions to build scripting
Browse files Browse the repository at this point in the history
 1. Fixed various syntax issues, including an unquoted variable in
    conditional test (Debug or Release log file name), superfluous
    backslashes, spaces between errorlevel tests and tested functions,
    MSBuild syntax consolidaiton, prefixing FOR do commands with @, etc.
 2. Unwrapped nested IF statements to ensure no jumping out of loops
    or other unexpected behaviours.
 3. Updated usage, including Win11 target and explanation regarding
    analysis builds (build.bat only).
 4. Added analysis build specific variables CODEQL_FAILED and SDV_FAILED
    to init area (build.bat only).
 5. Refactored fail code, removing return failure detection in favour
    of in-line failure detection.
 6. Updated labels to use snake style notation.
 7. Refactored end of build_arch function to avoide "goto :eof" and
    instead use ":build_arch_done" to ensure POPD occurs and
    ":build_arch_skip" to check for success before ending the local
    environment (build.bat only).
 8. Do conditional (if exists) removal of sdv and codeql_db folders
    (build.bat only).
 9. Additional commenting and stdout output (logging).
10. Remove superfluous newline spacing.
11. Removed packaging folder from build per PRs virtio-win#1209 and virtio-win#1224
    (buildAll.bat only).
12. Consolidated exiting function (whether success or fail) to
    :leave (buildAll.bat only).

Split from PR virtio-win#1212.

     .,ueeeeeu,
   e$$$$$P?$$$$$b
 :$$$$"      '$$$$c
 $$$$          $$$$c
 $$$6          $$$$$
 $$$F          $$$$"
 $$$F          $$$F
 $$$$         $$$F
 $$$$        J$$F                                   .ccCCCCCCCCc,.
 ?$$$        $$$$$$e                             ,CCCCCCCCCCCCCCCCCCc
 :$$$        `$$$$$"                            CCCCCCCCCCCCCC" CCCCCC.
 `$$$.                                         CCCCCCCCCCC" .,d.`CCCCCC.
  $$$t             .,uuuuu,.                  <CCC  . `"",$$$$$$L CCCCCC
  ?$$$          ,HHHHHHHHHHHHHb,               CCC $$$$$$$$$P"""" `CCCCC
  `$$$        4F"" .,uuuuuuu,,,,.              `CC '=-  "$$$="""$$r C><C
  `$$$,      zuHF""`.,,,,,,. ""??HH             `CC bue$:$$$$bd$$$ C ? C
   $$$$      -=='.ee???$eeeec,,,.`=.             `C $$$$ $$P???$$$ C  cC
   ?$$$     ,H""  .e$P"""?heeee,,.""               .'P .cc-=<Cc,  cC'CC'
   `$$$    HH jF $$$b,/"""cd$$..,,)                 \ dP".  .,cCCCP u
   `$$$. .HHH H':F $$$du,$$$$ ' ";l                  CCCCCCCCCCCCC'.$$
    $$$h HHHF H H  "$$$$$F d$ 4$$ H                ,z "?CCCCCCCCP J$$ :: $
    ?$$$ HHH'jF.H % $P" ...'" u$ J'            .d$$$$F .   ....zd$P" :::d$
    :$$$ HHH H HF %%,%%"     %' dH           j$$$$$$$$ :::        ::::: $$
             ? HF %%%%%.%. " % JHf        :: $$$$$$$$$. :::::::::::::::d$$
 .:::::::::::::   '%%%%%%%%%%/ H"      ::::: $$$$$$$$$$ ::::::::::::::d$$$
:::'``````````'::: `%%%%%%%%% JH dH   :::::: ?$$$$$$$$$ `:::::::::::: $$$$
..:::::::::::::::.  %%%%%%/', H" H",""  `::: ?$$$$$$$$$" :::::::::::`$$$$$
   ... . ::: : . `: `eeeee;".F -.H dHHHHc.    $$$$$F"`.=" `:::::::` '?$$$$
:::::   .ze$eu  . `:  =uuuu/"z".H" HHHHHHHHHHe. "" e$$$$$$b  :::: ee,. '$$
'   z$$$$$$$$$$$$$  `.zeed?"".dHF HHHHHHHHHHHHHH  $$$$$beeem ': ec,"$$$$ '
 : 4$$$ .   $$$$??  beeeeeedHF"".HHHHHF"" _,,..    `$$$$cze= ':,,`"$$$$$$$
:  $$$$$b,,d$F  ,  .HHF""".,zeHHHHF" ,i!"` .,;i!!!i;. ?$bee` ::`""9$$$$$$$
: $$$$$$$$$$$L.,  c,,eeHHHHHHHHF ,i!' .;!!!!!!!!!!!!!!.  . ::::""??$$$$$$$
 J$$$$$??$,`'". .HHHHHHHHHHHH" ,!!'.i!!!!!!!!!!!!!!!!!!  \ ::::: d$bc."??$
 "$$$$$$h  .; .HHHHHHHHHHHF" ,!!',! !!!!!!''''`  '''<!!i  ? :::: d$$$$$
:$ "$$$$$$$F uHHHHHHHHHHH" ,!! ,!! !!!"                !i    :::  $$$$$
$$$    """    "HHHHHHHHH ,!!',!!!! !" .d$$$$ezece$$$,   !    ::: d$$$$$'
...:  ::::::::  3HHHHH" ,!!',!!!!!   d$$$$$$$$$$$$$$$t   >   ::: d$$$$$
:::: ::` .:::::  HHHHF ,!!' !!!!!!  9$$P""""?$$$$$$$$"   ! ; `:: $$$$$$ :
:::   .::::::::: ?HH" ,!!! !!!!!!!  3$$$.``''$$$F - ;    ! ! `:  $$$$$$`::
::  .:::::::::::  H" ,!!!'<!!!!!!!i  $$$$$$$$$$ teeJ' .  ! !  : d$$$$$$`::
` .:::::::::::::: " ,!!!! <!!!!!!!!   $$$$$$P??'?$$      ! !i ` d$$$$$$L::
 :::::::::::        `<!!! !!!!!!!!'   '$$u,"""" ,' .  ;  ! `!.  d$$$$$$$::
.:::::::  aeeee$$$$$$e   <!!!!!!!'   '.^$$$$$$F'  ;      !! !!, $$$$$$$$`:
::::::::::`""777d$$$$$$u  !!!!!!   '  $$ee...e%  <  ,    !! `!!i$$$$$$$L :
 ``````::`` d$$$$$  ?$$$b `!!!'  , .  $$$$$$$$    .     . !! !!!,$$$$$$$ :
eccec,.  ,zd$$$$$$$$$$>$L; !'   ; ,   """""""       ;    \ `! !!!,?$$$$$ `
$$$$$$$$d$$$$$$$$$P""""` .  .  '     !!!!!!!!! .    `;  ` `  !, !!i"$$$$ `
$$$$$$$$$$$$$$$$$F    i!!'    ,'   .. .. ``!!! !     `;  \ `   `\`!!.$$$L
>>>"""""""??$$$$k ==" !!'  ' ,  , d$$" u":". !! !  \  `;  `   i!i,`!!, ?$F
$$$$UUU$$$$u,"?$$$ =" r   '    $F4 ".$$LJ 3$L !!,`  ',    \ !!i,.`!i.`!.$
$$$$$$$$$$$ec. d$$$  f     '" $$F4.$"zP"$$b."b  !!,` '!  . :!!!!!!i.`!i
"""```"=??he,  ?$$$b ,i'!  ! d$$$$$d$b$$$$$$F?$       `!=''  ..... `!,!i
,,,,  ,,,   ::: $$$$ `!i 'i" $$$$$$$$$$$$$$$c`" d$$$$$$bc, "?$$$$$$$.!,`!i
$$$' $$$ '::::: '$$$> !!!!!   `?$$$$$$$$$$$$F  d$$$$$$$$$$F,u.'$$$$$$c!i`!
 : .$$$"x :::::  $$$ i!!!!!, $.   ``"""""" .,z$$$P"?$$$",ed$$$b $$$$$$i!!!
$e $$$" $R ::::: 3$$ !!!!!!!,`$$bd"uer  .dP"""?$$. ?y, "4$$$$$$,`$$$$Fi!!!
" d$$$  :::::::: )$$ !!!!!!i   `$$bc      . "?bey,. `d$$e `$$$$F $PP"i!!!!
 d$$F $r ::::::  $$$ )!!!!!!     `$$$L".W. "?$by,`"d$$$$$$c $$$" .eeeeu '!
J$$" :  .::::  . """ !!!!!!!i.     `??$  .,._ `"3$$$$$$$$$b,,,d$$$$$$$$c
"$" ::::::'    :  !!!!!!!!!!!!i;;i! ueee. `"?$$$$$$$$$$$$$$$$$$$$$$$$$$$F
:.:::::::  `:: :: <!!!!!!!!!!!!> z$$$$$$$$$$$be..`'<<<??$$$$$$$$$$$$$$$F.i
::::::::  : :: ::  !!!!!!!!!!!':$$$$$$$$$$$$$$$$$$beeeeeee,.    ```"`,i!!!
::::::  ::: ::: :  !!!!!!!!!' . ""??$$$$$$$$$$$$$$PF"""'`  .,,;;ii!!!!!!!!
:::::   ::: `:: :: `!!!!!!!  !!!!!i,,,,...  .....,,,;;;ii!!!!!!!!!!!!!!!!!
:::  :: :::: :: ::  !!!!!' ,!!!!!!!!!!!!",!!!!!!!!!!!!!!!!!,`!!!!!!!!!!!!!
:`  ':: :::: :: ::  !!!!' !!!!!!!!!!!!! ,!!!!!!!!!!!!!!!!!!!i!!!!!!!!!!!!!
 .:: :: :::: :: ::  !!!' !!!!!!!!!!!!'.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
:::: :: :::: :: ::  !!' !!!!!!!!!!!!',!!!!''.,;;;;;,.`'''''''`!!!!!!!!!!!!
:::: :' :::: `: `:  !'.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!i;,,..`'<!!!!!
::: :' ::::: :: ::   .!!!! .!!!!!!!i!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!i;;,, '
::`.: .:''` ..  . `` .  '  , '!!!!i!!!!>:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       ...\..>\\.\\.\\\\ ,/ |,   ''```''`<<''<'<<<<<<<!!!!!!!!!!!!!!!!!!!!
`\>/`\\\>\%`%%"./'%..\=///,%//,,/', ,/'' ,/   ,  `'''''''''''''''''!!!!!!!
//>;>;\.""./';./>.`\- |`/./'','./|'"/`\\</%/'//%','::::::::::::::::!!!!!!'
\.:\'.'///'">>>`,`/'.  '. ,` ,/',/',|%//<</,'<^< -=-<'\\'-::``,::'.!!!'` .
/==>'/%.////;.//>>,/,;,.-.`\`,..\`<.\\=\\-^//=/<<\\%'- ' .,::` ..:' '`.:::
'/'/''/'/>.''</>(\<|/%<%///>\`\%</>>\\%\\\>/\'\\\\< `.,''  ..::'`.:.::::'`
/',/"><|,/','/'>,/,/'>/|/>\\`|"\|<``\`\"" \<```.,,'``  ..::::..:::: :::
::::::::::::::::::::::...::::::::::::::::::::''` ...::::::::::::::: :::
............................................. .:::::::::::::::::::: :::
::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::   .

Signed-off-by: benyamin-codez <[email protected]>
  • Loading branch information
benyamin-codez committed Dec 24, 2024
1 parent a01c696 commit fdf1f44
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 98 deletions.
247 changes: 155 additions & 92 deletions build/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ rem Debug, dbg, chk .. to build Debug rather than the default release fl
rem amd64, x64, 64 .. to build only 64-bit driver
rem x86, 32 .. to build only 32-bit driver
rem /Option .. build command to pass to VS, for example /Rebuild
rem Win10 .. target OS version
rem Win10, Win11 .. target OS version
rem
rem By default the script performs an incremental build of both 32-bit and 64-bit
rem release drivers for all supported target OSes.
rem
rem To do a Static Driver Verifier build, append _SDV to the target OS version, for
rem example Win10_SDV.
rem To do a Static Driver Verifier build, append the _SDV tag to the target OS version,
rem for example Win10_SDV. Where SDV is deprecated, we rely on CodeQL, defaulting to
rem the WHCP_24H2 configuration. To use an earlier configuration specify WHCP_LEGACY.
rem We also continue to run Code Analysis (CA) and Driver Verifier Log (DVL) builds
rem for use with HCK / WHCP.
rem ================================================================================

rem This is a list of supported build target specifications A_B where A is the
Expand All @@ -38,6 +41,10 @@ set BUILD_SPEC=
set BUILD_ARCH=
set BUILD_FAILED=

rem Analysis Build specific variables
set CODEQL_FAILED=
set SDV_FAILED=

rem Parse arguments
:argloop
shift /2
Expand All @@ -60,21 +67,27 @@ rem Assume that this is target OS version and split off the tag
call :split_target_tag "%ARG%"

rem Verify that this target OS is supported and valid
for %%N in (%SUPPORTED_BUILD_SPECS%) do (
for %%N in (%SUPPORTED_BUILD_SPECS%) do @(
set T=%%N
set CANDIDATE_SPEC=
set FOUND_MATCH=

for %%A in ("!T:_=" "!") do (
if /I %%A=="%TARGET%" set CANDIDATE_SPEC=!T!!TAG!
for %%B in (%BUILD_TARGETS%) do (
if /I %%B==%%~A!TAG! set FOUND_MATCH=1
for %%A in ("!T:_=" "!") do @(
if /I %%A=="%TARGET%" (
set CANDIDATE_SPEC=!T!!TAG!
)
for %%B in (%BUILD_TARGETS%) do @(
if /I %%B==%%~A!TAG! (
set FOUND_MATCH=1
)
)
)

if not "!FOUND_MATCH!"=="" if not "!CANDIDATE_SPEC!"=="" (
set BUILD_SPEC=!CANDIDATE_SPEC!
goto :argloop
if not "!FOUND_MATCH!"=="" (
if not "!CANDIDATE_SPEC!"=="" (
set BUILD_SPEC=!CANDIDATE_SPEC!
goto :argloop
)
)
)

Expand All @@ -93,17 +106,18 @@ goto :eof
rem Figure out which targets we're building
:argend
if "%BUILD_SPEC%"=="" (
for %%B in (%BUILD_TARGETS%) do (
for %%B in (%BUILD_TARGETS%) do @(
call :split_target_tag "%%B"
for %%N in (%SUPPORTED_BUILD_SPECS%) do (
for %%N in (%SUPPORTED_BUILD_SPECS%) do @(
set T=%%N
set BUILD_SPEC=
for %%A in ("!T:_=" "!") do (
if /I %%A=="!TARGET!" set BUILD_SPEC=!T!!TAG!
for %%A in ("!T:_=" "!") do @(
if /I %%A=="!TARGET!" (
set BUILD_SPEC=!T!!TAG!
)
)
if not "!BUILD_SPEC!"=="" (
call :build_target !BUILD_SPEC!
if not "!BUILD_FAILED!"=="" goto :fail
)
)
)
Expand All @@ -116,163 +130,212 @@ rem Figure out which archs we're building
:build_target
if "%BUILD_ARCH%"=="" (
call :build_arch %1 x86
if not "!BUILD_FAILED!"=="" goto :eof
call :build_arch %1 amd64
) else (
call :build_arch %1 %BUILD_ARCH%
)
goto :eof

rem Invoke Visual Studio
rem Invoke Visual Studio and CodeQL as needed...
:build_arch
setlocal
set BUILD_ARCH=%2
set TAG=
for /f "tokens=1 delims=_" %%T in ("%1") do (
set TARGET_PROJ_CONFIG=%%T
)
for /f "tokens=2 delims=_" %%T in ("%1") do (
set TARGET_PLATFORM=%%T
)
for /f "tokens=3 delims=_" %%T in ("%1") do (
set TAG=%%T
)
for /f "tokens=1 delims=_" %%T in ("%1") do @set TARGET_PROJ_CONFIG=%%T
for /f "tokens=2 delims=_" %%T in ("%1") do @set TARGET_PLATFORM=%%T
for /f "tokens=3 delims=_" %%T in ("%1") do @set TAG=%%T

if /I "!TAG!"=="SDV" (
rem There is no 32-bit SDV build
if %BUILD_ARCH%==x86 goto :eof
if %BUILD_ARCH%==x86 (
goto :build_arch_skip
)
rem Check the SDV build suppression variable
if not "%_BUILD_DISABLE_SDV%"=="" (
echo Skipping %TARGET_PROJ_CONFIG% SDV build because _BUILD_DISABLE_SDV is set
goto :eof
goto :build_arch_skip
)
)

rem Compose build log file name
if %BUILD_FLAVOR%=="Debug" (
if "%BUILD_FLAVOR%"=="Debug" (
set BUILD_LOG_FILE=buildchk
) else (
set BUILD_LOG_FILE=buildfre
)
set BUILD_LOG_FILE=%BUILD_LOG_FILE%_%TARGET_PLATFORM%_%BUILD_ARCH%.log

if %BUILD_ARCH%==amd64 set BUILD_ARCH=x64
if %BUILD_ARCH%==amd64 (
set BUILD_ARCH=x64
)
set TARGET_VS_CONFIG="%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%|%BUILD_ARCH%"

rem We set up the Build Environment and get started...
echo.
pushd %BUILD_DIR%
call "%~dp0\SetVsEnv.bat" %TARGET_PROJ_CONFIG%
call "%~dp0SetVsEnv.bat" %TARGET_PROJ_CONFIG%

rem Split builds between Code Analysis and No-Analyis...
if /I "!TAG!"=="SDV" (
echo Running SDV for %BUILD_FILE%, configuration %TARGET_VS_CONFIG%
call :runsdv "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
echo.
rem SDV is deprecated from Germanium EWDK and Windows 11 24H2. Making some allowances...
rem We only do SDV for Win10 targets.
if "%TARGET%"=="Win10" (
echo Running SDV for %BUILD_FILE%, configuration %TARGET_VS_CONFIG%
call :run_sdv "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
if "%BUILD_FAILED%" EQU "1" (
echo Static Driver Verifier BUILD FAILED - Resolve problem and try again.
goto :build_arch_done
)
echo Static Driver Verifier build for %BUILD_FILE% succeeded.
) else (
echo Skipping SDV for %BUILD_FILE%, configuration %TARGET_VS_CONFIG%. SDV is for WHCP_LEGACY targets ONLY.
echo.
)
if exist "%CODEQL_BIN%" (
echo Running CodeQL for %BUILD_FILE%, configuration %TARGET_VS_CONFIG%
call :runql "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
call :run_ql "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
if "!CODEQL_FAILED!" EQU "1" (
set BUILD_FAILED=1
echo CodeQL - BUILD FAILED - Resolve problem and try again.
goto :build_arch_done
)
echo CodeQL build for %BUILD_FILE% succeeded.
) else (
echo CodeQL binary is missing!
@echo.
)
call :run_ca "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
if "!BUILD_FAILED!" EQU "1" (
echo Code Analysis BUILD FAILED.
goto :build_arch_done
)
echo Code Analysis build for %BUILD_FILE% succeeded.
echo.
call :run_dvl "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
if "!BUILD_FAILED!" EQU "1" (
echo Driver Verifier Log BUILD FAILED.
goto :build_arch_done
)
call :runca "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
call :rundvl "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
echo Driver Verifier Log build for %BUILD_FILE% succeeded.
echo.
) else (
rem Do a build without analysis.
echo Building %BUILD_FILE%, configuration %TARGET_VS_CONFIG%, command %BUILD_COMMAND%
call :runbuild "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
call :run_build "%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%" %BUILD_ARCH%
if "!BUILD_FAILED!" EQU "1" (
echo NO-ANALYSIS BUILD FAILED.
goto :build_arch_done
)
echo No-Analysis build for %BUILD_FILE% succeeded.
echo.
)
:build_arch_done
popd
endlocal

IF ERRORLEVEL 1 (
set BUILD_FAILED=1
:build_arch_skip
if not "!BUILD_FAILED!"=="" (
goto :fail
)
endlocal
goto :eof

:runbuild:
:run_build
:: %1 - configuration (as "Win10 Release")
:: %2 - platform (as x64)
:: %3 - build command (as "/Build")
set __TARGET__=%BUILD_COMMAND:/=%
::(n)ormal(d)etailed,(disg)nostic
set __VERBOSITY__=n
msbuild.exe -maxCpuCount %BUILD_FILE% /t:%__TARGET__% /p:Configuration="%~1" /P:Platform=%2 -fileLoggerParameters:Verbosity=%__VERBOSITY__%;LogFile=%BUILD_LOG_FILE%
goto :eof

:runsdv
echo "Removing previously created SDV artifacts"
rmdir /s/q sdv

msbuild.exe -maxCpuCount %BUILD_FILE% /t:clean /p:Configuration="%~1" /P:Platform=%2

IF ERRORLEVEL 1 (
msbuild.exe -maxCpuCount %~dp1%BUILD_FILE% /t:%__TARGET__% /p:Configuration="%~1" /P:Platform=%2 -fileLoggerParameters:Verbosity=%__VERBOSITY__%;LogFile=%~dp1%BUILD_LOG_FILE%
if ERRORLEVEL 1 (
set BUILD_FAILED=1
)
echo.
goto :eof

msbuild.exe -maxCpuCount %BUILD_FILE% /t:sdv /p:inputs="/clean" /p:Configuration="%~1" /P:platform=%2

IF ERRORLEVEL 1 (
set BUILD_FAILED=1
:run_sdv
if exist sdv (
echo "Removing previously created SDV artifacts"
rmdir /s /q sdv
echo.
)

msbuild.exe -maxCpuCount %BUILD_FILE% /t:sdv /p:inputs="/check /devenv" /p:Configuration="%~1" /P:platform=%2

IF ERRORLEVEL 1 (
if "!SDV_FAILED!" NEQ "1" (
echo Build - Cleaning for %BUILD_FILE%...
msbuild.exe -maxCpuCount %~dp1%BUILD_FILE% /t:clean /p:Configuration="%~1" /P:Platform=%2
if ERRORLEVEL 1 (
set SDV_FAILED=1
)
echo.
)
if "!SDV_FAILED!" NEQ "1" (
echo Build - Cleaning SDV for %BUILD_FILE%...
msbuild.exe -maxCpuCount %~dp1%BUILD_FILE% /t:sdv /p:inputs="/clean" /p:Configuration="%~1" /P:platform=%2
if ERRORLEVEL 1 (
set SDV_FAILED=1
)
echo.
)
if "!SDV_FAILED!" NEQ "1" (
echo Build - Performing SDV checks for %BUILD_FILE%...
msbuild.exe -maxCpuCount %~dp1%BUILD_FILE% /t:sdv /p:inputs="/check /devenv" /p:Configuration="%~1" /P:platform=%2
if ERRORLEVEL 1 (
set SDV_FAILED=1
)
echo.
)
if "!SDV_FAILED!" EQU "1" (
set BUILD_FAILED=1
)

goto :eof

:runql

echo "Removing previously created rules database"
rmdir /s/q codeql_db
:run_ql

echo call "%~dp0\SetVsEnv.bat" %~1 > %~dp1\codeql.build.bat
echo msbuild.exe -maxCpuCount %~dp1\%BUILD_FILE% /t:rebuild /p:Configuration="%~1" /P:Platform=%2 >> %~dp1\codeql.build.bat
if exist %~dp1codeql_db (
echo CodeQL ^: Removing previously created rules database...
rmdir /s /q %~dp1codeql_db
)

call %CODEQL_BIN% database create -l=cpp -s=%~dp1 -c "%~dp1\codeql.build.bat" %~dp1\codeql_db -j 0
rem Prepare CodeQL build...
echo call "%~dp0SetVsEnv.bat" %~1 > %~dp1codeql.build.bat
echo msbuild.exe -maxCpuCount %~dp1%BUILD_FILE% /t:rebuild /p:Configuration="%~1" /P:Platform=%2 >> %~dp1codeql.build.bat

IF ERRORLEVEL 1 (
rem Create the CodeQL database...
call %CODEQL_BIN% database create -l=cpp -s=%~dp1 -c "%~dp1codeql.build.bat" %~dp1codeql_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 %CODEQL_DRIVER_SUITES%\windows_driver_recommended.qls %CODEQL_DRIVER_SUITES%\windows_driver_mustfix.qls --format=sarifv2.1.0 --output=%~dp1\%BUILD_NAME%.sarif -j 0
)

IF ERRORLEVEL 1 (
set BUILD_FAILED=1
call %CODEQL_BIN% database analyze %~dp1codeql_db %CODEQL_DRIVER_SUITES%\windows_driver_recommended.qls --format=sarifv2.1.0 --output=%~dp1%BUILD_NAME%.sarif -j 0
if ERRORLEVEL 1 (
set CODEQL_FAILED=1
)
)

goto :eof

:runca
msbuild.exe -maxCpuCount %BUILD_FILE% /p:Configuration="%~1" /P:Platform=%2 /P:RunCodeAnalysisOnce=True -fileLoggerParameters:LogFile=%~dp1\%BUILD_NAME%.CodeAnalysis.log

IF ERRORLEVEL 1 (
:run_ca
echo Performing Code Analysis build of %BUILD_FILE%.
msbuild.exe -maxCpuCount %~dp1%BUILD_FILE% /p:Configuration="%~1" /P:Platform=%2 /P:RunCodeAnalysisOnce=True -fileLoggerParameters:LogFile=%~dp1%BUILD_NAME%.CodeAnalysis.log
if ERRORLEVEL 1 (
set BUILD_FAILED=1
)

goto :eof

:rundvl
msbuild.exe -maxCpuCount %BUILD_FILE% /t:dvl /p:Configuration="%~1" /P:platform=%2

:run_dvl
Performing Driver Verfier Log build of %BUILD_FILE%.
msbuild.exe -maxCpuCount %~dp1%BUILD_FILE% /t:dvl /p:Configuration="%~1" /P:platform=%2
IF ERRORLEVEL 1 (
set BUILD_FAILED=1
)

goto :eof

:split_target_tag
set TARGET=
set TAG=
for /f "tokens=1 delims=_" %%T in (%1) do (
set TARGET=%%T
)
for /f "tokens=2 delims=_" %%T in (%1) do (
set TAG=_%%T
)
for /f "tokens=1 delims=_" %%T in (%1) do @set TARGET=%%T
for /f "tokens=2 delims=_" %%T in (%1) do @set TAG=_%%T
goto :eof

:fail

exit /B 1
Loading

0 comments on commit fdf1f44

Please sign in to comment.