mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-14 02:45:24 +00:00
ci: Improve Windows CI scripts
This commit is contained in:
parent
67c47fbcb3
commit
9e164eec96
|
@ -175,8 +175,8 @@ arch:rolling:container_prep:
|
|||
inherit:
|
||||
default: false
|
||||
variables:
|
||||
MONADO_WIN_BASE_TAG: "20220727.0"
|
||||
MONADO_WIN_MAIN_TAG: "20220727.0"
|
||||
MONADO_WIN_BASE_TAG: "20221026.0"
|
||||
MONADO_WIN_MAIN_TAG: "20221026.0"
|
||||
MONADO_BASE_IMAGE_PATH: "win2022/vs2022_base"
|
||||
MONADO_MAIN_IMAGE_PATH: "win2022/vs2022"
|
||||
|
||||
|
@ -492,7 +492,7 @@ windows:
|
|||
extends:
|
||||
- .monado.image.windows
|
||||
script:
|
||||
- ./.gitlab-ci/windows/monado_build.ps1
|
||||
- ./.gitlab-ci/windows/monado_build.ps1 -Install -RunTests
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
|
|
|
@ -201,7 +201,7 @@ windows:
|
|||
extends:
|
||||
- .monado.image.windows
|
||||
script:
|
||||
- ./.gitlab-ci/windows/monado_build.ps1
|
||||
- ./.gitlab-ci/windows/monado_build.ps1 -Install -RunTests
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
inherit:
|
||||
default: false
|
||||
variables:
|
||||
MONADO_WIN_BASE_TAG: "20220727.0"
|
||||
MONADO_WIN_MAIN_TAG: "20220727.0"
|
||||
MONADO_WIN_BASE_TAG: "20221026.0"
|
||||
MONADO_WIN_MAIN_TAG: "20221026.0"
|
||||
MONADO_BASE_IMAGE_PATH: "win2022/vs2022_base"
|
||||
MONADO_MAIN_IMAGE_PATH: "win2022/vs2022"
|
||||
|
||||
|
|
|
@ -12,5 +12,5 @@ FROM mcr.microsoft.com/windows/server:ltsc2022
|
|||
SHELL ["powershell", "-ExecutionPolicy", "RemoteSigned", "-Command", "$ErrorActionPreference = 'Stop';"]
|
||||
ENV ErrorActionPreference='Stop'
|
||||
|
||||
COPY "monado_deps_vs2022.ps1" "C:/"
|
||||
RUN "C:/monado_deps_vs2022.ps1"
|
||||
COPY "monado_deps_vs2022.ps1" "C:\\"
|
||||
RUN "powershell C:\\monado_deps_vs2022.ps1"
|
||||
|
|
|
@ -3,9 +3,24 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
# Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/8396df5ad90aeb6ab2267811aba2187954562f81/.gitlab-ci/windows/mesa_build.ps1
|
||||
|
||||
# force the CA cert cache to be rebuilt, in case Meson tries to access anything
|
||||
Write-Host "Refreshing Windows TLS CA cache"
|
||||
(New-Object System.Net.WebClient).DownloadString("https://github.com") > $null
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
# Should we install the project?
|
||||
[Parameter()]
|
||||
[switch]
|
||||
$Install = $false,
|
||||
|
||||
# Should we package the project?
|
||||
[Parameter()]
|
||||
[switch]
|
||||
$Package = $false,
|
||||
|
||||
# Should we run the test suite?
|
||||
[Parameter()]
|
||||
[switch]
|
||||
$RunTests = $false
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$env:PYTHONUTF8 = 1
|
||||
|
||||
|
@ -22,19 +37,27 @@ Remove-Item -Recurse -Force $installdir -ErrorAction SilentlyContinue
|
|||
Write-Output "builddir:$builddir"
|
||||
Write-Output "installdir:$installdir"
|
||||
Write-Output "sourcedir:$sourcedir"
|
||||
Write-Output "toolchainfile:$toolchainfile"
|
||||
|
||||
$installPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 17 -property installationpath
|
||||
Write-Output "vswhere.exe installPath: $installPath"
|
||||
# $installPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 17 -property installationpath
|
||||
# Write-Information "vswhere.exe installPath: $installPath"
|
||||
# if (!$installPath) {
|
||||
# throw "Could not find VS2022 using vswhere!"
|
||||
# }
|
||||
$installPath = "C:\BuildTools"
|
||||
Write-Output "Final installPath: $installPath"
|
||||
Write-Output "installPath: $installPath"
|
||||
|
||||
# Note that we can't have $ErrorActionPreference as "Stop" here:
|
||||
# it "errors" (not finding some shared tool because of our mini build tools install)
|
||||
# but the error doesn't matter for our use case.
|
||||
Write-Output "There may be a harmless error about 'Team Explorer' shown next, which may be ignored."
|
||||
$ErrorActionPreference = 'Continue'
|
||||
Import-Module (Join-Path $installPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
|
||||
Enter-VsDevShell -VsInstallPath $installPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo -host_arch=amd64'
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Push-Location $sourcedir
|
||||
|
||||
$cmakeArgs = @(
|
||||
"-S"
|
||||
"."
|
||||
|
@ -44,18 +67,32 @@ $cmakeArgs = @(
|
|||
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
|
||||
"-DCMAKE_TOOLCHAIN_FILE=$toolchainfile"
|
||||
"-DCMAKE_INSTALL_PREFIX=$installdir"
|
||||
"-DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON"
|
||||
)
|
||||
cmake @cmakeArgs
|
||||
|
||||
ninja -C $builddir
|
||||
ninja -C $builddir install test
|
||||
|
||||
$buildstatus = $?
|
||||
Pop-Location
|
||||
|
||||
Get-Date
|
||||
|
||||
if (!$buildstatus) {
|
||||
Write-Host "Monado build or test failed"
|
||||
Exit 1
|
||||
if (!$?) {
|
||||
throw "cmake generate failed!"
|
||||
}
|
||||
|
||||
Write-Information "Building"
|
||||
cmake --build $builddir
|
||||
if (!$?) {
|
||||
throw "cmake build failed!"
|
||||
}
|
||||
|
||||
if ($RunTests) {
|
||||
Write-Information "Running tests"
|
||||
cmake --build $builddir --target test
|
||||
|
||||
}
|
||||
|
||||
if ($Install) {
|
||||
Write-Information "Installing"
|
||||
cmake --build $builddir --target install
|
||||
}
|
||||
|
||||
|
||||
if ($Package) {
|
||||
Write-Information "Packaging"
|
||||
cmake --build $builddir --target package
|
||||
}
|
||||
|
|
|
@ -135,22 +135,32 @@ function Test-Image {
|
|||
return $false
|
||||
}
|
||||
|
||||
if ($BaseImage -and (!$BaseUpstreamImage)) {
|
||||
$BaseUpstreamImage = $BaseImage
|
||||
}
|
||||
|
||||
Write-Host "Will log in to $RegistryUri as $RegistryUsername"
|
||||
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."
|
||||
if ($BaseImage) {
|
||||
Write-Host "This image builds on $BaseImage so we will check for it."
|
||||
if ($BaseUpstreamImage) {
|
||||
Write-Host "If it is missing but $BaseUpstreamImage exists, we copy that one. If both are missing, we error out."
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Write-Host "If it is missing, we error out."
|
||||
}
|
||||
}
|
||||
|
||||
# Start-Docker -ArgumentList ("login", "-u", "$RegistryUsername", "--password-stdin", "$RegistryPassword", "$RegistryUri")
|
||||
$loginProc = Start-Process -FilePath "docker" -ArgumentList ($CommonDockerArgs + @("login", "-u", "$RegistryUsername", "--password", "$RegistryPassword", "$RegistryUri")) `
|
||||
-NoNewWindow -PassThru -WorkingDirectory "$PSScriptRoot" -Wait
|
||||
if ($loginProc.ExitCode -ne 0) {
|
||||
throw "docker login failed"
|
||||
if ($RegistryPassword) {
|
||||
# Start-Docker -ArgumentList ("login", "-u", "$RegistryUsername", "--password-stdin", "$RegistryPassword", "$RegistryUri")
|
||||
$loginProc = Start-Process -FilePath "docker" -ArgumentList ($CommonDockerArgs + @("login", "-u", "$RegistryUsername", "--password", "$RegistryPassword", "$RegistryUri")) `
|
||||
-NoNewWindow -PassThru -WorkingDirectory "$PSScriptRoot" -Wait
|
||||
if ($loginProc.ExitCode -ne 0) {
|
||||
throw "docker login failed"
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "Skipping docker login, password not available"
|
||||
}
|
||||
|
||||
# if the image already exists, don't rebuild it
|
||||
|
@ -194,4 +204,10 @@ Get-Date
|
|||
|
||||
Write-Host "Done building image, now pushing $UserImage"
|
||||
Start-Docker -LogoutOnFailure -ArgumentList ("push", "$UserImage")
|
||||
Start-Docker -ArgumentList ("logout", "$RegistryUri")
|
||||
|
||||
if ($RegistryPassword) {
|
||||
Start-Docker -ArgumentList ("logout", "$RegistryUri")
|
||||
}
|
||||
else {
|
||||
Write-Host "Skipping docker logout, password not available so we did not login"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue