This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
/
prerequisites.ps1
84 lines (77 loc) · 3.63 KB
/
prerequisites.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#Requires -Version 6.0
Write-Host "##[info] Runtime/prerequisites.ps1"
if ($Env:ENABLE_QIRRUNTIME -ne "false") {
if (($IsWindows) -or ((Test-Path Env:/AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Win")))) {
$ChocoRan = $false
if (!(Get-Command clang -ErrorAction SilentlyContinue) -or `
!(Get-Command clang-format -ErrorAction SilentlyContinue) -or `
(Test-Path Env:/AGENT_OS)) {
choco install llvm --version=14.0.6 --allow-downgrade
$ChocoRan = $true
Write-Host "##vso[task.setvariable variable=PATH;]$($env:SystemDrive)\Program Files\LLVM\bin;$Env:PATH"
}
if (!(Get-Command ninja -ErrorAction SilentlyContinue)) {
choco install ninja
$ChocoRan = $true
}
if (!(Get-Command cmake -ErrorAction SilentlyContinue)) {
choco install cmake
$ChocoRan = $true
}
if ($ChocoRan) {
refreshenv
}
} elseif ($IsMacOS) {
# temporary workaround for Bintray sunset
# remove this after Homebrew is updated to 3.1.1 on MacOS image, see:
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md
brew update
brew install ninja
brew install llvm@14
if (!(Get-Command clang-format -ErrorAction SilentlyContinue)) {
brew install clang-format@14 # Still needed after the LLVM is installed.
}
} else {
$needClang = !(Get-Command clang-14 -ErrorAction SilentlyContinue)
if (Get-Command sudo -ErrorAction SilentlyContinue) {
if ($needClang) {
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo add-apt-repository "deb https://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"
}
sudo apt update
sudo apt-get install -y ninja-build
sudo apt-get install -y clang-14 clang-tidy-14 clang-format-14
} else {
if ($needClang) {
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add -
add-apt-repository "deb https://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"
}
apt update
apt-get install -y ninja-build
apt-get install -y clang-14 clang-tidy-14 clang-format-14
}
}
if (-not (Get-Command rustup -ErrorAction SilentlyContinue)) {
if ($IsWindows -or $PSVersionTable.PSEdition -eq "Desktop") {
Invoke-WebRequest "https://win.rustup.rs" -OutFile rustup-init.exe
Unblock-File rustup-init.exe;
./rustup-init.exe -y
} elseif ($IsLinux -or $IsMacOS) {
Invoke-WebRequest "https://sh.rustup.rs" | Select-Object -ExpandProperty Content | sh -s -- -y;
} else {
Write-Error "Host operating system not recognized as being Windows, Linux, or macOS; please download Rust manually from https://rustup.rs/."
}
if (-not (Get-Command rustup -ErrorAction SilentlyContinue)) {
Write-Error "After running rustup-init, rustup was not available. Please check logs above to see if something went wrong.";
exit -1;
}
}
# Now that rustup is available, go on and make sure that nightly support for
# rustfmt and clippy is available.
rustup install nightly
rustup toolchain install nightly
rustup component add rustfmt clippy llvm-tools-preview
rustup component add rustfmt clippy llvm-tools-preview --toolchain nightly
}