forked from microsoft/cpp_client_telemetry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-win.ps1
140 lines (124 loc) · 4.14 KB
/
build-win.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
param (
[string[]]$configs = @("Debug", "Release"),
[string[]]$archs = @("x64", "Win32", "ARM", "ARM64"),
[string[]]$binTypes = @("dll", "lib"),
[string]$enableWin10 = "true",
[string]$enableMini = "true",
[string]$enableTests = "true",
[string]$customProps = "",
[string]$vsDevCmdBat = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"
)
$solution = "Solutions\MSTelemetrySDK.sln"
$cpuCount = $env:NUMBER_OF_PROCESSORS
$actualCustomProps = ""
if ($customProps -ne "") {
$actualCustomProps = "/p:ForceImportBeforeCppTargets=$customProps"
}
$coreTargets = @("zlib")
$testTargets = @("Tests\gmock", "Tests\gtest", "Tests\UnitTests", "Tests\FuncTests")
$win10DllTargets = @("sqlite-uwp", "win10-cs", "win10-dll")
$win32DllTargets = @("sqlite", "win32-dll")
$win32LibTargets = @("sqlite", "win32-lib")
$win32MiniDllTargets = @("win32-mini-dll")
$win32MiniLibTargets = @("win32-mini-lib")
# Update version headers
& "tools\gen-version.cmd"
# Import variables from developer command prompt
if (-not $env:DevEnvDir) {
echo "Running VsDevCmd.bat..."
& cmd /s /c """$vsDevCmdBat"" -no_logo && set" | foreach-object {
echo "Reading $_"
$name, $value = $_ -split '=', 2
if ($name -and $value) {
echo " Setting $name = $value"
set-content env:\"$name" $value
}
}
echo "...Done!"
}
foreach ($arch in $archs) {
# Normalize architecture
$actualArch = $arch
if ($arch -eq "amd64") {
$actualArch = "x64"
} elseif ($arch -ceq "win32") {
$actualArch = "Win32"
} elseif ($arch -ceq "arm") {
$actualArch = "ARM"
} elseif ($arch -ceq "arm64") {
$actualArch = "ARM64"
}
foreach ($binType in $binTypes) {
foreach ($config in $configs) {
$actualConfig = $config
if ($binType -eq "lib") {
$actualConfig += ".vc14x.MT-sqlite"
}
echo "Building $actualArch|$actualConfig|$binType..."
$targets = $coreTargets
# Bail out if dependencies aren't met:
# 1) ARM requires win10
# 2) Static libs are only supported on x64/x86
if ($actualArch -eq "ARM" -and $enableWin10 -ne "true") {
echo " ARM requires ""-enableWin10 true"""
echo "...Skipped!"
echo ""
continue
}
if ($binType -eq "lib" -and ($actualArch -eq "ARM")) {
if ($binType -eq "lib") {
echo " static .libs are not supported for $actualArch architecture"
echo "...Skipped!"
echo ""
continue
}
}
# Ignore irrelevant parameters
# 1) Tests are only supported for DLL build on x64/x86
if ($enableTests -eq "true") {
if ($actualArch -eq "x64" -or $actualArch -eq "Win32") {
if ($binType -eq "dll") {
$targets += $testTargets
} else {
echo " NOTE: Automation tests are not supported for $binType builds"
}
} else {
echo " NOTE: Automation tests are not supported for $actualArch architecture"
}
}
if ($binType -eq "lib") {
$targets += $win32LibTargets
if ($enableMini -eq "true") {
$targets += $win32MiniLibTargets
}
} elseif ($binType -eq "dll") {
# ARM doesn't support win32 targets
if ($actualArch -ne "ARM") {
$targets += $win32DllTargets
if ($enableMini -eq "true") {
$targets += $win32MiniDllTargets
}
}
# ARM64 doesn't support win10 targets
if ($actualArch -ne "ARM64" -and $enableWin10 -eq "true") {
$targets += $win10DllTargets
}
}
$targetStr = $targets -join ","
echo " Targets: $targetStr"
echo " Architecture: $actualArch"
echo " Configuration: $actualConfig"
echo " CPU Count: $cpuCount"
if ($customProps -ne "") {
echo " Custom .props: $customProps"
}
# Build!
& cmd /c "msbuild $solution /target:$targetStr /p:BuildProjectReferences=true /maxcpucount:$cpuCount /p:Configuration=$actualConfig /p:Platform=$actualArch $actualCustomProps"
echo "...Done!"
echo ""
if ($lastexitcode -ne 0) {
exit 1
}
}
}
}