tangled
alpha
login
or
join now
matrixfurry.com
/
monado
0
fork
atom
The open source OpenXR runtime
0
fork
atom
overview
issues
pulls
pipelines
ci: Improve Windows CI scripts
Ryan Pavlik
3 years ago
9e164eec
67c47fbc
+82
-29
6 changed files
expand all
collapse all
unified
split
.gitlab-ci
ci.template
win_containers.yml
windows
Dockerfile.vs2022
monado_build.ps1
monado_container.ps1
.gitlab-ci.yml
+3
-3
.gitlab-ci.yml
···
175
175
inherit:
176
176
default: false
177
177
variables:
178
178
-
MONADO_WIN_BASE_TAG: "20220727.0"
179
179
-
MONADO_WIN_MAIN_TAG: "20220727.0"
178
178
+
MONADO_WIN_BASE_TAG: "20221026.0"
179
179
+
MONADO_WIN_MAIN_TAG: "20221026.0"
180
180
MONADO_BASE_IMAGE_PATH: "win2022/vs2022_base"
181
181
MONADO_MAIN_IMAGE_PATH: "win2022/vs2022"
182
182
···
492
492
extends:
493
493
- .monado.image.windows
494
494
script:
495
495
-
- ./.gitlab-ci/windows/monado_build.ps1
495
495
+
- ./.gitlab-ci/windows/monado_build.ps1 -Install -RunTests
496
496
artifacts:
497
497
when: always
498
498
paths:
+1
-1
.gitlab-ci/ci.template
···
201
201
extends:
202
202
- .monado.image.windows
203
203
script:
204
204
-
- ./.gitlab-ci/windows/monado_build.ps1
204
204
+
- ./.gitlab-ci/windows/monado_build.ps1 -Install -RunTests
205
205
artifacts:
206
206
when: always
207
207
paths:
+2
-2
.gitlab-ci/win_containers.yml
···
9
9
inherit:
10
10
default: false
11
11
variables:
12
12
-
MONADO_WIN_BASE_TAG: "20220727.0"
13
13
-
MONADO_WIN_MAIN_TAG: "20220727.0"
12
12
+
MONADO_WIN_BASE_TAG: "20221026.0"
13
13
+
MONADO_WIN_MAIN_TAG: "20221026.0"
14
14
MONADO_BASE_IMAGE_PATH: "win2022/vs2022_base"
15
15
MONADO_MAIN_IMAGE_PATH: "win2022/vs2022"
16
16
+2
-2
.gitlab-ci/windows/Dockerfile.vs2022
···
12
12
SHELL ["powershell", "-ExecutionPolicy", "RemoteSigned", "-Command", "$ErrorActionPreference = 'Stop';"]
13
13
ENV ErrorActionPreference='Stop'
14
14
15
15
-
COPY "monado_deps_vs2022.ps1" "C:/"
16
16
-
RUN "C:/monado_deps_vs2022.ps1"
15
15
+
COPY "monado_deps_vs2022.ps1" "C:\\"
16
16
+
RUN "powershell C:\\monado_deps_vs2022.ps1"
+51
-14
.gitlab-ci/windows/monado_build.ps1
···
3
3
# SPDX-License-Identifier: MIT
4
4
# Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/8396df5ad90aeb6ab2267811aba2187954562f81/.gitlab-ci/windows/mesa_build.ps1
5
5
6
6
-
# force the CA cert cache to be rebuilt, in case Meson tries to access anything
7
7
-
Write-Host "Refreshing Windows TLS CA cache"
8
8
-
(New-Object System.Net.WebClient).DownloadString("https://github.com") > $null
6
6
+
[CmdletBinding()]
7
7
+
param (
8
8
+
# Should we install the project?
9
9
+
[Parameter()]
10
10
+
[switch]
11
11
+
$Install = $false,
12
12
+
13
13
+
# Should we package the project?
14
14
+
[Parameter()]
15
15
+
[switch]
16
16
+
$Package = $false,
17
17
+
18
18
+
# Should we run the test suite?
19
19
+
[Parameter()]
20
20
+
[switch]
21
21
+
$RunTests = $false
22
22
+
)
23
23
+
$ErrorActionPreference = 'Stop'
9
24
10
25
$env:PYTHONUTF8 = 1
11
26
···
22
37
Write-Output "builddir:$builddir"
23
38
Write-Output "installdir:$installdir"
24
39
Write-Output "sourcedir:$sourcedir"
40
40
+
Write-Output "toolchainfile:$toolchainfile"
25
41
26
26
-
$installPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 17 -property installationpath
27
27
-
Write-Output "vswhere.exe installPath: $installPath"
42
42
+
# $installPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 17 -property installationpath
43
43
+
# Write-Information "vswhere.exe installPath: $installPath"
44
44
+
# if (!$installPath) {
45
45
+
# throw "Could not find VS2022 using vswhere!"
46
46
+
# }
28
47
$installPath = "C:\BuildTools"
29
29
-
Write-Output "Final installPath: $installPath"
48
48
+
Write-Output "installPath: $installPath"
30
49
31
50
# Note that we can't have $ErrorActionPreference as "Stop" here:
32
51
# it "errors" (not finding some shared tool because of our mini build tools install)
33
52
# but the error doesn't matter for our use case.
53
53
+
Write-Output "There may be a harmless error about 'Team Explorer' shown next, which may be ignored."
54
54
+
$ErrorActionPreference = 'Continue'
34
55
Import-Module (Join-Path $installPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
35
56
Enter-VsDevShell -VsInstallPath $installPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo -host_arch=amd64'
36
57
58
58
+
$ErrorActionPreference = 'Stop'
37
59
Push-Location $sourcedir
60
60
+
38
61
$cmakeArgs = @(
39
62
"-S"
40
63
"."
···
44
67
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
45
68
"-DCMAKE_TOOLCHAIN_FILE=$toolchainfile"
46
69
"-DCMAKE_INSTALL_PREFIX=$installdir"
70
70
+
"-DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON"
47
71
)
48
72
cmake @cmakeArgs
73
73
+
if (!$?) {
74
74
+
throw "cmake generate failed!"
75
75
+
}
49
76
50
50
-
ninja -C $builddir
51
51
-
ninja -C $builddir install test
77
77
+
Write-Information "Building"
78
78
+
cmake --build $builddir
79
79
+
if (!$?) {
80
80
+
throw "cmake build failed!"
81
81
+
}
52
82
53
53
-
$buildstatus = $?
54
54
-
Pop-Location
83
83
+
if ($RunTests) {
84
84
+
Write-Information "Running tests"
85
85
+
cmake --build $builddir --target test
55
86
56
56
-
Get-Date
87
87
+
}
57
88
58
58
-
if (!$buildstatus) {
59
59
-
Write-Host "Monado build or test failed"
60
60
-
Exit 1
89
89
+
if ($Install) {
90
90
+
Write-Information "Installing"
91
91
+
cmake --build $builddir --target install
92
92
+
}
93
93
+
94
94
+
95
95
+
if ($Package) {
96
96
+
Write-Information "Packaging"
97
97
+
cmake --build $builddir --target package
61
98
}
+23
-7
.gitlab-ci/windows/monado_container.ps1
···
135
135
return $false
136
136
}
137
137
138
138
+
if ($BaseImage -and (!$BaseUpstreamImage)) {
139
139
+
$BaseUpstreamImage = $BaseImage
140
140
+
}
141
141
+
138
142
Write-Host "Will log in to $RegistryUri as $RegistryUsername"
139
143
Write-Host "Will check for image $UserImage - if it does not exist but $UpstreamImage does, we copy that one, otherwise we need to build it."
140
144
if ($BaseImage) {
141
145
Write-Host "This image builds on $BaseImage so we will check for it."
142
146
if ($BaseUpstreamImage) {
143
147
Write-Host "If it is missing but $BaseUpstreamImage exists, we copy that one. If both are missing, we error out."
144
144
-
} else {
148
148
+
}
149
149
+
else {
145
150
Write-Host "If it is missing, we error out."
146
151
}
147
152
}
148
153
149
149
-
# Start-Docker -ArgumentList ("login", "-u", "$RegistryUsername", "--password-stdin", "$RegistryPassword", "$RegistryUri")
150
150
-
$loginProc = Start-Process -FilePath "docker" -ArgumentList ($CommonDockerArgs + @("login", "-u", "$RegistryUsername", "--password", "$RegistryPassword", "$RegistryUri")) `
151
151
-
-NoNewWindow -PassThru -WorkingDirectory "$PSScriptRoot" -Wait
152
152
-
if ($loginProc.ExitCode -ne 0) {
153
153
-
throw "docker login failed"
154
154
+
if ($RegistryPassword) {
155
155
+
# Start-Docker -ArgumentList ("login", "-u", "$RegistryUsername", "--password-stdin", "$RegistryPassword", "$RegistryUri")
156
156
+
$loginProc = Start-Process -FilePath "docker" -ArgumentList ($CommonDockerArgs + @("login", "-u", "$RegistryUsername", "--password", "$RegistryPassword", "$RegistryUri")) `
157
157
+
-NoNewWindow -PassThru -WorkingDirectory "$PSScriptRoot" -Wait
158
158
+
if ($loginProc.ExitCode -ne 0) {
159
159
+
throw "docker login failed"
160
160
+
}
161
161
+
}
162
162
+
else {
163
163
+
Write-Host "Skipping docker login, password not available"
154
164
}
155
165
156
166
# if the image already exists, don't rebuild it
···
194
204
195
205
Write-Host "Done building image, now pushing $UserImage"
196
206
Start-Docker -LogoutOnFailure -ArgumentList ("push", "$UserImage")
197
197
-
Start-Docker -ArgumentList ("logout", "$RegistryUri")
207
207
+
208
208
+
if ($RegistryPassword) {
209
209
+
Start-Docker -ArgumentList ("logout", "$RegistryUri")
210
210
+
}
211
211
+
else {
212
212
+
Write-Host "Skipping docker logout, password not available so we did not login"
213
213
+
}