The open source OpenXR runtime

ci: Improve Windows CI scripts

+82 -29
+3 -3
.gitlab-ci.yml
··· 175 175 inherit: 176 176 default: false 177 177 variables: 178 - MONADO_WIN_BASE_TAG: "20220727.0" 179 - MONADO_WIN_MAIN_TAG: "20220727.0" 178 + MONADO_WIN_BASE_TAG: "20221026.0" 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 - - ./.gitlab-ci/windows/monado_build.ps1 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 - - ./.gitlab-ci/windows/monado_build.ps1 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 - MONADO_WIN_BASE_TAG: "20220727.0" 13 - MONADO_WIN_MAIN_TAG: "20220727.0" 12 + MONADO_WIN_BASE_TAG: "20221026.0" 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 - COPY "monado_deps_vs2022.ps1" "C:/" 16 - RUN "C:/monado_deps_vs2022.ps1" 15 + COPY "monado_deps_vs2022.ps1" "C:\\" 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 - # force the CA cert cache to be rebuilt, in case Meson tries to access anything 7 - Write-Host "Refreshing Windows TLS CA cache" 8 - (New-Object System.Net.WebClient).DownloadString("https://github.com") > $null 6 + [CmdletBinding()] 7 + param ( 8 + # Should we install the project? 9 + [Parameter()] 10 + [switch] 11 + $Install = $false, 12 + 13 + # Should we package the project? 14 + [Parameter()] 15 + [switch] 16 + $Package = $false, 17 + 18 + # Should we run the test suite? 19 + [Parameter()] 20 + [switch] 21 + $RunTests = $false 22 + ) 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 + Write-Output "toolchainfile:$toolchainfile" 25 41 26 - $installPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 17 -property installationpath 27 - Write-Output "vswhere.exe installPath: $installPath" 42 + # $installPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 17 -property installationpath 43 + # Write-Information "vswhere.exe installPath: $installPath" 44 + # if (!$installPath) { 45 + # throw "Could not find VS2022 using vswhere!" 46 + # } 28 47 $installPath = "C:\BuildTools" 29 - Write-Output "Final installPath: $installPath" 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 + Write-Output "There may be a harmless error about 'Team Explorer' shown next, which may be ignored." 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 + $ErrorActionPreference = 'Stop' 37 59 Push-Location $sourcedir 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 + "-DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON" 47 71 ) 48 72 cmake @cmakeArgs 73 + if (!$?) { 74 + throw "cmake generate failed!" 75 + } 49 76 50 - ninja -C $builddir 51 - ninja -C $builddir install test 77 + Write-Information "Building" 78 + cmake --build $builddir 79 + if (!$?) { 80 + throw "cmake build failed!" 81 + } 52 82 53 - $buildstatus = $? 54 - Pop-Location 83 + if ($RunTests) { 84 + Write-Information "Running tests" 85 + cmake --build $builddir --target test 55 86 56 - Get-Date 87 + } 57 88 58 - if (!$buildstatus) { 59 - Write-Host "Monado build or test failed" 60 - Exit 1 89 + if ($Install) { 90 + Write-Information "Installing" 91 + cmake --build $builddir --target install 92 + } 93 + 94 + 95 + if ($Package) { 96 + Write-Information "Packaging" 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 + if ($BaseImage -and (!$BaseUpstreamImage)) { 139 + $BaseUpstreamImage = $BaseImage 140 + } 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 - } else { 148 + } 149 + else { 145 150 Write-Host "If it is missing, we error out." 146 151 } 147 152 } 148 153 149 - # Start-Docker -ArgumentList ("login", "-u", "$RegistryUsername", "--password-stdin", "$RegistryPassword", "$RegistryUri") 150 - $loginProc = Start-Process -FilePath "docker" -ArgumentList ($CommonDockerArgs + @("login", "-u", "$RegistryUsername", "--password", "$RegistryPassword", "$RegistryUri")) ` 151 - -NoNewWindow -PassThru -WorkingDirectory "$PSScriptRoot" -Wait 152 - if ($loginProc.ExitCode -ne 0) { 153 - throw "docker login failed" 154 + if ($RegistryPassword) { 155 + # Start-Docker -ArgumentList ("login", "-u", "$RegistryUsername", "--password-stdin", "$RegistryPassword", "$RegistryUri") 156 + $loginProc = Start-Process -FilePath "docker" -ArgumentList ($CommonDockerArgs + @("login", "-u", "$RegistryUsername", "--password", "$RegistryPassword", "$RegistryUri")) ` 157 + -NoNewWindow -PassThru -WorkingDirectory "$PSScriptRoot" -Wait 158 + if ($loginProc.ExitCode -ne 0) { 159 + throw "docker login failed" 160 + } 161 + } 162 + else { 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 - Start-Docker -ArgumentList ("logout", "$RegistryUri") 207 + 208 + if ($RegistryPassword) { 209 + Start-Docker -ArgumentList ("logout", "$RegistryUri") 210 + } 211 + else { 212 + Write-Host "Skipping docker logout, password not available so we did not login" 213 + }