1# Download new TLS certs from Windows Update
2Get-Date
3Write-Host "Updating TLS certificate store"
4Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "_tlscerts" | Out-Null
5$certdir = (New-Item -ItemType Directory -Name "_tlscerts")
6certutil -syncwithWU "$certdir"
7Foreach ($file in (Get-ChildItem -Path "$certdir\*" -Include "*.crt")) {
8  Import-Certificate -FilePath $file -CertStoreLocation Cert:\LocalMachine\Root | Out-Null
9}
10Remove-Item -Recurse -Path $certdir
11
12
13Get-Date
14Write-Host "Installing Chocolatey"
15Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
16Import-Module "$env:ProgramData\chocolatey\helpers\chocolateyProfile.psm1"
17Update-SessionEnvironment
18Write-Host "Installing Chocolatey packages"
19
20# Chocolatey tries to download winflexbison from SourceForge, which is not super reliable, and has no retry
21# loop of its own - so we give it a helping hand here
22For ($i = 0; $i -lt 5; $i++) {
23  choco install --no-progress -y python3 --params="/InstallDir:C:\python3"
24  $python_install = $?
25  choco install --allow-empty-checksums --no-progress -y cmake git git-lfs ninja pkgconfiglite winflexbison --installargs "ADD_CMAKE_TO_PATH=System"
26  $other_install = $?
27  $choco_installed = $other_install -and $python_install
28  if ($choco_installed) {
29    Break
30  }
31}
32
33if (!$choco_installed) {
34  Write-Host "Couldn't install dependencies from Chocolatey"
35  Exit 1
36}
37
38# Add Chocolatey's native install path
39Update-SessionEnvironment
40# Python and CMake add themselves to the system environment path, which doesn't get refreshed
41# until we start a new shell
42$env:PATH = "C:\python3;C:\python3\scripts;C:\Program Files\CMake\bin;$env:PATH"
43
44Start-Process -NoNewWindow -Wait git -ArgumentList 'config --global core.autocrlf false'
45
46Get-Date
47Write-Host "Installing Meson, Mako and numpy"
48pip3 install meson mako numpy --progress-bar off
49if (!$?) {
50  Write-Host "Failed to install dependencies from pip"
51  Exit 1
52}
53
54Get-Date
55Write-Host "Downloading Vulkan-SDK"
56Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/$env:VULKAN_SDK_VERSION/windows/VulkanSDK-$env:VULKAN_SDK_VERSION-Installer.exe" -OutFile 'C:\vulkan_sdk.exe'
57C:\vulkan_sdk.exe --am --al -c in
58if (!$?) {
59    Write-Host "Failed to install Vulkan SDK"
60    Exit 1
61}
62Remove-Item C:\vulkan_sdk.exe -Force
63
64Get-Date
65Write-Host "Downloading Vulkan-Runtime"
66Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/$env:VULKAN_SDK_VERSION/windows/VulkanRT-$env:VULKAN_SDK_VERSION-Installer.exe" -OutFile 'C:\vulkan-runtime.exe' | Out-Null
67Write-Host "Installing Vulkan-Runtime"
68Start-Process -NoNewWindow -Wait C:\vulkan-runtime.exe -ArgumentList '/S'
69if (!$?) {
70  Write-Host "Failed to install Vulkan-Runtime"
71  Exit 1
72}
73Remove-Item C:\vulkan-runtime.exe -Force
74