-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-win.ps1
More file actions
59 lines (45 loc) · 1.65 KB
/
build-win.ps1
File metadata and controls
59 lines (45 loc) · 1.65 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
Function Info($msg) {
Write-Host -ForegroundColor DarkGreen "`nINFO: $msg`n"
}
Function Error($msg) {
Write-Host `n`n
Write-Error $msg
exit 1
}
Function CheckReturnCodeOfPreviousCommand($msg) {
if(-Not $?) {
Error "${msg}. Error code: $LastExitCode"
}
}
Function BuildAndTest($buildType, $arch) {
Info "Build and test $buildType-$arch"
$thisBuildDir = "$buildDir/win-$buildType-$arch"
Info "Cmake generate cache"
cmake -S $root `
-B $thisBuildDir `
-G Ninja `
-D CMAKE_BUILD_TYPE=$buildType
CheckReturnCodeOfPreviousCommand "cmake cache failed"
Info "Cmake build"
cmake --build $thisBuildDir
CheckReturnCodeOfPreviousCommand "cmake build failed"
Info "Run tests"
& "$thisBuildDir/dlms_parser_test.exe"
CheckReturnCodeOfPreviousCommand "tests failed"
}
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
$root = Resolve-Path $PSScriptRoot
$buildDir = "$root/build"
Info "Find Visual Studio installation path"
$vswhereCommand = Get-Command -Name "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installationPath = & $vswhereCommand -prerelease -latest -property installationPath
Info "Open Visual Studio Developer PowerShell amd64"
& "$installationPath\Common7\Tools\Launch-VsDevShell.ps1" -SkipAutomaticLocation -Arch amd64
BuildAndTest -buildType Debug -arch amd64
BuildAndTest -buildType Release -arch amd64
Info "Open Visual Studio Developer PowerShell x86"
& "$installationPath\Common7\Tools\Launch-VsDevShell.ps1" -SkipAutomaticLocation -Arch x86
BuildAndTest -buildType Debug -arch x86
BuildAndTest -buildType Release -arch x86