• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
9 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "deps" | Out-Null
10 
11 Get-Date
12 Write-Host "Cloning LLVM release/12.x"
13 git clone -b release/12.x --depth=1 https://github.com/llvm/llvm-project deps/llvm-project
14 if (!$?) {
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
22 Get-Date
23 Write-Host "Cloning SPIRV-LLVM-Translator"
24 git clone https://github.com/KhronosGroup/SPIRV-LLVM-Translator deps/llvm-project/llvm/projects/SPIRV-LLVM-Translator
25 if (!$?) {
26   Write-Host "Failed to clone SPIRV-LLVM-Translator repository"
27   Exit 1
28 }
29 Push-Location deps/llvm-project/llvm/projects/SPIRV-LLVM-Translator
30 git checkout 5b641633b3bcc3251a52260eee11db13a79d7258
31 Pop-Location
32 
33 $depsInstallPath="C:\mesa-deps"
34 
35 Get-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"
38 Push-Location -Path $llvm_build.FullName
39 Write-Host "Compiling LLVM and Clang"
40 cmake ../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 && `
61 ninja -j32 install
62 $buildstatus = $?
63 Pop-Location
64 if (!$buildstatus) {
65   Write-Host "Failed to compile LLVM"
66   Exit 1
67 }
68 
69 Get-Date
70 $libclc_build = New-Item -ItemType Directory -Path ".\deps\llvm-project" -Name "build-libclc"
71 Push-Location -Path $libclc_build.FullName
72 Write-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
74 cmake ../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-" && `
82 ninja -j32 install
83 $buildstatus = $?
84 Pop-Location
85 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $libclc_build
86 if (!$buildstatus) {
87   Write-Host "Failed to compile libclc"
88   Exit 1
89 }
90 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $llvm_build
91 
92 Get-Date
93 Write-Host "Cloning SPIRV-Tools"
94 git clone -b "sdk-$env:VULKAN_SDK_VERSION" --depth=1 https://github.com/KhronosGroup/SPIRV-Tools deps/SPIRV-Tools
95 if (!$?) {
96   Write-Host "Failed to clone SPIRV-Tools repository"
97   Exit 1
98 }
99 git clone -b "sdk-$env:VULKAN_SDK_VERSION" --depth=1 https://github.com/KhronosGroup/SPIRV-Headers deps/SPIRV-Tools/external/SPIRV-Headers
100 if (!$?) {
101   Write-Host "Failed to clone SPIRV-Headers repository"
102   Exit 1
103 }
104 Write-Host "Building SPIRV-Tools"
105 $spv_build = New-Item -ItemType Directory -Path ".\deps\SPIRV-Tools" -Name "build"
106 Push-Location -Path $spv_build.FullName
107 # SPIRV-Tools doesn't use multi-threaded MSVCRT, but we need it to
108 cmake .. `
109 -GNinja `
110 -DCMAKE_BUILD_TYPE=Release `
111 -DCMAKE_POLICY_DEFAULT_CMP0091=NEW `
112 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
113 -DCMAKE_INSTALL_PREFIX="$depsInstallPath" && `
114 ninja -j32 install
115 $buildstatus = $?
116 Pop-Location
117 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $spv_build
118 if (!$buildstatus) {
119   Write-Host "Failed to compile SPIRV-Tools"
120   Exit 1
121 }
122 
Remove-Symlinks()123 function Remove-Symlinks {
124   Get-ChildItem -Force -ErrorAction SilentlyContinue @Args | Where-Object { if($_.Attributes -match "ReparsePoint"){$_.Delete()} }
125 }
126 Remove-Symlinks -Path "deps" -Recurse
127 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path "deps" | Out-Null
128 
129 Get-Date
130 Write-Host "Complete"
131