-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.ps1
138 lines (115 loc) · 3.1 KB
/
build.ps1
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#
# Main build script
#
param(
[Parameter(Mandatory = $true)]
[string]$Type,
[string]$Arch,
[string]$SignMode = "TestSign",
[switch]$CodeQL,
[switch]$Sdv
)
#
# Script Body
#
Function Build {
param(
[string]$Arch,
[string]$Type
)
$visualstudioversion = $Env:VisualStudioVersion
$solutiondir = @{ "16.0" = "vs2019"; "17.0" = "vs2022"; }
$configurationbase = @{ "16.0" = "Windows 10"; "17.0" = "Windows 10"; }
$params = @{
SolutionDir = $solutiondir[$visualstudioversion];
ConfigurationBase = $configurationbase[$visualstudioversion];
Arch = $Arch;
Type = $Type;
SignMode = $SignMode
}
& ".\msbuild.ps1" @params
if ($LASTEXITCODE -ne 0) {
Write-Host -ForegroundColor Red "ERROR: Build failed, code:" $LASTEXITCODE
Exit $LASTEXITCODE
}
}
Function SdvBuild {
$visualstudioversion = $Env:VisualStudioVersion
$solutiondir = @{ "16.0" = "vs2019"; "17.0" = "vs2022"; }
$configurationbase = @{ "16.0" = "Windows 10"; "17.0" = "Windows 10"; }
$arch = "x64"
$params = @{
SolutionDir = $solutiondir[$visualstudioversion];
ConfigurationBase = $configurationbase[$visualstudioversion];
Arch = $arch;
Type = "sdv";
SignMode = $SignMode
}
& ".\msbuild.ps1" @params
}
function CodeQLBuild {
$visualstudioversion = $Env:VisualStudioVersion
$solutiondir = @{ "16.0" = "vs2019"; "17.0" = "vs2022"; }
$configurationbase = @{ "16.0" = "Windows 10"; "17.0" = "Windows 10"; }
$arch = "x64"
$params = @{
SolutionDir = $solutiondir[$visualstudioversion];
ConfigurationBase = $configurationbase[$visualstudioversion];
Arch = $arch;
Type = "codeql";
SignMode = $SignMode
}
& ".\msbuild.ps1" @params
}
if ($Type -ne "free" -and $Type -ne "checked") {
Write-Host "Invalid Type"
Exit -1
}
if ([string]::IsNullOrEmpty($Env:VENDOR_NAME)) {
Set-Item -Path Env:VENDOR_NAME -Value 'Xen Project'
}
if ([string]::IsNullOrEmpty($Env:VENDOR_PREFIX)) {
Set-Item -Path Env:VENDOR_PREFIX -Value 'XP'
}
if ([string]::IsNullOrEmpty($Env:PRODUCT_NAME)) {
Set-Item -Path Env:PRODUCT_NAME -Value 'Xen'
}
if ([string]::IsNullOrEmpty($Env:OBJECT_PREFIX)) {
Set-Item -Path Env:OBJECT_PREFIX -Value 'XenProject'
}
if ([string]::IsNullOrEmpty($Env:COPYRIGHT)) {
Set-Item -Path Env:COPYRIGHT -Value 'Copyright (c) Xen Project.'
}
if ([string]::IsNullOrEmpty($Env:BUILD_NUMBER)) {
if (Test-Path ".build_number") {
$BuildNum = Get-Content -Path ".build_number"
Set-Content -Path ".build_number" -Value ([int]$BuildNum + 1)
} else {
$BuildNum = '0'
Set-Content -Path ".build_number" -Value '1'
}
Set-Item -Path Env:BUILD_NUMBER -Value $BuildNum
}
if ([string]::IsNullOrEmpty($Env:MAJOR_VERSION)) {
Set-Item -Path Env:MAJOR_VERSION -Value '9'
}
if ([string]::IsNullOrEmpty($Env:MINOR_VERSION)) {
Set-Item -Path Env:MINOR_VERSION -Value '1'
}
if ([string]::IsNullOrEmpty($Env:MICRO_VERSION)) {
Set-Item -Path Env:MICRO_VERSION -Value '0'
}
if ([string]::IsNullOrEmpty($Arch) -or $Arch -eq "x86" -or $Arch -eq "Win32") {
if ($Env:VisualStudioVersion -ne "17.0") {
Build "x86" $Type
}
}
if ([string]::IsNullOrEmpty($Arch) -or $Arch -eq "x64") {
Build "x64" $Type
}
if ($CodeQL) {
CodeQLBuild
}
if ($Sdv) {
SdvBuild
}