-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.run.ps1
46 lines (38 loc) · 1.09 KB
/
.run.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
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
. .\tools\Exec.ps1
. .\tools\Invoke-BatchFile.ps1
function loadBuildEnvironment {
$vswhere = Resolve-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vsDir = & $vswhere -latest `
-requires Microsoft.VisualStudio.Workload.NativeDesktop `
-property installationPath
if (-not $vsDir) {
throw 'MSVC is not installed.'
}
Invoke-BatchFile "$vsDir\VC\Auxiliary\Build\vcvars64.bat"
}
if ($args.Length -lt 1) {
throw 'No task is specified.'
}
Set-Location $PSScriptRoot
switch -regex ($args[0]) {
'^c(onfigure)?$' {
loadBuildEnvironment
Exec { cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE='vcpkg/scripts/buildsystems/vcpkg.cmake' }
break
}
'^b(uild)?$' {
loadBuildEnvironment
Exec { cmake --build build }
break
}
'^t(est)?$' {
loadBuildEnvironment
Exec { ctest -V --test-dir build }
break
}
default {
throw "Unknown task: '$($args[0])'"
}
}