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