ci: First pass for Windows CI

This commit is contained in:
Ryan Pavlik 2022-05-18 11:10:12 -05:00
parent f65a109508
commit 6cabf38e36
14 changed files with 644 additions and 6 deletions

View file

@ -192,6 +192,81 @@ arch:rolling:container_prep:
- .fdo.distribution-image@arch # from ci-templates
# # #
###
# Windows container-related jobs (prep and usage)
.monado.common_variables.windows:vs2022:
inherit:
default: false
variables:
FDO_DISTRIBUTION_TAG: "20220518.0"
MONADO_BASE_IMAGE_PATH: "win2019/vs2022_base"
MONADO_MAIN_IMAGE_PATH: "win2019/vs2022"
.monado.variables.windows:vs2022:
inherit:
default: false
extends:
- .monado.common_variables.windows:vs2022
variables:
MONADO_IMAGE_PATH: "$MONADO_MAIN_IMAGE_PATH"
MONADO_IMAGE: "$CI_REGISTRY_IMAGE/$MONADO_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
MONADO_UPSTREAM_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/$MONADO_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
# Shared container-building job
.monado.windows.container_prep:
inherit:
default: false
tags:
- windows
- "1909"
- shell
variables:
GIT_STRATEGY: fetch
only:
changes:
- .gitlab-ci/**/*
stage: container_prep
script:
- |
.gitlab-ci\windows\monado_container.ps1 -RegistryUri "$CI_REGISTRY" -RegistryUsername "$CI_REGISTRY_USER" -UserImage "$MONADO_IMAGE" -UpstreamImage "$MONADO_UPSTREAM_IMAGE" -Dockerfile "$DOCKERFILE" -BaseImage "$MONADO_BASE_IMAGE" -BaseUpstreamImage "$MONADO_UPSTREAM_BASE_IMAGE" -Verbose
# This container just installs Visual C++ Build Tools.
win:container_prep:base:
extends:
- .monado.windows.container_prep
- .monado.common_variables.windows:vs2022
variables:
DOCKERFILE: Dockerfile.vs2022
MONADO_IMAGE_PATH: ${MONADO_BASE_IMAGE_PATH}
MONADO_IMAGE: "$CI_REGISTRY_IMAGE/$MONADO_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
MONADO_UPSTREAM_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/$MONADO_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
# This container adds other deps
win:container_prep:
extends:
- .monado.windows.container_prep
- .monado.variables.windows:vs2022
needs:
- win:container_prep:base
variables:
DOCKERFILE: Dockerfile.build
MONADO_BASE_IMAGE: "$CI_REGISTRY_IMAGE/$MONADO_BASE_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
MONADO_UPSTREAM_BASE_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/$MONADO_BASE_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
# Base job to use a Windows build container
.monado.image.windows:
tags:
- windows
- "1909"
- docker
extends:
- .monado.variables.windows:vs2022
image: $MONADO_IMAGE
needs:
- win:container_prep
# Style check job
format-and-spellcheck:
extends:
@ -389,6 +464,17 @@ arch:cmake:clang:
- ninja -C build
- cd build && ctest --output-on-failure
# Windows build
windows:
stage: build
extends:
- .monado.image.windows
script:
- ./.gitlab-ci/windows/monado_build.ps1
artifacts:
paths:
- install
# Packaging
.monado.packaging.conditions:
rules:

0
.gitlab-ci/android_container_prep.sh Normal file → Executable file
View file

View file

@ -4,23 +4,29 @@
# To generate all the templated files, run this from the root of the repo:
# make -f .gitlab-ci/ci-scripts.mk
# These also all have their template named the same with a .template suffix.
# These also all have their template named the same with a .jinja suffix.
FILES_IN_SUBDIR := \
.gitlab-ci/distributions \
.gitlab-ci/reprepro.sh \
CONFIG_FILE := .gitlab-ci/config.yml
all: .gitlab-ci.yml $(FILES_IN_SUBDIR)
OUTPUTS := .gitlab-ci.yml \
$(FILES_IN_SUBDIR)
all: $(OUTPUTS)
chmod +x .gitlab-ci/*.sh
.PHONY: all
clean:
rm -f .gitlab-ci.yml $(FILES_IN_SUBDIR)
rm -f $(OUTPUTS)
.PHONY: clean
CI_FAIRY := ci-fairy generate-template --config=$(CONFIG_FILE)
# As the default thing for ci-fairy to template, this is special cased
.gitlab-ci.yml: .gitlab-ci/ci.template $(CONFIG_FILE)
ci-fairy generate-template
.gitlab-ci.yml: .gitlab-ci/ci.template .gitlab-ci/win_containers.yml $(CONFIG_FILE)
$(CI_FAIRY) $< > $@
# Everything else is structured alike
$(FILES_IN_SUBDIR): %: %.jinja $(CONFIG_FILE)
ci-fairy generate-template --config=$(CONFIG_FILE) $< > $@
$(CI_FAIRY) $< > $@

View file

@ -99,6 +99,8 @@ stages:
{% endfor -%} {%- endfor %}
{% endmacro -%}
{% include 'win_containers.yml' %}
# Style check job
format-and-spellcheck:
extends:
@ -192,6 +194,17 @@ reuse:
{% endfor -%} {%- endfor -%} {%- endfor %}
# Windows build
windows:
stage: build
extends:
- .monado.image.windows
script:
- ./.gitlab-ci/windows/monado_build.ps1
artifacts:
paths:
- install
# Packaging
.monado.packaging.conditions:
rules:

0
.gitlab-ci/i386_and_proclamation_container_prep.sh Normal file → Executable file
View file

0
.gitlab-ci/reprepro.sh Normal file → Executable file
View file

View file

@ -0,0 +1,78 @@
# {# included by ci.template #}
# {# SPDX-License-Identifier: CC0-1.0 #}
# {# SPDX-FileCopyrightText: 2018-2022 Collabora, Ltd. and the Monado contributors #}
###
# Windows container-related jobs (prep and usage)
.monado.common_variables.windows:vs2022:
inherit:
default: false
variables:
FDO_DISTRIBUTION_TAG: "20220518.0"
MONADO_BASE_IMAGE_PATH: "win2019/vs2022_base"
MONADO_MAIN_IMAGE_PATH: "win2019/vs2022"
.monado.variables.windows:vs2022:
inherit:
default: false
extends:
- .monado.common_variables.windows:vs2022
variables:
MONADO_IMAGE_PATH: "$MONADO_MAIN_IMAGE_PATH"
MONADO_IMAGE: "$CI_REGISTRY_IMAGE/$MONADO_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
MONADO_UPSTREAM_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/$MONADO_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
# Shared container-building job
.monado.windows.container_prep:
inherit:
default: false
tags:
- windows
- "1909"
- shell
variables:
GIT_STRATEGY: fetch
only:
changes:
- .gitlab-ci/**/*
stage: container_prep
script:
- |
.gitlab-ci\windows\monado_container.ps1 -RegistryUri "$CI_REGISTRY" -RegistryUsername "$CI_REGISTRY_USER" -UserImage "$MONADO_IMAGE" -UpstreamImage "$MONADO_UPSTREAM_IMAGE" -Dockerfile "$DOCKERFILE" -BaseImage "$MONADO_BASE_IMAGE" -BaseUpstreamImage "$MONADO_UPSTREAM_BASE_IMAGE" -Verbose
# This container just installs Visual C++ Build Tools.
win:container_prep:base:
extends:
- .monado.windows.container_prep
- .monado.common_variables.windows:vs2022
variables:
DOCKERFILE: Dockerfile.vs2022
MONADO_IMAGE_PATH: ${MONADO_BASE_IMAGE_PATH}
MONADO_IMAGE: "$CI_REGISTRY_IMAGE/$MONADO_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
MONADO_UPSTREAM_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/$MONADO_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
# This container adds other deps
win:container_prep:
extends:
- .monado.windows.container_prep
- .monado.variables.windows:vs2022
needs:
- win:container_prep:base
variables:
DOCKERFILE: Dockerfile.build
MONADO_BASE_IMAGE: "$CI_REGISTRY_IMAGE/$MONADO_BASE_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
MONADO_UPSTREAM_BASE_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/$MONADO_BASE_IMAGE_PATH:$FDO_DISTRIBUTION_TAG"
# Base job to use a Windows build container
.monado.image.windows:
tags:
- windows
- "1909"
- docker
extends:
- .monado.variables.windows:vs2022
image: $MONADO_IMAGE
needs:
- win:container_prep

View file

@ -0,0 +1,17 @@
# Copyright 2019-2022, Mesa contributors
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: MIT
# Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/8396df5ad90aeb6ab2267811aba2187954562f81/.gitlab-ci/windows/Dockerfile_build
# escape=`
ARG base_image
FROM ${base_image}
# Make sure any failure in PowerShell scripts is fatal
SHELL ["powershell", "-ExecutionPolicy", "RemoteSigned", "-Command", "$ErrorActionPreference = 'Stop';"]
ENV ErrorActionPreference='Stop'
COPY "monado_deps_build.ps1" "C:/"
RUN "C:/monado_deps_build.ps1"

View file

@ -0,0 +1,16 @@
# Copyright 2019-2022, Mesa contributors
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: MIT
# Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/8396df5ad90aeb6ab2267811aba2187954562f81/.gitlab-ci/windows/Dockerfile_build
# escape=`
# FROM mcr.microsoft.com/windows:2004
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# Make sure any failure in PowerShell scripts is fatal
SHELL ["powershell", "-ExecutionPolicy", "RemoteSigned", "-Command", "$ErrorActionPreference = 'Stop';"]
ENV ErrorActionPreference='Stop'
COPY "monado_deps_vs2022.ps1" "C:/"
RUN "C:/monado_deps_vs2022.ps1"

View file

@ -0,0 +1,70 @@
# Native Windows GitLab CI builds
<!--
# Copyright 2019-2022, Mesa contributors
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: MIT
Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/8396df5ad90aeb6ab2267811aba2187954562f81/.gitlab-ci/windows/README.md
-->
We are using the same basic approach to Windows CI building as Mesa, just as we
do on Linux. See
<https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/.gitlab-ci/windows> for
the details there. The following is the Mesa readme, lightly modified to fit
Monado.
Unlike Linux, Windows cannot reuse the freedesktop ci-templates as they exist
as we do not have Podman, Skopeo, or even Docker-in-Docker builds available
under Windows.
We still reuse the same model: build a base container with the core operating
system and infrequently-changed build dependencies, then execute Monado builds
only inside that base container. This is open-coded in PowerShell scripts.
## Base container build
The base container build jobs execute the `monado_container.ps1` script which
reproduces the ci-templates behaviour. It looks for the registry image in
the user's namespace, and exits if found. If not found, it tries to copy
the same image tag from the upstream Monado repository. If that is not found,
the image is rebuilt inside the user's namespace.
The rebuild executes `docker build` which calls `monado_deps_*.ps1` inside the
container to fetch and install all build dependencies. This includes Visual
Studio Build Tools (downloaded from Microsoft, under the license which
allows use by open-source projects), and other build tools from Scoop.
(These are done as two separate jobs to allow "resuming from the middle".)
This job is executed inside a Windows shell environment directly inside the
host, without Docker.
## Monado build
The Monado build runs inside the base container, executing `mesa_build.ps1`.
This simply compiles Monado using CMake and Ninja, executing the build and
unit tests.
## Local testing
To try these scripts locally, you need this done once, rebooting after they are complete:
```pwsh
scoop install sudo
sudo Add-MpPreference -ExclusionProcess dockerd.exe
sudo Add-MpPreference -ExclusionProcess docker.exe
winget install stevedore
sudo Add-MpPreference -ExclusionPath c:\ProgramData\docker
```
then this, done when you want to test:
```pwsh
docker context use desktop-windows
```
before doing your normal `docker build .`, etc. (It may still be very slow
despite the virus scanning exclusions.)
If you're having issues accessing the network, see this comment's instructions:
<https://github.com/docker/for-win/issues/9847#issuecomment-832674649>

View file

@ -0,0 +1,61 @@
# Copyright 2019-2022, Mesa contributors
# Copyright 2022, Collabora, Ltd.
# 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
$env:PYTHONUTF8 = 1
Get-Date
Write-Host "Compiling Monado"
$sourcedir = (Resolve-Path "$PSScriptRoot/../..")
$builddir = Join-Path $sourcedir "build"
$installdir = Join-Path $sourcedir "install"
$vcpkgdir = "c:\vcpkg"
$toolchainfile = Join-Path $vcpkgdir "scripts/buildsystems/vcpkg.cmake"
Remove-Item -Recurse -Force $installdir -ErrorAction SilentlyContinue
Write-Output "builddir:$builddir"
Write-Output "installdir:$installdir"
Write-Output "sourcedir:$sourcedir"
$installPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 17 -property installationpath
Write-Output "vswhere.exe installPath: $installPath"
$installPath = "C:\BuildTools"
Write-Output "Final 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.
Import-Module (Join-Path $installPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $installPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo -host_arch=amd64'
Push-Location $sourcedir
$cmakeArgs = @(
"-S"
"."
"-B"
"$builddir"
"-GNinja"
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
"-DCMAKE_TOOLCHAIN_FILE=$toolchainfile"
"-DCMAKE_INSTALL_PREFIX=$installdir"
)
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
}

View file

@ -0,0 +1,197 @@
# Copyright 2019-2022, Mesa contributors
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: MIT
# Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/8396df5ad90aeb6ab2267811aba2187954562f81/.gitlab-ci/windows/mesa_container.ps1
# Implements the equivalent of ci-templates container-ifnot-exists, using
# Docker directly as we don't have buildah/podman/skopeo available under
# Windows, nor can we execute Docker-in-Docker
[CmdletBinding()]
param (
# Address for container registry
[Parameter()]
[string]
$RegistryUri,
# Username for container registry
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$RegistryUsername,
# The path of the image for this user's fork
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$UserImage,
# The path of the image in the upstream registry
[Parameter()]
[string]
$UpstreamImage,
# Dockerfile to build
[Parameter()]
[string]
$Dockerfile = "Dockerfile",
# Base image to use for this container, if any
[Parameter()]
[string]
$BaseImage,
# Base image to use for this container, from the upstream repo, if any
[Parameter()]
[string]
$BaseUpstreamImage
)
$RegistryPassword = "$env:CI_REGISTRY_PASSWORD"
$CommonDockerArgs = @(
"--config"
"windows-docker.conf"
)
$ErrorActionPreference = 'Stop'
# Returns $true on a zero error code
# If $AllowFailure is not set, throws on a nonzero exit code
function Start-Docker {
param (
# Should we just return the exit code on failure instead of throwing?
[Parameter()]
[switch]
$AllowFailure = $false,
# Should we try to log out before throwing in case of an error?
[Parameter()]
[switch]
$LogoutOnFailure = $false,
# What arguments should be passed to docker (besides the config)
[Parameter(Mandatory = $true)]
[string[]]
$ArgumentList
)
$DockerArgs = $CommonDockerArgs + $ArgumentList
Write-Verbose ("Will run docker " + ($DockerArgs -join " "))
$proc = Start-Process -FilePath "docker" -ArgumentList $DockerArgs -NoNewWindow -PassThru -WorkingDirectory "$PSScriptRoot" -Wait
if ($proc.ExitCode -eq 0) {
Write-Verbose "Success!"
return $true
}
if (!$AllowFailure) {
Write-Error ($ArgumentList[0] + " failed")
if ($LogoutOnFailure) {
Write-Host "Logging out"
Start-Process -FilePath "docker" -ArgumentList ($CommonDockerArgs + @("logout", "$RegistryUri")) `
-NoNewWindow -PassThru -WorkingDirectory "$PSScriptRoot" -Wait
}
throw ("docker " + $ArgumentList[0] + " invocation failed")
}
return $false
}
# Returns $true if the $Image exists (whether or not we had to copy $UpstreamImage)
function Test-Image {
param (
# Image to look for
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]
$Image,
# Equivalent image from the upstream repo, if any
[Parameter()]
[string]
$UpstreamImage
)
# if the image already exists, great
Write-Verbose "Looking for $Image"
# $pullResult = Start-Docker -AllowFailure -ArgumentList ("pull", "$Image")
docker @CommonDockerArgs pull "$Image"
if ($?) {
Write-Host "Image $UserImage exists"
return $true
}
if (!$UpstreamImage) {
Write-Host "Cannot find $Image"
return $false
}
# if it's only upstream, copy it
Write-Host "Cannot find $Image, looking for upstream $UpstreamImage"
docker @CommonDockerArgs pull "$UpstreamImage"
if ($?) {
Write-Host "Found upstream image, copying image from upstream $UpstreamImage to user $Image"
Start-Docker -LogoutOnFailure -ArgumentList ("tag", "$UpstreamImage", "$Image")
Start-Docker -LogoutOnFailure -ArgumentList ("push", "$Image")
return $true
}
Write-Host "Cannot find $Image nor $UpstreamImage"
return $false
}
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 {
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 the image already exists, don't rebuild it
$imageResult = Test-Image -Image $UserImage -UpstreamImage $UpstreamImage
if ($imageResult) {
Write-Host "User image $UserImage already exists; not rebuilding"
Start-Docker -ArgumentList ("logout", "$RegistryUri")
Exit 0
}
# do we need a base image?
if ($BaseImage) {
$baseImageResult = Test-Image -Image "$BaseImage" -UpstreamImage "$BaseUpstreamImage"
if (!$baseImageResult) {
throw "Could not find base image: neither '$BaseImage' nor '$BaseUpstreamImage' exist."
}
}
Write-Host "No image found at $UserImage or $UpstreamImage; rebuilding, this may take a while"
$DockerBuildArgs = @(
"build"
"--no-cache"
"-t"
"$UserImage"
"-f"
"$Dockerfile"
)
if ($BaseImage) {
$DockerBuildArgs += @(
"--build-arg"
"base_image=$BaseImage"
)
}
$DockerBuildArgs += "."
Start-Docker -LogoutOnFailure -ArgumentList (, $DockerBuildArgs)
Get-Date
Write-Host "Done building image, now pushing $UserImage"
Start-Docker -LogoutOnFailure -ArgumentList ("push", "$UserImage")
Start-Docker -ArgumentList ("logout", "$RegistryUri")

View file

@ -0,0 +1,51 @@
# Copyright 2019-2022, Mesa contributors
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: MIT
# Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/8396df5ad90aeb6ab2267811aba2187954562f81/.gitlab-ci/windows/mesa_deps_build.ps1
# Download new TLS certs from Windows Update
Get-Date
Write-Host "Updating TLS certificate store"
$certdir = (New-Item -ItemType Directory -Name "_tlscerts")
certutil -syncwithWU "$certdir"
Foreach ($file in (Get-ChildItem -Path "$certdir\*" -Include "*.crt")) {
Import-Certificate -FilePath $file -CertStoreLocation Cert:\LocalMachine\Root
}
Remove-Item -Recurse -Path $certdir
Get-Date
Write-Host "Installing runtime redistributables"
Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "C:\vcredist_x64.exe" -UseBasicParsing
Start-Process -NoNewWindow -Wait "C:\vcredist_x64.exe" -ArgumentList "/install /passive /norestart /log out.txt"
if (!$?) {
Write-Host "Failed to install vc_redist"
Exit 1
}
Remove-Item "C:\vcredist_x64.exe" -Force
Get-Date
Write-Host "Installing Scoop"
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-WebRequest get.scoop.sh -OutFile install.ps1
.\install.ps1 -RunAsAdmin
scoop install git
Get-Date
Write-Host "Installing things from Scoop"
scoop install cmake
scoop install python
scoop install vulkan
scoop install ninja
Get-Date
Write-Host "Preparing vcpkg"
Set-Location C:\
git clone https://github.com/microsoft/vcpkg.git
Set-Location vcpkg
./bootstrap-vcpkg.bat -DisableMetrics
Get-Date
Write-Host "Installing some base deps from vcpkg"
./vcpkg.exe install cjson:x64-windows eigen3:x64-windows wil:x64-windows pthreads:x64-windows glslang:x64-windows libusb:x64-windows hidapi:x64-windows
Remove-Item -Recurse -Path downloads
Remove-Item -Recurse -Path buildtrees

View file

@ -0,0 +1,43 @@
# Copyright 2019-2022, Mesa contributors
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: MIT
# Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/8396df5ad90aeb6ab2267811aba2187954562f81/.gitlab-ci/windows/mesa_deps_vs2019.ps1
# we want more secure TLS 1.2 for most things
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
# VS17.x is 2022
$msvc_url = 'https://aka.ms/vs/17/release/vs_buildtools.exe'
Get-Date
Write-Host "Downloading Visual Studio 2022 build tools"
Invoke-WebRequest -Uri $msvc_url -OutFile C:\vs_buildtools.exe -UseBasicParsing
Get-Date
Write-Host "Installing Visual Studio"
$vsInstallerArgs = @(
"--wait"
"--quiet"
"--norestart"
"--nocache"
"--installPath"
"C:\BuildTools"
"--add"
"Microsoft.VisualStudio.Component.VC.CoreBuildTools"
"--add"
"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core"
"--add"
"Microsoft.VisualStudio.Component.Windows10SDK"
"--add"
"Microsoft.VisualStudio.Component.Windows11SDK.22000"
"--add"
"Component.Microsoft.Windows.CppWinRT"
"--add"
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
)
Start-Process -NoNewWindow -Wait C:\vs_buildtools.exe -ArgumentList $vsInstallerArgs
if (!$?) {
Write-Host "Failed to install Visual Studio tools"
Exit 1
}
Remove-Item C:\vs_buildtools.exe -Force