summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test/evergreen/build_windows.ps1
blob: 0c6111ad714ad18441c993e2972df78b05a26c69 (plain)
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
param (
    [bool]$configure = $false,
    [bool]$build = $false,
    [string]$vcvars_bat = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat"
)

function Die-On-Failure {
    param (
        $Result
    )

    if ($Result -ne 0) {
        throw("Task failed: " + $Result)
    }
}

# This script should fail when a cmdlet fails.
$ErrorActionPreference = "Stop"

# Source the vcvars to ensure we have access to the Visual Studio toolchain
cmd /c "`"$vcvars_bat`"&set" |
foreach {
    if ($_ -match "=") {
        $v = $_.split("="); set-item -force -path "ENV:\$($v[0])"  -value "$($v[1])"
    }
}

# Ensure the PROCESSOR_ARCHITECTURE environment variable is set. This is sometimes not set
# when entering from a cygwin environment.
$env:PROCESSOR_ARCHITECTURE = "AMD64"

# Ensure the swig binary location is in our PATH.
$env:Path += ";C:\swigwin-3.0.2"

if (-not (Test-Path cmake_build)) {
    mkdir cmake_build
}

cd cmake_build

# Configure build with CMake.
if ($configure -eq $true) {
    # Note that ${args} are all the command line options that are not automatically parsed by the param function.
    C:\cmake\bin\cmake --no-warn-unused-cli -DSWIG_DIR='C:\swigwin-3.0.2' -DSWIG_EXECUTABLE='C:\swigwin-3.0.2\swig.exe' -DCMAKE_BUILD_TYPE='None' -DENABLE_PYTHON=1 -DENABLE_STRICT=1 -DCMAKE_TOOLCHAIN_FILE='..\cmake\toolchains\cl.cmake' ${args} -G "Ninja" ..\.
    Die-On-Failure($LastExitCode)
}

# Execute Ninja build.
if ($build -eq $true) {
    ninja
    Die-On-Failure($LastExitCode)
}