]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Fix SDV/CodeQL log generation
authorOwen Smith <owen.smith@citrix.com>
Tue, 10 Aug 2021 15:40:47 +0000 (16:40 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Sun, 19 Sep 2021 13:29:53 +0000 (14:29 +0100)
- sarif files need to be stored with SDV logs when generating the DVL file
- Disable PREFast and CodeAnalysis by default
- Run a seperate CodeAnalysis build after SDV, but before generating DVL file
    DVL file should contain multiple summary lines for SDV, at least 1 line
    for CodeAnalysis and at least 1 line for Semmle (CodeQL)

Signed-off-by: Owen Smith <owen.smith@citrix.com>
msbuild.ps1
vs2019/xen/xen.vcxproj
vs2019/xenbus/xenbus.vcxproj
vs2019/xenfilt/xenfilt.vcxproj

index de7ad52d11e8acdf55c5610a2c064704b175f579..846abd290df6843316ec45c1bf6ed538b5c59cec 100644 (file)
@@ -17,7 +17,8 @@ Function Run-MSBuild {
                [string]$Configuration,
                [string]$Platform,
                [string]$Target = "Build",
-               [string]$Inputs = ""
+               [string]$Inputs = "",
+               [switch]$CodeAnalysis
        )
 
        $c = "msbuild.exe"
@@ -28,6 +29,11 @@ Function Run-MSBuild {
        if ($Inputs) {
                $c += [string]::Format(" /p:Inputs=""{0}"" ", $Inputs)
        }
+       if ($CodeAnalysis) {
+               $c += "/p:RunCodeAnalysis=true "
+               $c += "/p:EnablePREFast=true "
+       }
+
        $c += Join-Path -Path $SolutionPath -ChildPath $Name
 
        Invoke-Expression $c
@@ -55,6 +61,7 @@ Function Run-MSBuildSDV {
        Run-MSBuild $projpath $project $Configuration $Platform "Build"
        Run-MSBuild $projpath $project $Configuration $Platform "sdv" "/clean"
        Run-MSBuild $projpath $project $Configuration $Platform "sdv" "/check:default.sdv /debug"
+       Run-MSBuild $projpath $project $Configuration $Platform "Build" -CodeAnalysis
        Run-MSBuild $projpath $project $Configuration $Platform "dvl"
 
        $refine = Join-Path -Path $projpath -ChildPath "refine.sdv"
@@ -73,14 +80,14 @@ Function Run-CodeQL {
                [string]$Name,
                [string]$Configuration,
                [string]$Platform,
-               [string]$SearchPath,
-               [string]$OutputPath
+               [string]$SearchPath
        )
 
        $projpath = Resolve-Path (Join-Path $SolutionPath $Name)
        $project = [string]::Format("{0}.vcxproj", $Name)
        $output = [string]::Format("{0}.sarif", $Name)
        $database = Join-Path "database" $Name
+       $sarif = Join-Path $projpath $output
 
        # write a bat file to wrap msbuild parameters
        $bat = [string]::Format("{0}.bat", $Name)
@@ -120,7 +127,7 @@ Function Run-CodeQL {
        $c += " windows_driver_recommended.qls"
        $c += " --format=sarifv2.1.0"
        $c += " --output="
-       $c += (Join-Path $OutputPath $output)
+       $c += $sarif
        $c += " --search-path="
        $c += $SearchPath
 
@@ -129,6 +136,8 @@ Function Run-CodeQL {
                Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
                Exit $LASTEXITCODE
        }
+
+       Copy-Item $sarif -Destination $SolutionPath
 }
 
 #
@@ -165,9 +174,11 @@ elseif ($Type -eq "codeql") {
        }
        New-Item -ItemType Directory "database"
 
-       Run-CodeQL $solutionpath "xen" $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
-       Run-CodeQL $solutionpath "xenfilt" $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
-       Run-CodeQL $solutionpath "xenbus" $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
+       Run-CodeQL $solutionpath "xen" $configuration["codeql"] $platform[$Arch] $searchpath
+       Run-CodeQL $solutionpath "xenfilt" $configuration["codeql"] $platform[$Arch] $searchpath
+       Run-CodeQL $solutionpath "xenbus" $configuration["codeql"] $platform[$Arch] $searchpath
+
+       Copy-Item -Path (Join-Path -Path $SolutionPath -ChildPath "*.sarif") -Destination $archivepath
 }
 elseif ($Type -eq "sdv") {
        $archivepath = "xenbus"
index bccef34d2b0a595439444d5f18a74eb73c15a42f..2c4579ec525488d14a60de65f1cddf3bb95fb8ff 100644 (file)
@@ -13,7 +13,6 @@
   <Import Project="..\targets.props" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <PropertyGroup>
-    <RunCodeAnalysis>true</RunCodeAnalysis>
     <EnableInf2cat>false</EnableInf2cat>
     <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
     <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
@@ -26,7 +25,6 @@
       <WarningLevel>EnableAllWarnings</WarningLevel>
       <DisableSpecificWarnings>4061;4146;4464;4711;4770;4548;4820;4668;4255;5045;6001;6054;26451;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
-      <EnablePREfast>true</EnablePREfast>
     </ClCompile>
     <ResourceCompile>
       <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
index eac2f7eb47679f3170f989c83497d315101f20ca..c769599d27bf0ad5dd41d98ec0cbcca1028742e9 100644 (file)
@@ -13,7 +13,6 @@
   <Import Project="..\targets.props" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <PropertyGroup>
-    <RunCodeAnalysis>true</RunCodeAnalysis>
     <EnableInf2cat>false</EnableInf2cat>
     <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
     <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
@@ -26,7 +25,6 @@
       <WarningLevel>EnableAllWarnings</WarningLevel>
       <DisableSpecificWarnings>4061;4146;4464;4711;4770;4548;4820;4668;4255;5045;6001;6054;26451;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
-      <EnablePREfast>true</EnablePREfast>
     </ClCompile>
     <ResourceCompile>
       <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
index 620e3a6aaa79040508ebc0142c04c0cc91f88d3b..a0e54c531ebdb495a6a889d86c0e0864f66c735a 100644 (file)
@@ -13,7 +13,6 @@
   <Import Project="..\targets.props" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <PropertyGroup>
-    <RunCodeAnalysis>true</RunCodeAnalysis>
     <EnableInf2cat>false</EnableInf2cat>
     <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir>
     <OutDir>..\$(ConfigurationName)\$(Platform)\</OutDir>
@@ -26,7 +25,6 @@
       <WarningLevel>EnableAllWarnings</WarningLevel>
       <DisableSpecificWarnings>4061;4464;4711;4770;4548;4820;4668;4255;5045;6001;6054;26451;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
-      <EnablePREfast>true</EnablePREfast>
     </ClCompile>
     <ResourceCompile>
       <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>