forked from vector-of-bool/pmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.ps1
97 lines (84 loc) · 2.11 KB
/
ci.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
[CmdletBinding(PositionalBinding=$false)]
param(
# Run the Docker tests
[Parameter()]
[switch]
$RunDockerTests,
# Forcibly set CC and CXX to MSVC cl.exe
[Parameter()]
[switch]
$ForceMSVC,
# Ignore the `ci/` tests directory
[Parameter()]
[switch]
$NoCITestDir,
# Do not delete the build directory before running
[Parameter()]
[switch]
$NoClean,
# Run tests matching the given regular expression
[Parameter()]
[regex]
$TestRegex
)
$ErrorActionPreference = "Stop"
if ($PSVersionTable.OS -and $PSVersionTable.OS.StartsWith("Darwin")) {
# We're on macOS, and we need a newer GCC for the FS TS
& brew install "gcc@8"
if ($LASTEXITCODE) {
throw "Brew installation failed!"
}
$cc = Get-ChildItem '/usr/local/Cellar/gcc@8/*/bin/gcc-8'
$cxx = Get-ChildItem '/usr/local/Cellar/gcc@8/*/bin/g++-8'
$env:CC = $cc.FullName
$env:CXX = $cxx.FullName
}
if ($ForceMSVC) {
$env:CC = "cl"
$env:CXX = "cl"
}
$cmake = (Get-Command -Name cmake).Source
$ninja = (Get-Command -Name ninja).Source
if (! $cmake) {
throw "No CMake installed?"
}
if (! $ninja) {
throw "No Ninja found?"
}
$source_dir = $PSScriptRoot
$bin_dir = Join-Path $source_dir "ci-build"
if (-not $NoClean -and (Test-Path $bin_dir)) {
Remove-Item -Recurse $bin_dir -Force
}
$run_docker_tests = "FALSE"
if ($RunDockerTests) {
$run_docker_tests = "TRUE"
}
$no_ci_test_dir = "FALSE"
if ($NoCITestDir) {
$no_ci_test_dir = "TRUE"
}
& $cmake -GNinja `
"-DRUN_DOCKER_TESTS:BOOL=$run_docker_tests" `
"-DNO_CI_TEST_DIR:BOOL=$no_ci_test_dir" `
"-H$source_dir" "-B$bin_dir"
if ($LASTEXITCODE) {
throw "CMake configure failed [$LASTEXITCODE]"
}
& $cmake --build $bin_dir
if ($LASTEXITCODE) {
throw "CMake build failed [$LASTEXITCODE]"
}
$cm_dir = Split-Path $cmake -Parent
$ctest = Join-Path $cm_dir "ctest"
$args = @()
if ($VerbosePreference) {
$args += "-V"
}
if ($TestRegex) {
$args += "-R", "$TestRegex"
}
& $cmake -E chdir $bin_dir $ctest -j6 --output-on-failure @args
if ($LASTEXITCODE) {
throw "CTest failed [$LASTEXITCODE]"
}