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.614.1 --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 setup .. --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.3.1 --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.3.1-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 robocopy deps/zlib/zlib-1.3.1 deps/zlib /E 45 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path deps/zlib/zlib-1.3.1 46 $zlib_build = New-Item -ItemType Directory -Path ".\deps\zlib" -Name "build" 47 Push-Location -Path $zlib_build.FullName 48 meson setup .. --backend=ninja -Dprefix="$depsInstallPath" --default-library=static --buildtype=release -Db_vscrt=mt && ` 49 ninja -j32 install 50 $buildstatus = $? 51 Pop-Location 52 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $zlib_build 53 if (!$buildstatus) { 54 Write-Host "Failed to compile zlib" 55 Exit 1 56 } 57 58 Get-Date 59 Write-Host "Cloning LLVM release/15.x" 60 git clone -b release/15.x --depth=1 https://github.com/llvm/llvm-project deps/llvm-project 61 if (!$?) { 62 Write-Host "Failed to clone LLVM repository" 63 Exit 1 64 } 65 66 Get-Date 67 Write-Host "Cloning SPIRV-LLVM-Translator" 68 git clone -b llvm_release_150 https://github.com/KhronosGroup/SPIRV-LLVM-Translator deps/llvm-project/llvm/projects/SPIRV-LLVM-Translator 69 if (!$?) { 70 Write-Host "Failed to clone SPIRV-LLVM-Translator repository" 71 Exit 1 72 } 73 74 Get-Date 75 # slightly convoluted syntax but avoids the CWD being under the PS filesystem meta-path 76 $llvm_build = New-Item -ItemType Directory -ErrorAction SilentlyContinue -Force -Path ".\deps\llvm-project" -Name "build" 77 Push-Location -Path $llvm_build.FullName 78 Write-Host "Compiling LLVM and Clang" 79 cmake ../llvm ` 80 -GNinja ` 81 -DCMAKE_BUILD_TYPE=Release ` 82 -DLLVM_USE_CRT_RELEASE=MT ` 83 -DCMAKE_PREFIX_PATH="$depsInstallPath" ` 84 -DCMAKE_INSTALL_PREFIX="$depsInstallPath" ` 85 -DLLVM_ENABLE_PROJECTS="clang" ` 86 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" ` 87 -DLLVM_OPTIMIZED_TABLEGEN=TRUE ` 88 -DLLVM_ENABLE_ASSERTIONS=TRUE ` 89 -DLLVM_INCLUDE_UTILS=OFF ` 90 -DLLVM_INCLUDE_RUNTIMES=OFF ` 91 -DLLVM_INCLUDE_TESTS=OFF ` 92 -DLLVM_INCLUDE_EXAMPLES=OFF ` 93 -DLLVM_INCLUDE_GO_TESTS=OFF ` 94 -DLLVM_INCLUDE_BENCHMARKS=OFF ` 95 -DLLVM_BUILD_LLVM_C_DYLIB=OFF ` 96 -DLLVM_ENABLE_DIA_SDK=OFF ` 97 -DCLANG_BUILD_TOOLS=ON ` 98 -DLLVM_SPIRV_INCLUDE_TESTS=OFF ` 99 -DLLVM_ENABLE_ZLIB=OFF ` 100 -Wno-dev && ` 101 ninja -j32 install 102 $buildstatus = $? 103 Pop-Location 104 if (!$buildstatus) { 105 Write-Host "Failed to compile LLVM" 106 Exit 1 107 } 108 109 Get-Date 110 $libclc_build = New-Item -ItemType Directory -Path ".\deps\llvm-project" -Name "build-libclc" 111 Push-Location -Path $libclc_build.FullName 112 Write-Host "Compiling libclc" 113 # libclc can only be built with Ninja, because CMake's VS backend doesn't know how to compile new language types 114 cmake ../libclc ` 115 -GNinja ` 116 -DCMAKE_BUILD_TYPE=Release ` 117 -DCMAKE_CXX_FLAGS="-m64" ` 118 -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ` 119 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ` 120 -DCMAKE_INSTALL_PREFIX="$depsInstallPath" ` 121 -DLIBCLC_TARGETS_TO_BUILD="spirv-mesa3d-;spirv64-mesa3d-" && ` 122 ninja -j32 install 123 $buildstatus = $? 124 Pop-Location 125 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $libclc_build 126 if (!$buildstatus) { 127 Write-Host "Failed to compile libclc" 128 Exit 1 129 } 130 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $llvm_build 131 132 Get-Date 133 Write-Host "Cloning SPIRV-Tools" 134 git clone -b "vulkan-sdk-$env:VULKAN_SDK_VERSION" --depth=1 https://github.com/KhronosGroup/SPIRV-Tools deps/SPIRV-Tools 135 if (!$?) { 136 Write-Host "Failed to clone SPIRV-Tools repository" 137 Exit 1 138 } 139 git clone -b "vulkan-sdk-$env:VULKAN_SDK_VERSION" --depth=1 https://github.com/KhronosGroup/SPIRV-Headers deps/SPIRV-Tools/external/SPIRV-Headers 140 if (!$?) { 141 Write-Host "Failed to clone SPIRV-Headers repository" 142 Exit 1 143 } 144 Write-Host "Building SPIRV-Tools" 145 $spv_build = New-Item -ItemType Directory -Path ".\deps\SPIRV-Tools" -Name "build" 146 Push-Location -Path $spv_build.FullName 147 # SPIRV-Tools doesn't use multi-threaded MSVCRT, but we need it to 148 cmake .. ` 149 -GNinja ` 150 -DCMAKE_BUILD_TYPE=Release ` 151 -DCMAKE_POLICY_DEFAULT_CMP0091=NEW ` 152 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ` 153 -DCMAKE_INSTALL_PREFIX="$depsInstallPath" && ` 154 ninja -j32 install 155 $buildstatus = $? 156 Pop-Location 157 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $spv_build 158 if (!$buildstatus) { 159 Write-Host "Failed to compile SPIRV-Tools" 160 Exit 1 161 } 162 Remove-Symlinks()163function Remove-Symlinks { 164 Get-ChildItem -Force -ErrorAction SilentlyContinue @Args | Where-Object { if($_.Attributes -match "ReparsePoint"){$_.Delete()} } 165 } 166 Remove-Symlinks -Path "deps" -Recurse 167 Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path "deps" | Out-Null 168 169 Get-Date 170 Write-Host "Complete" 171