--- /dev/null
+#
+# Wrapper script for MSBuild
+# Also creates the final package(s) (if specified) and bumps the build number
+#
+param(
+ [string]$SolutionDir = "vs2017",
+ [string]$DriverName = "xenbus",
+ [string]$ConfigurationBase = "Windows 10",
+ [switch]$Free,
+ [switch]$Checked,
+ [switch]$Sdv,
+ [switch]$Package,
+ [switch]$DontBumpBuild
+)
+
+Function Run-MSBuild {
+ param(
+ [string]$SolutionDir,
+ [string]$SolutionName,
+ [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=[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
+ }
+}
+
+Function Run-MSBuildSDV {
+ param(
+ [string]$SolutionDir,
+ [string]$ProjectName
+ )
+
+ $basepath = Get-Location
+ $projpath = Join-Path -Path $SolutionDir -ChildPath $ProjectName
+ Set-Location $projpath
+
+ $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"
+
+ $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"
+ }
+
+ Set-Location $basepath
+}
+
+#
+# Script Body
+#
+
+$configuration = @{ "free"="$ConfigurationBase Release"; "checked"="$ConfigurationBase Debug" }
+$solutionname = [string]::Format("{0}.sln", $DriverName)
+$solutiondir = Resolve-Path $SolutionDir
+
+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
+}
+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"
+ }
+}
--- /dev/null
+#
+# Generate version.h and xenbus.inf
+#
+param(
+ [string]$SolutionDir = "vs2017",
+ [string]$DriverName = "xenbus",
+ [string]$ConfigFile = $null
+)
+
+# Copy $InFileName -> $OutFileName replacing $Token$_.Key$Token with $_.Value from
+# either $ConfigFile or $Replacements
+Function Copy-FileWithReplacements {
+ param(
+ [Parameter(Mandatory=$true)]
+ [string]$InFileName,
+ [Parameter(Mandatory=$true)]
+ [string]$OutFileName,
+ [string]$ConfigFile,
+ [hashtable]$Replacements,
+ [string]$Token = "@"
+ )
+
+ Write-Host "Copy-FileWithReplacements"
+ Write-Host $InFileName" -> "$OutFileName
+
+ if ($ConfigFile) {
+ $List = Get-Content $ConfigFile | Out-String | iex
+ $List | Out-String | Write-Host
+ } elseif ($Replacements) {
+ $List = $Replacements
+ } else {
+ Write-Host "Invalid Arguments, ConfigFile or Replacements must be set"
+ Write-Host
+ Exit -1
+ }
+
+ (Get-Content $InFileName) |
+ ForEach-Object {
+ $line = $_
+ $List.GetEnumerator() | ForEach-Object {
+ $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
+ }
+ $line = $line -replace $key, $_.Value
+ }
+ $line
+ } |
+ Set-Content $OutFileName
+}
+
+#
+# Script Body
+#
+$cwd = Get-Location
+Set-Location $PSScriptRoot
+
+$TheYear = Get-Date -UFormat "%Y"
+$TheMonth = Get-Date -UFormat "%m"
+$TheDay = Get-Date -UFormat "%d"
+$TheDate = 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"
+if ($GitRevision) {
+ Set-Content -Path ".revision" -Value $GitRevision
+}
+
+# if ".build_number" doesnt exist, BUILD_NUMBER = 0
+# since this can called by the vcxproj, do not autoincrement the build number
+# as this will mean x64 and Win32 builds have different numbers!
+if (Test-Path ".build_number") {
+ $TheBuildNum = Get-Content -Path ".build_number"
+} else {
+ Set-Content -Path ".build_number" -Value "0"
+}
+if (-not $TheBuildNum) {
+ $TheBuildNum = '0'
+}
+
+# [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';
+
+ '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
+}
+
+if ($ConfigFile -and (Test-Path -Path $ConfigFile)) {
+ $config = Resolve-Path $ConfigFile | Get-Content | Out-String | iex
+ $config.GetEnumerator() | % { $Replacements[$_.Key] = $_.Value }
+}
+
+$Replacements | Out-String | Write-Host
+
+$src = "./include/version.tmpl"
+$dst = "./include/version.h"
+Copy-FileWithReplacements $src $dst -Replacements $Replacements
+
+$src = [string]::Format("./src/{0}.inf", $DriverName)
+$dst = [string]::Format("./{0}/{1}.inf", $SolutionDir, $DriverName)
+Copy-FileWithReplacements $src $dst -Replacements $Replacements
+
+Set-Location $cwd
--- /dev/null
+#define VENDOR_NAME_STR "@VENDOR_NAME@"
+#define PRODUCT_NAME_STR "@PRODUCT_NAME@"
+#define VENDOR_PREFIX_STR "@VENDOR_PREFIX@"
+#define VENDOR_DEVICE_ID_STR "@VENDOR_DEVICE_ID@"
+
+#define MAJOR_VERSION_STR "@MAJOR_VERSION@"
+#define MINOR_VERSION_STR "@MINOR_VERSION@"
+#define MICRO_VERSION_STR "@MICRO_VERSION@"
+#define BUILD_NUMBER_STR "@BUILD_NUMBER@"
+
+#define YEAR_STR "@YEAR@"
+#define MONTH_STR "@MONTH@"
+#define DAY_STR "@DAY@"
+
+#define MAJOR_VERSION @MAJOR_VERSION@
+#define MINOR_VERSION @MINOR_VERSION@
+#define MICRO_VERSION @MICRO_VERSION@
+#define BUILD_NUMBER @BUILD_NUMBER@
+
+#define YEAR @YEAR@
+#define MONTH @MONTH@
+#define DAY @DAY@
--- /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
+}
ClassGUID={4d36e97d-e325-11ce-bfc1-08002be10318}
Provider=%Vendor%
CatalogFile=xenbus.cat
-DriverVer=01/01/1900,0.0.0.0
+DriverVer=@INF_DATE@,@MAJOR_VERSION@.@MINOR_VERSION@.@MICRO_VERSION@.@BUILD_NUMBER@
DriverPackageDisplayName=%DiskDesc%
[DestinationDirs]
--- /dev/null
+#
+# Wrapper script Symbol Server
+#
+param(
+ [string]$DriverName = "xenbus",
+ [string]$SymbolServer = "c:\symbols",
+ [switch]$Free,
+ [switch]$Checked
+)
+
+Function Add-Symbols {
+ param(
+ [string]$DriverName,
+ [string]$DriverPath,
+ [string]$SymbolServer,
+ [string]$Arch
+ )
+
+ $cwd = Get-Location
+ Set-Location $DriverPath
+
+ $symstore = [string]::Format("{0}Debuggers\{1}\symstore.exe", $env:WDKContentRoot, $Arch)
+
+ $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"
+}