1
2$MyPath = $MyInvocation.MyCommand.Path | Split-Path -Parent
3. "$MyPath\mesa_vs_init.ps1"
4
5# we want more secure TLS 1.2 for most things, but it breaks SourceForge
6# downloads so must be done after Chocolatey use
7[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13;
8
9Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "deps" | Out-Null
10
11Get-Date
12Write-Host "Cloning LLVM release/12.x"
13git clone -b release/12.x --depth=1 https://github.com/llvm/llvm-project deps/llvm-project
14if (!$?) {
15  Write-Host "Failed to clone LLVM repository"
16  Exit 1
17}
18
19# ideally we want to use a tag here insted of a sha,
20# but as of today, SPIRV-LLVM-Translator doesn't have
21# a tag matching LLVM 12.0.0
22Get-Date
23Write-Host "Cloning SPIRV-LLVM-Translator"
24git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator deps/llvm-project/llvm/projects/SPIRV-LLVM-Translator
25if (!$?) {
26  Write-Host "Failed to clone SPIRV-LLVM-Translator repository"
27  Exit 1
28}
29Push-Location deps/llvm-project/llvm/projects/SPIRV-LLVM-Translator
30git checkout 5b641633b3bcc3251a52260eee11db13a79d7258
31Pop-Location
32
33$depsInstallPath="C:\mesa-deps"
34
35Get-Date
36# slightly convoluted syntax but avoids the CWD being under the PS filesystem meta-path
37$llvm_build = New-Item -ItemType Directory -ErrorAction SilentlyContinue -Force -Path ".\deps\llvm-project" -Name "build"
38Push-Location -Path $llvm_build.FullName
39Write-Host "Compiling LLVM and Clang"
40cmake ../llvm `
41-GNinja `
42-DCMAKE_BUILD_TYPE=Release `
43-DLLVM_USE_CRT_RELEASE=MT `
44-DCMAKE_PREFIX_PATH="$depsInstallPath" `
45-DCMAKE_INSTALL_PREFIX="$depsInstallPath" `
46-DLLVM_ENABLE_PROJECTS="clang" `
47-DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" `
48-DLLVM_OPTIMIZED_TABLEGEN=TRUE `
49-DLLVM_ENABLE_ASSERTIONS=TRUE `
50-DLLVM_INCLUDE_UTILS=OFF `
51-DLLVM_INCLUDE_RUNTIMES=OFF `
52-DLLVM_INCLUDE_TESTS=OFF `
53-DLLVM_INCLUDE_EXAMPLES=OFF `
54-DLLVM_INCLUDE_GO_TESTS=OFF `
55-DLLVM_INCLUDE_BENCHMARKS=OFF `
56-DLLVM_BUILD_LLVM_C_DYLIB=OFF `
57-DLLVM_ENABLE_DIA_SDK=OFF `
58-DCLANG_BUILD_TOOLS=ON `
59-DLLVM_SPIRV_INCLUDE_TESTS=OFF `
60-Wno-dev && `
61ninja -j32 install
62$buildstatus = $?
63Pop-Location
64if (!$buildstatus) {
65  Write-Host "Failed to compile LLVM"
66  Exit 1
67}
68
69Get-Date
70$libclc_build = New-Item -ItemType Directory -Path ".\deps\llvm-project" -Name "build-libclc"
71Push-Location -Path $libclc_build.FullName
72Write-Host "Compiling libclc"
73# libclc can only be built with Ninja, because CMake's VS backend doesn't know how to compile new language types
74cmake ../libclc `
75-GNinja `
76-DCMAKE_BUILD_TYPE=Release `
77-DCMAKE_CXX_FLAGS="-m64" `
78-DCMAKE_POLICY_DEFAULT_CMP0091=NEW `
79-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
80-DCMAKE_INSTALL_PREFIX="$depsInstallPath" `
81-DLIBCLC_TARGETS_TO_BUILD="spirv-mesa3d-;spirv64-mesa3d-" && `
82ninja -j32 install
83$buildstatus = $?
84Pop-Location
85Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $libclc_build
86if (!$buildstatus) {
87  Write-Host "Failed to compile libclc"
88  Exit 1
89}
90Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $llvm_build
91
92Get-Date
93Write-Host "Cloning SPIRV-Tools"
94git clone -b "sdk-$env:VULKAN_SDK_VERSION" --depth=1 https://github.com/KhronosGroup/SPIRV-Tools deps/SPIRV-Tools
95if (!$?) {
96  Write-Host "Failed to clone SPIRV-Tools repository"
97  Exit 1
98}
99git clone -b "sdk-$env:VULKAN_SDK_VERSION" --depth=1 https://github.com/KhronosGroup/SPIRV-Headers deps/SPIRV-Tools/external/SPIRV-Headers
100if (!$?) {
101  Write-Host "Failed to clone SPIRV-Headers repository"
102  Exit 1
103}
104Write-Host "Building SPIRV-Tools"
105$spv_build = New-Item -ItemType Directory -Path ".\deps\SPIRV-Tools" -Name "build"
106Push-Location -Path $spv_build.FullName
107# SPIRV-Tools doesn't use multi-threaded MSVCRT, but we need it to
108cmake .. `
109-GNinja `
110-DCMAKE_BUILD_TYPE=Release `
111-DCMAKE_POLICY_DEFAULT_CMP0091=NEW `
112-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
113-DCMAKE_INSTALL_PREFIX="$depsInstallPath" && `
114ninja -j32 install
115$buildstatus = $?
116Pop-Location
117Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $spv_build
118if (!$buildstatus) {
119  Write-Host "Failed to compile SPIRV-Tools"
120  Exit 1
121}
122
123function Remove-Symlinks {
124  Get-ChildItem -Force -ErrorAction SilentlyContinue @Args | Where-Object { if($_.Attributes -match "ReparsePoint"){$_.Delete()} }
125}
126Remove-Symlinks -Path "deps" -Recurse
127Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path "deps" | Out-Null
128
129Get-Date
130Write-Host "Complete"
131