[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/7] Refactor msbuild.ps1



From: Owen Smith <owen.smith@xxxxxxxxx>

Moves all repo specific data to a 'Globals' section, and simplifies the
structure so that it can be common across all drivers.

Also seperates DVL log generation from SDV build, so that DVL logs
can be created for CodeQL builds without SDV.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxx>
---
 msbuild.ps1 | 67 +++++++++++++++++++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 22 deletions(-)

diff --git a/msbuild.ps1 b/msbuild.ps1
index 64455ea..83b6928 100644
--- a/msbuild.ps1
+++ b/msbuild.ps1
@@ -12,6 +12,16 @@ param(
        [switch]$CodeAnalysis
 )
 
+#
+# Globals
+#
+$SolutionName = "xenbus.sln"
+$ArchivePath = "xenbus"
+$ProjectList = @( "xen", "xenfilt", "xenbus" )
+
+#
+# Functions
+#
 Function Run-MSBuild {
        param(
                [string]$SolutionPath,
@@ -63,6 +73,24 @@ 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"
+
+       Set-Location $basepath
+}
+
+Function Run-MSBuildDVL {
+       param(
+               [string]$SolutionPath,
+               [string]$Name,
+               [string]$Configuration,
+               [string]$Platform
+       )
+
+       $basepath = Get-Location
+       $projpath = Join-Path -Path $SolutionPath -ChildPath $Name
+       Set-Location $projpath
+
+       $project = [string]::Format("{0}.vcxproj", $Name)
+
        Run-MSBuild $projpath $project $Configuration $Platform "Build" 
-CodeAnalysis
        Run-MSBuild $projpath $project $Configuration $Platform "dvl"
 
@@ -151,19 +179,15 @@ $solutionpath = Resolve-Path $SolutionDir
 
 Set-ExecutionPolicy -Scope CurrentUser -Force Bypass
 
-if ($Type -eq "free") {
-       Run-MSBuild $solutionpath "xenbus.sln" $configuration["free"] 
$platform[$Arch] -CodeAnalysis:$CodeAnalysis
-}
-elseif ($Type -eq "checked") {
-       Run-MSBuild $solutionpath "xenbus.sln" $configuration["checked"] 
$platform[$Arch] -CodeAnalysis:$CodeAnalysis
+if (-Not (Test-Path -Path $archivepath)) {
+       New-Item -Name $archivepath -ItemType Directory | Out-Null
 }
-elseif ($Type -eq "codeql") {
-       $archivepath = "xenbus"
 
-       if (-Not (Test-Path -Path $archivepath)) {
-               New-Item -Name $archivepath -ItemType Directory | Out-Null
-       }
+if (($Type -eq "free") -or ($Type -eq "checked")) {
+       Run-MSBuild $solutionpath $SolutionName $configuration[$Type] 
$platform[$Arch] -CodeAnalysis:$CodeAnalysis
+}
 
+if ($Type -eq "codeql") {
        if ([string]::IsNullOrEmpty($Env:CODEQL_QUERY_SUITE)) {
                $searchpath = Resolve-Path ".."
        } else {
@@ -175,22 +199,21 @@ elseif ($Type -eq "codeql") {
        }
        New-Item -ItemType Directory "database"
 
-       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
-
+       ForEach ($project in $ProjectList) {
+               Run-CodeQL $solutionpath $project $configuration["codeql"] 
$platform[$Arch] $searchpath
+       }
        Copy-Item -Path (Join-Path -Path $SolutionPath -ChildPath "*.sarif") 
-Destination $archivepath
 }
-elseif ($Type -eq "sdv") {
-       $archivepath = "xenbus"
 
-       if (-Not (Test-Path -Path $archivepath)) {
-               New-Item -Name $archivepath -ItemType Directory | Out-Null
+if ($Type -eq "sdv") {
+       ForEach ($project in $ProjectList) {
+               Run-MSBuildSDV $solutionpath $project $configuration["sdv"] 
$platform[$Arch]
        }
+}
 
-       Run-MSBuildSDV $solutionpath "xen" $configuration["sdv"] 
$platform[$Arch]
-       Run-MSBuildSDV $solutionpath "xenfilt" $configuration["sdv"] 
$platform[$Arch]
-       Run-MSBuildSDV $solutionpath "xenbus" $configuration["sdv"] 
$platform[$Arch]
-
+if (($Type -eq "codeql") -or ($Type -eq "sdv")) {
+       ForEach ($project in $ProjectList) {
+               Run-MSBuildDVL $solutionpath $project $configuration["sdv"] 
$platform[$Arch]
+       }
        Copy-Item -Path (Join-Path -Path $SolutionPath -ChildPath "*DVL*") 
-Destination $archivepath
 }
-- 
2.51.2.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.