• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 Get-Date
2 Write-Host "Installing Chocolatey"
3 Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
4 Import-Module "$env:ProgramData\chocolatey\helpers\chocolateyProfile.psm1"
5 Update-SessionEnvironment
6 Write-Host "Installing Chocolatey packages"
7 
8 # Chocolatey tries to download winflexbison from SourceForge, which is not super reliable, and has no retry
9 # loop of its own - so we give it a helping hand here
10 For ($i = 0; $i -lt 5; $i++) {
11   choco install -y python3 --params="/InstallDir:C:\python3"
12   $python_install = $?
13   choco install --allow-empty-checksums -y cmake git git-lfs ninja pkgconfiglite winflexbison --installargs "ADD_CMAKE_TO_PATH=System"
14   $other_install = $?
15   $choco_installed = $other_install -and $python_install
16   if ($choco_installed) {
17     Break
18   }
19 }
20 
21 if (!$choco_installed) {
22   Write-Host "Couldn't install dependencies from Chocolatey"
23   Exit 1
24 }
25 
26 # Add Chocolatey's native install path
27 Update-SessionEnvironment
28 # Python and CMake add themselves to the system environment path, which doesn't get refreshed
29 # until we start a new shell
30 $env:PATH = "C:\python3;C:\python3\scripts;C:\Program Files\CMake\bin;$env:PATH"
31 
32 Start-Process -NoNewWindow -Wait git -ArgumentList 'config --global core.autocrlf false'
33 
34 Get-Date
35 Write-Host "Installing Meson and Mako"
36 pip3 install meson mako
37 if (!$?) {
38   Write-Host "Failed to install dependencies from pip"
39   Exit 1
40 }
41 
42 # we want more secure TLS 1.2 for most things, but it breaks SourceForge
43 # downloads so must be done after Chocolatey use
44 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
45 
46 # VS16.x is 2019
47 $msvc_2019_url = 'https://aka.ms/vs/16/release/vs_buildtools.exe'
48 
49 Get-Date
50 Write-Host "Downloading Visual Studio 2019 build tools"
51 Invoke-WebRequest -Uri $msvc_2019_url -OutFile C:\vs_buildtools.exe
52 
53 Get-Date
54 Write-Host "Installing Visual Studio 2019"
55 Start-Process -NoNewWindow -Wait C:\vs_buildtools.exe -ArgumentList '--wait --quiet --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Component.VC.ATL --add Microsoft.VisualStudio.Component.VC.ATLMFC --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Graphics.Tools --add Microsoft.VisualStudio.Component.Windows10SDK.18362 --includeRecommended'
56 if (!$?) {
57   Write-Host "Failed to install Visual Studio tools"
58   Exit 1
59 }
60 Remove-Item C:\vs_buildtools.exe -Force
61 
62 Get-Date
63 Write-Host "Cloning LLVM 10.x"
64 git clone -b release/10.x --depth=1 https://github.com/llvm/llvm-project llvm-project
65 if (!$?) {
66   Write-Host "Failed to clone LLVM repository"
67   Exit 1
68 }
69 
70 Get-Date
71 # slightly convoluted syntax but avoids the CWD being under the PS filesystem meta-path
72 $llvm_build = New-Item -ItemType Directory -Path ".\llvm-project" -Name "build"
73 Push-Location -Path $llvm_build.FullName
74 Write-Host "Compiling LLVM and Clang"
75 cmd.exe /C 'C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=amd64 && cmake ../llvm -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=MT -DCMAKE_INSTALL_PREFIX="C:\llvm-10" -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_OPTIMIZED_TABLEGEN=TRUE -DLLVM_ENABLE_ASSERTIONS=TRUE -DLLVM_INCLUDE_UTILS=OFF -DLLVM_INCLUDE_RUNTIMES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_GO_TESTS=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_BUILD_LLVM_C_DYLIB=OFF -DLLVM_ENABLE_DIA_SDK=OFF -DCLANG_BUILD_TOOLS=ON && ninja -j4 install'
76 $buildstatus = $?
77 Pop-Location
78 Remove-Item -Recurse -Path $llvm_build
79 if (!$buildstatus) {
80   Write-Host "Failed to compile LLVM"
81   Exit 1
82 }
83 
84 Get-Date
85 Write-Host "Complete"
86