blob: 3cfc554124d179e73cb76a5ea22de9c7a8129efc (
plain) (
blame)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
param(
[Parameter(Mandatory=$true)]
[string] $InstallDir = $null,
[Parameter(Mandatory=$true)]
[string] $Platform = $null,
[Parameter(Mandatory=$true)]
[string] $Configuration = $null,
[Parameter(Mandatory=$true)]
[string] $WDK = $null
)
$ErrorActionPreference = "Stop";
Set-PSDebug -Strict
function Invoke-Exe {
param(
[ScriptBlock] $Cmd,
[int[]] $AllowedExitCodes = @(0)
)
$backupErrorActionPreference = $script:ErrorActionPreference
$script:ErrorActionPreference = 'Continue'
try {
& $Cmd
if ($AllowedExitCodes -notcontains $LastExitCode) {
throw "External command failed with exit code ${LastExitCode}: $Cmd"
}
} finally {
$script:ErrorActionPreference = $backupErrorActionPreference
}
}
function Test-AppVeyor {
return Test-Path env:APPVEYOR
}
function Get-DriverBuildDir {
param(
[Parameter(Mandatory=$true)]
[string] $DriverName
)
return "$script:PSScriptRoot\..\km\build\$script:WDK\$DriverName"
}
function Get-DriverSolutionPath {
param(
[Parameter(Mandatory=$true)]
[string] $DriverName
)
$build_dir = Get-DriverBuildDir -DriverName $DriverName
return "$build_dir\$DriverName.sln"
}
function Build-Driver {
param(
[Parameter(Mandatory=$true)]
[string] $DriverName
)
$build_dir = Get-DriverBuildDir -DriverName $DriverName
$solution_path = Get-DriverSolutionPath -DriverName $DriverName
$msbuild_params = @()
$msbuild_params += "/p:Platform=$script:Platform"
$msbuild_params += "/p:Configuration=$script:Configuration"
$msbuild_params += "/p:SignMode=TestSign"
$msbuild_params += "/p:OutDir=$InstallDir\lib"
cd $build_dir
Invoke-Exe { msbuild.exe $msbuild_params $solution_path }
}
function Build-ProjectKernelMode {
$drivers = 'minimal', 'simple', 'nt_namespace'
foreach ($driver in $drivers) {
Build-Driver -DriverName $driver
}
}
function Build-Project {
if (Test-AppVeyor) {
$appveyor_cwd = pwd
}
New-Item -ItemType Directory -Force $script:InstallDir | Out-Null
$script:InstallDir = (Resolve-Path $script:InstallDir).Path
try {
Build-ProjectKernelMode
} finally {
if (Test-AppVeyor) {
cd $appveyor_cwd
Set-PSDebug -Off
}
}
}
Build-Project
|