-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild-drivers.ps1
More file actions
84 lines (75 loc) · 2.65 KB
/
Copy pathbuild-drivers.ps1
File metadata and controls
84 lines (75 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
[CmdletBinding()]
param (
[Parameter()]
[string[]]$Drivers = @("xenbus", "xencons", "xenhid", "xeniface", "xennet", "xenvbd", "xenvif", "xenvkbd"),
[Parameter()]
[string]$Target = "Build",
[Parameter(Mandatory)]
[ValidateSet("Debug", "Release")]
[string]$Configuration,
[Parameter(Mandatory)]
[ValidateSet("x86", "x64")]
[string]$Platform,
[Parameter()]
[ValidateSet("vs2019", "vs2022")]
[string]$SolutionDir = "vs2022",
[Parameter()]
[ValidateSet("Windows 10")]
[string]$ConfigurationBase = "Windows 10",
[Parameter()]
[switch]$Kasan
)
. $PSScriptRoot\branding.ps1
. $PSScriptRoot\scripts\branding-generic.ps1
. $PSScriptRoot\scripts\sign.ps1
# Drivers are ordered by build date first so the HHmm gives you a more granular revision number (down to the minute).
# The "1" is to avoid leading zeroes.
$DriverTime = "1" + (Get-Date -Format HHmm)
$OutputPath = "$PSScriptRoot\installer\driver-bins"
Remove-Item -Path $OutputPath -Force -Recurse -ErrorAction SilentlyContinue
$ErrorActionPreference = "Stop"
foreach ($repo in $Drivers) {
Push-Location $PSScriptRoot\$repo
try {
$rawver = Get-PackageVersion -Raw $repo
$ver = Get-PackageVersion $repo
$Env:MAJOR_VERSION = $ver.Major
$Env:MINOR_VERSION = $ver.Minor
$Env:MICRO_VERSION = $ver.Build
if ($rawver.Revision -eq -1) {
$Env:BUILD_NUMBER = $DriverTime
}
else {
$Env:BUILD_NUMBER = $rawver.Revision
}
git clean -fXd
$DriverConfiguration = "$ConfigurationBase $Configuration"
$DriverConfigShort = $DriverConfiguration.Replace(" ", "")
$BuildArgs = @(
(Resolve-Path "$SolutionDir\$repo.sln"),
"/m:4",
"/p:Configuration=$DriverConfiguration",
"/p:Platform=$Platform",
"/p:SignMode=Off",
"/t:$Target"
)
if ($Kasan) {
$BuildArgs += @("/p:EnableKASAN=true")
}
msbuild.exe @BuildArgs
if ($LASTEXITCODE -ne 0) {
throw "MSBuild failed with error $LASTEXITCODE"
}
$DriverOutput = "$OutputPath\$Platform\$Configuration\$repo"
New-Item -ItemType Directory -Path $DriverOutput -Force
Copy-Item -Path .\$SolutionDir\$DriverConfigShort\$Platform\package\* -Destination $DriverOutput\ -Force -Recurse
Set-SignerFileSignature $DriverOutput\*.sys, $DriverOutput\*.dll, $DriverOutput\*.exe, $DriverOutput\*.cat
}
finally {
$Env:MAJOR_VERSION = ''
$Env:MINOR_VERSION = ''
$Env:MICRO_VERSION = ''
$Env:BUILD_NUMBER = ''
Pop-Location
}
}