#
-# Wrapper script for MSBuild
-# Also creates the final package(s) (if specified) and bumps the build number
+# Main build script
#
+
param(
- [string]$SolutionDir = "vs2017",
- [string]$DriverName = "xenbus",
- [string]$ConfigurationBase = "Windows 10",
- [switch]$Free,
- [switch]$Checked,
- [switch]$Sdv,
- [switch]$Package,
- [switch]$DontBumpBuild
+ [Parameter(Mandatory = $true)]
+ [string]$Type,
+ [switch]$Sdv
)
-Function Run-MSBuild {
+#
+# Script Body
+#
+
+Function Build {
param(
- [string]$SolutionDir,
- [string]$SolutionName,
- [string]$Configuration,
- [string]$Platform,
- [string]$Target = "Build",
- [string]$Inputs = ""
+ [string]$Arch,
+ [string]$Type
)
- $c=[string]::Format("/p:Configuration=`"{0}`"", $Configuration)
- $p=[string]::Format("/p:Platform=`"{0}`"", $Platform)
- $t=[string]::Format("/t:`"{0}`"", $Target)
- $s=[string]::Format("{0}\{1}", $SolutionDir, $SolutionName)
- if ($Inputs) {
- $i=[string]::Format("/p:Inputs=`"{0}`"", $Inputs)
- Write-Host "msbuild.exe" "/m:1" $c $p $t $i $s
- & "msbuild.exe" "/m:1" $c $p $t $s $i
- } else {
- Write-Host "msbuild.exe" "/m:1" $c $p $t $s
- & "msbuild.exe" "/m:1" $c $p $t $s
+ $visualstudioversion = $Env:VisualStudioVersion
+ $solutiondir = @{ "14.0" = "vs2015"; "15.0" = "vs2017"; }
+ $configurationbase = @{ "14.0" = "Windows 10"; "15.0" = "Windows 10"; }
+
+ $params = @{
+ SolutionDir = $solutiondir[$visualstudioversion];
+ Arch = $Arch;
}
-}
+ & ".\genfiles.ps1" @params
-Function Run-MSBuildSDV {
- param(
- [string]$SolutionDir,
- [string]$ProjectName
- )
+ $params = @{
+ SolutionDir = $solutiondir[$visualstudioversion];
+ ConfigurationBase = $configurationbase[$visualstudioversion];
+ Arch = $Arch;
+ Type = $Type
+ }
+ & ".\msbuild.ps1" @params
- $basepath = Get-Location
- $projpath = Join-Path -Path $SolutionDir -ChildPath $ProjectName
- Set-Location $projpath
+ $params = @{
+ Arch = $Arch;
+ }
+ & ".\symstore.ps1" @params
+}
- $project = [string]::Format("{0}.vcxproj", $ProjectName)
- Run-MSBuild $projpath $project "Windows 10 Release" "x64" "Build"
- Run-MSBuild $projpath $project "Windows 10 Release" "x64" "sdv" "/clean"
- Run-MSBuild $projpath $project "Windows 10 Release" "x64" "sdv" "/check:default.sdv /debug"
- Run-MSBuild $projpath $project "Windows 10 Release" "x64" "dvl"
+Function SdvBuild {
+ $visualstudioversion = $Env:VisualStudioVersion
+ $solutiondir = @{ "14.0" = "vs2015"; "15.0" = "vs2017"; }
+ $configurationbase = @{ "14.0" = "Windows 10"; "15.0" = "Windows 10"; }
+ $arch = "x64"
- $refine = Join-Path -Path $projpath -ChildPath "refine.sdv"
- if (Test-Path -Path $refine -PathType Leaf) {
- Run-MSBuild $projpath $project "Windows 10 Release" "x64" "sdv" "/refine"
+ $params = @{
+ SolutionDir = $solutiondir[$visualstudioversion];
+ Arch = $arch;
}
+ & ".\genfiles.ps1" @params
- Set-Location $basepath
+ $params = @{
+ SolutionDir = $solutiondir[$visualstudioversion];
+ ConfigurationBase = $configurationbase[$visualstudioversion];
+ Arch = $arch;
+ Type = "sdv"
+ }
+ & ".\msbuild.ps1" @params
}
-#
-# Script Body
-#
+if ($Type -ne "free" -and $Type -ne "checked") {
+ Write-Host "Invalid Type"
+ Exit -1
+}
-$configuration = @{ "free"="$ConfigurationBase Release"; "checked"="$ConfigurationBase Debug" }
-$solutionname = [string]::Format("{0}.sln", $DriverName)
-$solutiondir = Resolve-Path $SolutionDir
+Build "x86" $Type
+Build "x64" $Type
-if ($Free -or -not ($Sdv -or $Checked)) {
- Run-MSBuild $solutiondir $solutionname $configuration["free"] "x64"
- Run-MSBuild $solutiondir $solutionname $configuration["free"] "Win32"
-}
-if ($Checked) {
- Run-MSBuild $solutiondir $solutionname $configuration["checked"] "x64"
- Run-MSBuild $solutiondir $solutionname $configuration["checked"] "Win32"
-}
if ($Sdv) {
- Run-MSBuildSDV $solutiondir "xen"
- Run-MSBuildSDV $solutiondir "xenfilt"
- Run-MSBuildSDV $solutiondir "xenbus"
-}
-if ($Package) {
- $config=$ConfigurationBase.Replace(' ', '')
- $params = @{
- SolutionDir=$SolutionDir;
- DriverName=$DriverName;
- ConfigurationBase=$config;
- Free=$Free;
- Checked=$Checked
- }
- & ".\package.ps1" @params
+ SdvBuild
}
-if (-not $DontBumpBuild) {
- if (Test-Path ".build_number") {
- $TheBuildNum = Get-Content -Path ".build_number"
- Set-Content -Path ".build_number" -Value ([int]$TheBuildNum + 1)
- } else {
- Set-Content -Path ".build_number" -Value "1"
- }
+
+if (Test-Path ".build_number") {
+ $TheBuildNum = Get-Content -Path ".build_number"
+ Set-Content -Path ".build_number" -Value ([int]$TheBuildNum + 1)
+} else {
+ Set-Content -Path ".build_number" -Value "1"
}
#
param(
[string]$SolutionDir = "vs2017",
- [string]$DriverName = "xenbus",
- [string]$ConfigFile = $null
+ [string]$ConfigFile = $null,
+ [Parameter(Mandatory = $true)]
+ [string]$Arch
)
# Copy $InFileName -> $OutFileName replacing $Token$_.Key$Token with $_.Value from
# either $ConfigFile or $Replacements
Function Copy-FileWithReplacements {
param(
- [Parameter(Mandatory=$true)]
+ [Parameter(Mandatory = $true)]
[string]$InFileName,
- [Parameter(Mandatory=$true)]
+ [Parameter(Mandatory = $true)]
[string]$OutFileName,
[string]$ConfigFile,
[hashtable]$Replacements,
ForEach-Object {
$line = $_
$List.GetEnumerator() | ForEach-Object {
- $key=[string]::Format("{0}{1}{2}", $Token, $_.Name, $Token)
+ $key = [string]::Format("{0}{1}{2}", $Token, $_.Name, $Token)
if (([string]::IsNullOrEmpty($_.Value)) -and ($line.Contains($key))) {
Write-Host "Skipping Line Containing " $_.Name
$line = $null
$TheYear = Get-Date -UFormat "%Y"
$TheMonth = Get-Date -UFormat "%m"
$TheDay = Get-Date -UFormat "%d"
-$TheDate = Get-Date -UFormat "%m/%d/%Y"
+$InfArch = @{ "x86" = "x86"; "x64" = "amd64" }
+$InfDate = Get-Date -UFormat "%m/%d/%Y"
# if GitRevision is $null, GIT_REVISION will be excluded from the Copy-FileWithReplacements
$GitRevision = & "git.exe" "rev-list" "--max-count=1" "HEAD"
# [ordered] makes output easier to parse by humans
$Replacements = [ordered]@{
# default parameters, may be overridden in config.ps1
- 'VENDOR_NAME'='Xen Project';
- 'PRODUCT_NAME'='Xen';
- 'VENDOR_DEVICE_ID'=$null; # must define this replacement, or @VENDOR_DEVICE_ID@ will remain in OutFileName
- 'VENDOR_PREFIX'='XP';
+ 'VENDOR_NAME' = 'Xen Project';
+ 'PRODUCT_NAME' = 'Xen';
+ 'VENDOR_DEVICE_ID' = $null; # must define this replacement, or @VENDOR_DEVICE_ID@ will remain in OutFileName
+ 'VENDOR_PREFIX' = 'XP';
- 'MAJOR_VERSION'='9';
- 'MINOR_VERSION'='0';
- 'MICRO_VERSION'='0';
+ 'MAJOR_VERSION' = '9';
+ 'MINOR_VERSION' = '0';
+ 'MICRO_VERSION' = '0';
# generated values (should not be in config.ps1)
- 'BUILD_NUMBER'=$TheBuildNum;
- 'GIT_REVISION'= $GitRevision;
-
- 'INF_DATE'=$TheDate;
- 'YEAR'=$TheYear;
- 'MONTH'=$TheMonth;
- 'DAY'=$TheDay
+ 'BUILD_NUMBER' = $TheBuildNum;
+ 'GIT_REVISION' = $GitRevision;
+
+ 'INF_DATE' = $InfDate;
+ 'INF_ARCH' = $InfArch[$Arch];
+ 'YEAR' = $TheYear;
+ 'MONTH' = $TheMonth;
+ 'DAY' = $TheDay
}
if ($ConfigFile -and (Test-Path -Path $ConfigFile)) {
$Replacements | Out-String | Write-Host
-$src = "./include/version.tmpl"
-$dst = "./include/version.h"
+$includepath = Resolve-Path "include"
+$src = Join-Path -Path $includepath -ChildPath "version.tmpl"
+$dst = Join-Path -Path $includepath -ChildPath "version.h"
Copy-FileWithReplacements $src $dst -Replacements $Replacements
-$src = [string]::Format("./src/{0}.inf", $DriverName)
-$dst = [string]::Format("./{0}/{1}.inf", $SolutionDir, $DriverName)
+$sourcepath = Resolve-Path "src"
+$solutionpath = Resolve-Path $SolutionDir
+$src = Join-Path -Path $sourcepath -ChildPath "xenbus.inf"
+$dst = Join-Path -Path $solutionpath -ChildPath "xenbus.inf"
Copy-FileWithReplacements $src $dst -Replacements $Replacements
Set-Location $cwd
--- /dev/null
+#
+# Wrapper script for MSBuild
+#
+param(
+ [string]$SolutionDir = "vs2017",
+ [string]$ConfigurationBase = "Windows 10",
+ [Parameter(Mandatory = $true)]
+ [string]$Arch,
+ [Parameter(Mandatory = $true)]
+ [string]$Type
+)
+
+Function Run-MSBuild {
+ param(
+ [string]$SolutionPath,
+ [string]$Name,
+ [string]$Configuration,
+ [string]$Platform,
+ [string]$Target = "Build",
+ [string]$Inputs = ""
+ )
+
+ $c = [string]::Format("/p:Configuration=`"{0}`"", $Configuration)
+ $p = [string]::Format("/p:Platform=`"{0}`"", $Platform)
+ $t = [string]::Format("/t:`"{0}`"", $Target)
+ $s = Join-Path -Path $SolutionPath -ChildPath $Name
+ if ($Inputs) {
+ $i = [string]::Format("/p:Inputs=`"{0}`"", $Inputs)
+ Write-Host "msbuild.exe" "/m:1" $c $p $t $i $s
+ & "msbuild.exe" "/m:1" $c $p $t $s $i
+ } else {
+ Write-Host "msbuild.exe" "/m:1" $c $p $t $s
+ & "msbuild.exe" "/m:1" $c $p $t $s
+ }
+}
+
+Function Run-MSBuildSDV {
+ 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"
+ 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 "dvl"
+
+ $refine = Join-Path -Path $projpath -ChildPath "refine.sdv"
+ if (Test-Path -Path $refine -PathType Leaf) {
+ Run-MSBuild $projpath $project $Configuration $Platform "sdv" "/refine"
+ }
+
+ Set-Location $basepath
+}
+
+Function Copy-To-Archive {
+ param(
+ [string]$ArtifactPath,
+ [string]$ArchivePath
+ )
+
+ if (-Not (Test-Path -Path $ArtifactPath)) {
+ return
+ }
+
+ if (-Not (Test-Path -Path $ArchivePath)) {
+ New-Item -Name $ArchivePath -ItemType Directory | Out-Null
+ }
+
+ $src = Join-Path -Path $ArtifactPath -ChildPath "package"
+ Get-ChildItem -Path $src -File | Copy-Item -Destination $ArchivePath
+}
+
+#
+# Script Body
+#
+
+$configuration = @{ "free" = "$ConfigurationBase Release"; "checked" = "$ConfigurationBase Debug"; "sdv" = "$ConfigurationBase Release"; }
+$platform = @{ "x86" = "Win32"; "x64" = "x64" }
+$solutionpath = Resolve-Path $SolutionDir
+$artifactpath = Join-Path -Path $solutionpath -ChildPath (Join-Path -Path $configuration[$Type].Replace(' ', '') -Childpath $platform[$Arch])
+$archivepath = Join-Path -Path (Resolve-Path "xenbus") -ChildPath $Arch
+
+if ($Type -eq "free") {
+ Run-MSBuild $solutionpath "xenbus.sln" $configuration["free"] $platform[$Arch]
+ Copy-To-Archive $artifactpath $archivepath
+}
+elseif ($Type -eq "checked") {
+ Run-MSBuild $solutionpath "xenbus.sln" $configuration["checked"] $platform[$Arch]
+ Copy-To-Archive $artifactpath $archivepath
+}
+elseif ($Type -eq "sdv") {
+ Run-MSBuildSDV $solutionpath "xen" $configuration["sdv"] $platform[$Arch]
+ Run-MSBuildSDV $solutionpath "xenfilt" $configuration["sdv"] $platform[$Arch]
+ Run-MSBuildSDV $solutionpath "xenbus" $configuration["sdv"] $platform[$Arch]
+
+ Get-ChildItem -Path $artifactpath -Include "*.DVL.XML" -File -Recurse | Copy-Item -Destination $archivepath
+}
+++ /dev/null
-#
-# Package - create the output package
-#
-param(
- [string]$SolutionDir = "vs2017",
- [string]$DriverName = "xenbus",
- [string]$ConfigurationBase = "Windows10",
- [switch]$Free,
- [switch]$Checked
-)
-
-Function Build-Package {
- param(
- [string]$SolutionDir,
- [string]$BinPath,
- [string]$Package
- )
-
- $zipfile = [string]::Format("{0}.zip", $Package)
- $hashfile = [string]::Format("{0}.sha256", $Package)
- if (Test-Path -Path $zipfile) {
- Remove-Item -Path $zipfile -Recurse -Force
- }
- if (Test-Path -Path $hashfile) {
- Remove-Item -Path $hashfile -Recurse -Force
- }
- if (Test-Path -Path $Package) {
- Remove-Item -Path $Package -Recurse -Force
- }
- New-Item -Name $Package -ItemType Directory | Out-Null
-
- $src = Join-Path -Path $BinPath -ChildPath "x64\package\*"
- $dst = Join-Path -Path $Package -ChildPath "x64"
- New-Item -Path $dst -ItemType Directory | Out-Null
- Copy-Item -Path $src -Destination $dst -Recurse -Force
-
- $src = Join-Path -Path $BinPath -ChildPath "Win32\package\*"
- $dst = Join-Path -Path $Package -ChildPath "x86"
- New-Item -Path $dst -ItemType Directory | Out-Null
- Copy-Item -Path $src -Destination $dst -Recurse -Force
-
- Copy-Item ".build_number" $Package
- Copy-Item ".revision" $Package
-
- Get-ChildItem -Path $SolutionDir -Include "*.DVL.XML" -File -Recurse | Copy-Item -Destination $Package
-
- Compress-Archive -Path $Package -DestinationPath $zipfile
-
- $hash = Get-FileHash -Path $zipfile -Algorithm SHA256
- $hash.Hash | Set-Content $hashfile
-
- Format-List -InputObject $hash
-}
-
-#
-# Script Body
-#
-
-if ($Free -or -not $Checked) {
- $config=[string]::Format("{0}Release", $ConfigurationBase);
- $binpath = Join-Path -Path $SolutionDir -ChildPath $config
- Build-Package $SolutionDir $binpath $DriverName
-}
-if ($Checked) {
- $config=[string]::Format("{0}Debug", $ConfigurationBase);
- $binpath = Join-Path -Path $SolutionDir -ChildPath $config
- $package = [string]::Format("{0}-checked", $DriverName)
- Build-Package $SolutionDir $binpath $package
-}
#
-# Wrapper script Symbol Server
+# Store symbols for archived build
#
param(
- [string]$DriverName = "xenbus",
[string]$SymbolServer = "c:\symbols",
- [switch]$Free,
- [switch]$Checked
+ [Parameter(Mandatory = $true)]
+ [string]$Arch
)
Function Add-Symbols {
param(
[string]$DriverName,
- [string]$DriverPath,
+ [string]$ArchivePath,
[string]$SymbolServer,
[string]$Arch
)
+ Write-Host Store symbols from (Resolve-Path $ArchivePath)
+
$cwd = Get-Location
- Set-Location $DriverPath
+ Set-Location $ArchivePath
- $symstore = [string]::Format("{0}Debuggers\{1}\symstore.exe", $env:WDKContentRoot, $Arch)
+ $path = Join-Path -Path ([string]::Format("{0}Debuggers", $env:WDKContentRoot)) -ChildPath $Arch
+ $symstore = Join-Path -Path $path -ChildPath "symstore.exe"
- $inffile=[string]::Format("{0}.inf", $DriverName)
- $Version=(Get-Content -Path $inffile | Select-String "DriverVer").Line.Split(',')[1]
+ $inffile = [string]::Format("{0}.inf", $DriverName)
+ $Version = (Get-Content -Path $inffile | Select-String "DriverVer").Line.Split(',')[1]
- Write-Host $symstore "add" "/s" $SymbolServer "/r" "/f" "*.pdb" "/t" $DriverName "/v" $Version
Get-ChildItem -Path "." -Include "*.pdb" -Name | Write-Host
& $symstore "add" "/s" $SymbolServer "/r" "/f" "*.pdb" "/t" $DriverName "/v" $Version
Set-Location $cwd
}
-if ($Free -or -not $Checked) {
- $driverpath = [string]::Format("{0}\x64", $DriverName)
- Add-Symbols $DriverName $driverpath $SymbolServer "x64"
- $driverpath = [string]::Format("{0}\x86", $DriverName)
- Add-Symbols $DriverName $driverpath $SymbolServer "x86"
-}
-if ($Checked) {
- $driverpath = [string]::Format("{0}-checked\x64", $DriverName)
- Add-Symbols $DriverName $driverpath $SymbolServer "x64"
- $driverpath = [string]::Format("{0}-checked\x86", $DriverName)
- Add-Symbols $DriverName $driverpath $SymbolServer "x86"
-}
+$archivepath = Join-Path -Path (Resolve-Path "xenbus") -ChildPath $Arch
+Add-Symbols "xenbus" $archivepath $SymbolServer $Arch