• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 $MyPath = $MyInvocation.MyCommand.Path | Split-Path -Parent
3 . "$MyPath\mesa_init_msvc.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 
9 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "deps" | Out-Null
10 
11 $depsInstallPath="C:\mesa-deps"
12 
13 Get-Date
14 Write-Host "Cloning DirectX-Headers"
15 git clone -b v1.611.0 --depth=1 https://github.com/microsoft/DirectX-Headers deps/DirectX-Headers
16 if (!$?) {
17   Write-Host "Failed to clone DirectX-Headers repository"
18   Exit 1
19 }
20 Write-Host "Building DirectX-Headers"
21 $dxheaders_build = New-Item -ItemType Directory -Path ".\deps\DirectX-Headers" -Name "build"
22 Push-Location -Path $dxheaders_build.FullName
23 meson .. --backend=ninja -Dprefix="$depsInstallPath" --buildtype=release -Db_vscrt=mt && `
24 ninja -j32 install
25 $buildstatus = $?
26 Pop-Location
27 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $dxheaders_build
28 if (!$buildstatus) {
29   Write-Host "Failed to compile DirectX-Headers"
30   Exit 1
31 }
32 
33 Get-Date
34 Write-Host "Cloning zlib"
35 git clone -b v1.2.13 --depth=1 https://github.com/madler/zlib deps/zlib
36 if (!$?) {
37   Write-Host "Failed to clone zlib repository"
38   Exit 1
39 }
40 Write-Host "Downloading zlib meson build files"
41 Invoke-WebRequest -Uri "https://wrapdb.mesonbuild.com/v2/zlib_1.2.13-1/get_patch" -OutFile deps/zlib.zip
42 Expand-Archive -Path deps/zlib.zip -Destination deps/zlib
43 # Wrap archive puts build files in a version subdir
44 Move-Item deps/zlib/zlib-1.2.13/* deps/zlib
45 $zlib_build = New-Item -ItemType Directory -Path ".\deps\zlib" -Name "build"
46 Push-Location -Path $zlib_build.FullName
47 meson .. --backend=ninja -Dprefix="$depsInstallPath" --default-library=static --buildtype=release -Db_vscrt=mt && `
48 ninja -j32 install
49 $buildstatus = $?
50 Pop-Location
51 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $zlib_build
52 if (!$buildstatus) {
53   Write-Host "Failed to compile zlib"
54   Exit 1
55 }
56 
57 
58 Get-Date
59 Write-Host "Cloning libva"
60 git clone https://github.com/intel/libva.git deps/libva
61 if (!$?) {
62   Write-Host "Failed to clone libva repository"
63   Exit 1
64 }
65 
66 Push-Location -Path ".\deps\libva"
67 Write-Host "Checking out libva df3c584bb79d1a1e521372d62fa62e8b1c52ce6c"
68 # libva-win32 is released with libva version 2.17 (see https://github.com/intel/libva/releases/tag/2.17.0)
69 git checkout 2.17.0
70 Pop-Location
71 
72 Write-Host "Building libva"
73 # libva already has a build dir in their repo, use builddir instead
74 $libva_build = New-Item -ItemType Directory -Path ".\deps\libva" -Name "builddir"
75 Push-Location -Path $libva_build.FullName
76 meson .. -Dprefix="$depsInstallPath"
77 ninja -j32 install
78 $buildstatus = $?
79 Pop-Location
80 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $libva_build
81 if (!$buildstatus) {
82   Write-Host "Failed to compile libva"
83   Exit 1
84 }
85 
86 Get-Date
87 Write-Host "Cloning LLVM release/15.x"
88 git clone -b release/15.x --depth=1 https://github.com/llvm/llvm-project deps/llvm-project
89 if (!$?) {
90   Write-Host "Failed to clone LLVM repository"
91   Exit 1
92 }
93 
94 Get-Date
95 Write-Host "Cloning SPIRV-LLVM-Translator"
96 git clone -b llvm_release_150 https://github.com/KhronosGroup/SPIRV-LLVM-Translator deps/llvm-project/llvm/projects/SPIRV-LLVM-Translator
97 if (!$?) {
98   Write-Host "Failed to clone SPIRV-LLVM-Translator repository"
99   Exit 1
100 }
101 
102 Get-Date
103 # slightly convoluted syntax but avoids the CWD being under the PS filesystem meta-path
104 $llvm_build = New-Item -ItemType Directory -ErrorAction SilentlyContinue -Force -Path ".\deps\llvm-project" -Name "build"
105 Push-Location -Path $llvm_build.FullName
106 Write-Host "Compiling LLVM and Clang"
107 cmake ../llvm `
108 -GNinja `
109 -DCMAKE_BUILD_TYPE=Release `
110 -DLLVM_USE_CRT_RELEASE=MT `
111 -DCMAKE_PREFIX_PATH="$depsInstallPath" `
112 -DCMAKE_INSTALL_PREFIX="$depsInstallPath" `
113 -DLLVM_ENABLE_PROJECTS="clang" `
114 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" `
115 -DLLVM_OPTIMIZED_TABLEGEN=TRUE `
116 -DLLVM_ENABLE_ASSERTIONS=TRUE `
117 -DLLVM_INCLUDE_UTILS=OFF `
118 -DLLVM_INCLUDE_RUNTIMES=OFF `
119 -DLLVM_INCLUDE_TESTS=OFF `
120 -DLLVM_INCLUDE_EXAMPLES=OFF `
121 -DLLVM_INCLUDE_GO_TESTS=OFF `
122 -DLLVM_INCLUDE_BENCHMARKS=OFF `
123 -DLLVM_BUILD_LLVM_C_DYLIB=OFF `
124 -DLLVM_ENABLE_DIA_SDK=OFF `
125 -DCLANG_BUILD_TOOLS=ON `
126 -DLLVM_SPIRV_INCLUDE_TESTS=OFF `
127 -Wno-dev && `
128 ninja -j32 install
129 $buildstatus = $?
130 Pop-Location
131 if (!$buildstatus) {
132   Write-Host "Failed to compile LLVM"
133   Exit 1
134 }
135 
136 Get-Date
137 $libclc_build = New-Item -ItemType Directory -Path ".\deps\llvm-project" -Name "build-libclc"
138 Push-Location -Path $libclc_build.FullName
139 Write-Host "Compiling libclc"
140 # libclc can only be built with Ninja, because CMake's VS backend doesn't know how to compile new language types
141 cmake ../libclc `
142 -GNinja `
143 -DCMAKE_BUILD_TYPE=Release `
144 -DCMAKE_CXX_FLAGS="-m64" `
145 -DCMAKE_POLICY_DEFAULT_CMP0091=NEW `
146 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
147 -DCMAKE_INSTALL_PREFIX="$depsInstallPath" `
148 -DLIBCLC_TARGETS_TO_BUILD="spirv-mesa3d-;spirv64-mesa3d-" && `
149 ninja -j32 install
150 $buildstatus = $?
151 Pop-Location
152 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $libclc_build
153 if (!$buildstatus) {
154   Write-Host "Failed to compile libclc"
155   Exit 1
156 }
157 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $llvm_build
158 
159 Get-Date
160 Write-Host "Cloning SPIRV-Tools"
161 git clone -b "vulkan-sdk-$env:VULKAN_SDK_VERSION" --depth=1 https://github.com/KhronosGroup/SPIRV-Tools deps/SPIRV-Tools
162 if (!$?) {
163   Write-Host "Failed to clone SPIRV-Tools repository"
164   Exit 1
165 }
166 git clone -b "vulkan-sdk-$env:VULKAN_SDK_VERSION" --depth=1 https://github.com/KhronosGroup/SPIRV-Headers deps/SPIRV-Tools/external/SPIRV-Headers
167 if (!$?) {
168   Write-Host "Failed to clone SPIRV-Headers repository"
169   Exit 1
170 }
171 Write-Host "Building SPIRV-Tools"
172 $spv_build = New-Item -ItemType Directory -Path ".\deps\SPIRV-Tools" -Name "build"
173 Push-Location -Path $spv_build.FullName
174 # SPIRV-Tools doesn't use multi-threaded MSVCRT, but we need it to
175 cmake .. `
176 -GNinja `
177 -DCMAKE_BUILD_TYPE=Release `
178 -DCMAKE_POLICY_DEFAULT_CMP0091=NEW `
179 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
180 -DCMAKE_INSTALL_PREFIX="$depsInstallPath" && `
181 ninja -j32 install
182 $buildstatus = $?
183 Pop-Location
184 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $spv_build
185 if (!$buildstatus) {
186   Write-Host "Failed to compile SPIRV-Tools"
187   Exit 1
188 }
189 
Remove-Symlinksnull190 function Remove-Symlinks {
191   Get-ChildItem -Force -ErrorAction SilentlyContinue @Args | Where-Object { if($_.Attributes -match "ReparsePoint"){$_.Delete()} }
192 }
193 Remove-Symlinks -Path "deps" -Recurse
194 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path "deps" | Out-Null
195 
196 Get-Date
197 Write-Host "Complete"
198