Repository navigation
Expand file tree
/
Copy pathsetup.ps1
More file actions
62 lines (56 loc) · 2.31 KB
/
Copy pathsetup.ps1
File metadata and controls
62 lines (56 loc) · 2.31 KB
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
# Build Clang + cpp-verify with vendored Z3 on Windows (no separate Z3 install).
# Requires: CMake, Ninja (or use Visual Studio generator), MSVC Build Tools, Git, Python 3.
# With Ninja, run from an x64 Developer PowerShell or Native Tools prompt for VS.
param(
[string]$BuildDir = "",
[string]$Generator = "Ninja",
[string]$BuildType = "Release",
[string]$LLVMTargets = "Native"
)
$ErrorActionPreference = "Stop"
$Root = $PSScriptRoot
if (-not $BuildDir) { $BuildDir = Join-Path $Root "build" }
function Require-Command($name) {
if (-not (Get-Command $name -ErrorAction SilentlyContinue)) {
Write-Error "Missing '$name' on PATH. Install CMake/Ninja/VS Build Tools and retry."
}
}
Require-Command cmake
if ($Generator -eq "Ninja") {
Require-Command ninja
if (-not (Get-Command cl -ErrorAction SilentlyContinue)) {
Write-Error "MSVC's cl is not on PATH. Run from an x64 Developer PowerShell or Native Tools prompt for VS, or pass -Generator 'Visual Studio 17 2022'."
}
}
Require-Command git
Write-Host "==> Configuring LLVM + Clang + CppVerify (vendored Z3)"
$cmakeArgs = @(
"-S", (Join-Path $Root "llvm"),
"-B", $BuildDir,
"-G", $Generator,
"-DLLVM_ENABLE_PROJECTS=clang;clang-tools-extra",
"-DLLVM_TARGETS_TO_BUILD=$LLVMTargets",
"-DCPPVERIFY_VENDOR_Z3=ON",
"-DCPPVERIFY_PREFER_SYSTEM_Z3=OFF"
)
if ($Generator -eq "Ninja") {
$cmakeArgs += "-DCMAKE_BUILD_TYPE=$BuildType"
}
# Visual Studio generator: multi-config; build with --config Release below.
& cmake @cmakeArgs
if ($LASTEXITCODE -ne 0) { Write-Error "Configuration failed." }
Write-Host "==> Building clang, cpp-verify, clangd, and clang-format"
if ($Generator -match "Visual Studio") {
& cmake --build $BuildDir --config $BuildType --target clang cpp-verify clangd clang-format --parallel
$BinDir = Join-Path $BuildDir "$BuildType\bin"
} else {
& cmake --build $BuildDir --target clang cpp-verify clangd clang-format --parallel
$BinDir = Join-Path $BuildDir "bin"
}
if ($LASTEXITCODE -ne 0) { Write-Error "Build failed." }
Write-Host ""
Write-Host "Done."
Write-Host " Verifier: $(Join-Path $BinDir 'cpp-verify.exe')"
Write-Host " Compiler: $(Join-Path $BinDir 'clang++.exe')"
Write-Host " Editors: $(Join-Path $BinDir 'clangd.exe'), $(Join-Path $BinDir 'clang-format.exe')"
Write-Host ""