-
Notifications
You must be signed in to change notification settings - Fork 185
/
bootstrap.ps1
337 lines (269 loc) · 9.03 KB
/
bootstrap.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# PowerShell script for performing TileDB bootstrapping process on
# Windows.
<#
.SYNOPSIS
This is a Powershell script to bootstrap a TileDB build on Windows.
.DESCRIPTION
This script will check dependencies, and run the CMake build generator
to generate a Visual Studio solution file that can be used to build or
develop TileDB.
.PARAMETER Prefix
Installs files in tree rooted at PREFIX (defaults to TileDB\dist).
.PARAMETER VcpkgBaseTriplet
Optionally specify the vcpkg target triplet, e.g. "x64-windows-release".
Defaults to automatically detecting it from the environment.
.PARAMETER Dependency
Semicolon separated list to binary dependencies.
.PARAMETER Linkage
Specify the linkage type to build TileDB with. Valid values are
"static" and "shared". Default is "shared".
.PARAMETER RemoveDeprecations
Build TileDB without any deprecated APIs.
.PARAMETER Architecture
Specify the architecture to configure for.
.PARAMETER CMakeGenerator
Optionally specify the CMake generator string, e.g. "Visual Studio 15
2017". Check 'cmake --help' for a list of supported generators.
.PARAMETER EnableDebug
Enable Debug build.
When using multi-config CMake generators this option is ignored and
you can just pass "--config Debug" when building with CMake.
.PARAMETER EnableAssert
Enable Assertions in compiled code (always on for debug build;
default off in release).
.PARAMETER EnableReleaseSymbols
Enable symbols with Release build.
When using multi-config CMake generators this option is ignored and
you can just pass "--config RelWithDebInfo" when building with CMake.
.PARAMETER EnableCoverage
Enable build with code coverage support.
.PARAMETER EnableVerbose
Enable verbose status messages.
.PARAMETER EnableAzure
Enables building with the Azure storage backend.
.PARAMETER EnableS3
Enables building with the S3 storage backend.
.PARAMETER EnableGcs
Enables building with the GCS storage backend.
.PARAMETER EnableSerialization
Enables building with serialization support.
.PARAMETER EnableStaticTileDB
Enables building TileDB as a static library.
Deprecated, use -Linkage static instead.
.PARAMETER EnableBuildDeps
Unused, kept for compatibility.
.PARAMETER EnableTools
Enables building TileDB CLI tools (experimental)
.PARAMETER EnableExperimentalFeatures
Enables building TileDB Experimental features
.PARAMETER EnableArrowTests
Enables the compilation of the arrow adapter unit tests
.PARAMETER EnableAwsS3Config
Enables AWS S3 configuration for unit tests
.PARAMETER DisableWebP
Disables building of WebP and simple linkage test
.Parameter DisableWerror
Disable use of warnings-as-errors (/WX) during build.
.Parameter DisableCppApi
Disable building the TileDB C++ API.
.Parameter DisableTests
Disable building the TileDB tests.
.Parameter DisableStats
Disables internal TileDB statistics.
.PARAMETER BuildProcesses
Number of parallel compile jobs.
.LINK
https://github.com/TileDB-Inc/TileDB
.EXAMPLE
..\bootstrap.ps1 -Prefix "\path\to\install" -Dependency "\path\to\dep1;\path\to\dep2"
#>
# Note -Debug and -Verbose are included in the PowerShell
# CommonParameters list, so we don't duplicate them here.
# TODO: that means they don't appear in the -? usage message.
[CmdletBinding()]
Param(
[string]$Prefix,
[string]$VcpkgBaseTriplet,
[string]$Dependency,
[string]$Linkage = "shared",
[switch]$RemoveDeprecations,
[string]$Architecture,
[string]$CMakeGenerator,
[switch]$EnableAssert,
[switch]$EnableDebug,
[switch]$EnableReleaseSymbols,
[switch]$EnableCoverage,
[switch]$EnableVerbose,
[switch]$EnableAzure,
[switch]$EnableS3,
[switch]$EnableGcs,
[switch]$EnableSerialization,
[switch]$EnableStaticTileDB,
[switch]$EnableTools,
[switch]$EnableExperimentalFeatures,
[switch]$EnableBuildDeps,
[switch]$EnableArrowTests,
[switch]$EnableAwsS3Config,
[switch]$DisableWebP,
[switch]$DisableWerror,
[switch]$DisableCppApi,
[switch]$DisableTests,
[switch]$DisableStats,
[Alias('J')]
[int]
$BuildProcesses = $env:NUMBER_OF_PROCESSORS
)
# Return the directory containing this script file.
function Get-ScriptDirectory {
Split-Path -Parent $PSCommandPath
}
# Absolute path of TileDB directories.
$SourceDirectory = Get-ScriptDirectory
$BinaryDirectory = (Get-Item -Path ".\" -Verbose).FullName
# Choose the default install prefix.
$DefaultPrefix = Join-Path $BinaryDirectory "dist"
# Choose the default dependency install prefix.
$DefaultDependency = $DefaultPrefix
# Set the vcpkg base triplet.
if ($VcpkgBaseTriplet.IsPresent) {
$VcpkgBaseTriplet = "-DTILEDB_VCPKG_BASE_TRIPLET=$VcpkgBaseTriplet"
}
# Set assertion mode
# No-op for a debug build.
$AssertionMode = "OFF"
if ($EnableAssert.IsPresent) {
$AssertionMode = "ON"
}
# Set TileDB build type
$BuildType = "Release"
if ($EnableDebug.IsPresent) {
$BuildType = "Debug"
}
if ($EnableReleaseSymbols.IsPresent) {
$BuildType = "RelWithDebInfo"
}
if ($EnableCoverage.IsPresent) {
$BuildType = "Coverage"
}
# Set TileDB verbosity
$Verbosity = "OFF"
if ($EnableVerbose.IsPresent) {
$Verbosity = "ON"
}
if ($RemoveDeprecations.IsPresent) {
$_RemoveDeprecations = "ON"
}
else {
$_RemoveDeprecations = "OFF"
}
# Set TileDB Azure flag
$UseAzure = "OFF"
if ($EnableAzure.IsPresent) {
$UseAzure = "ON"
}
# Set TileDB S3 flag
$UseS3 = "OFF"
if ($EnableS3.IsPresent) {
$UseS3 = "ON"
}
# Set TileDB GCS flag
$UseGcs = "OFF"
if ($EnableGcs.IsPresent) {
$UseGcs = "ON"
}
$UseSerialization = "OFF"
if ($EnableSerialization.IsPresent) {
$UseSerialization = "ON"
}
$Werror = "ON"
if ($DisableWerror.IsPresent) {
$Werror = "OFF"
}
$CppApi = "ON"
if ($DisableCppApi.IsPresent) {
$CppApi = "OFF"
}
$Tests = "ON"
if ($DisableTests.IsPresent) {
$Tests = "OFF"
}
$Stats = "ON"
if ($DisableStats.IsPresent) {
$Stats = "OFF"
}
$BuildWebP="ON"
if ($DisableWebP.IsPresent) {
$BuildWebP="OFF"
}
$BuildSharedLibs = "ON";
if ($Linkage -eq "static") {
$BuildSharedLibs = "OFF"
}
elseif ($Linkage -ne "shared") {
Write-Error "Invalid linkage type: $Linkage. Valid values are 'static' and 'shared'."
exit 1
}
if ($EnableStaticTileDB.IsPresent) {
Write-Warning "-EnableStaticTileDB is deprecated and will be removed in a future version. Use -Linkage static instead."
$BuildSharedLibs = "OFF"
if ($Linkage -eq "shared") {
Write-Error "Cannot specify -EnableStaticTileDB alongside -Linkage shared."
exit 1
}
}
$TileDBTools = "OFF";
if ($EnableTools.IsPresent) {
$TileDBTools = "ON"
}
$TileDBExperimentalFeatures = "OFF"
if ($EnableExperimentalFeatures.IsPresent) {
$TileDBExperimentalFeatures = "ON"
}
if ($EnableBuildDeps.IsPresent) {
Write-Warning "-EnableBuildDeps has no effect and will be removed in a future version. Vcpkg builds all dependencies by default, please consult the guide in doc/dev/BUILD.md or vcpkg's documentation to see how to provide your own dependencies."
}
$ArrowTests="OFF"
if ($EnableArrowTests.IsPresent) {
$ArrowTests="ON"
}
$ConfigureS3="OFF"
if ($EnableAwsS3Config.IsPresent) {
$ConfigureS3="ON"
}
# Set TileDB prefix
$InstallPrefix = $DefaultPrefix
if (![string]::IsNullOrEmpty($Prefix)) {
$InstallPrefix = $Prefix
}
# Set TileDB dependency directory string
$DependencyDir = $DefaultDependency
if (![string]::IsNullOrEmpty($Dependency)) {
$DependencyDir = $Dependency
}
$ArchFlag = ""
if ($PSBoundParameters.ContainsKey("Architecture")) {
$ArchFlag = "-A $Architecture"
}
# Set CMake generator type.
$GeneratorFlag = ""
if ($PSBoundParameters.ContainsKey("CMakeGenerator")) {
$GeneratorFlag = "-G""$CMakeGenerator"""
}
# Enforce out-of-source build
if ($SourceDirectory -eq $BinaryDirectory) {
Throw "Cannot build the project in the source directory! Out-of-source build is enforced!"
}
# Check cmake binary
if ($null -eq (Get-Command "cmake.exe" -ErrorAction SilentlyContinue)) {
Throw "Unable to find cmake.exe in your PATH."
}
if ($CMakeGenerator -eq $null) {
Throw "Could not identify a generator for CMake. Do you have Visual Studio installed?"
}
# Run CMake.
# We use Invoke-Expression so we can echo the command to the user.
$CommandString = "cmake $ArchFlag -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_INSTALL_PREFIX=""$InstallPrefix"" $VcpkgBaseTriplet -DCMAKE_PREFIX_PATH=""$DependencyDir"" -DMSVC_MP_FLAG=""/MP$BuildProcesses"" -DTILEDB_ASSERTIONS=$AssertionMode -DTILEDB_VERBOSE=$Verbosity -DTILEDB_AZURE=$UseAzure -DTILEDB_S3=$UseS3 -DTILEDB_GCS=$UseGcs -DTILEDB_SERIALIZATION=$UseSerialization -DTILEDB_WERROR=$Werror -DTILEDB_CPP_API=$CppApi -DTILEDB_TESTS=$Tests -DTILEDB_STATS=$Stats -DBUILD_SHARED_LIBS=$BuildSharedLibs -DTILEDB_REMOVE_DEPRECATIONS=$_RemoveDeprecations -DTILEDB_TOOLS=$TileDBTools -DTILEDB_EXPERIMENTAL_FEATURES=$TileDBExperimentalFeatures -DTILEDB_WEBP=$BuildWebP -DTILEDB_CRC32=$BuildCrc32 -DTILEDB_ARROW_TESTS=$ArrowTests -DTILEDB_TESTS_AWS_S3_CONFIG=$ConfigureS3 $GeneratorFlag ""$SourceDirectory"""
Write-Host $CommandString
Write-Host
Invoke-Expression "$CommandString"
Write-Host "Bootstrap success. Run 'cmake --build . --config $BuildType' to build and 'cmake --build . --target check --config $BuildType' to test."