Skip to content

Commit

Permalink
[Backport release-2.18] Use Ninja in Windows CI and explicitly set th…
Browse files Browse the repository at this point in the history
…e VS toolset version. (#4759) (#4765)

Backport f31fa3b from #4759.

---
TYPE: BUILD
DESC: Fix linker errors when building with MSVC
  • Loading branch information
teo-tsirpanis authored and Shelnutt2 committed Apr 21, 2024
1 parent 4734420 commit 13c3eae
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,22 @@ jobs:
TILEDB_ARROW_TESTS: ${{ matrix.TILEDB_ARROW_TESTS }}
TILEDB_WEBP: ${{ matrix.TILEDB_WEBP }}
TILEDB_CMAKE_BUILD_TYPE: 'Release'
# On windows-2019 we are using the Visual Studio generator, which is multi-config and places the build artifacts in a subdirectory
CONFIG_PATH_FIXUP: ${{ matrix.os == 'windows-2019' && 'Release' || '' }}
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
steps:
# By default Visual Studio chooses the earliest installed toolset version
# for the main build and vcpkg chooses the latest. Force it to use the
# latest (14.39 currently).
- name: Setup MSVC toolset (VS 2022)
uses: TheMrMilchmann/setup-msvc-dev@v3
if: matrix.os == 'windows-2022'
with:
arch: x64
toolset: 14.39
- name: Install Ninja (VS 2022)
uses: seanmiddleditch/gha-setup-ninja@v4
if: matrix.os == 'windows-2022'
- name: 'tiledb env prep'
run: |
$env:BUILD_BUILDDIRECTORY = $env:GITHUB_WORKSPACE.replace("TileDB\TileDB","tdbbd") # 't'ile'db' 'b'uild 'd'ir
Expand Down Expand Up @@ -141,7 +155,7 @@ jobs:
# allow double-checking path
cmd /c "echo $PATH"
$bootstrapOptions = $env:TILEDB_BASE_BOOTSTRAP_OPTIONS
$bootstrapOptions = $env:TILEDB_BASE_BOOTSTRAP_OPTIONS + " -CMakeGenerator ${{ matrix.os == 'windows-2022' && 'Ninja' || '`"Visual Studio 16 2019`"' }}"
if ($env:TILEDB_S3 -eq "ON") {
$bootstrapOptions = "-EnableS3 " + $bootstrapOptions
}
Expand Down Expand Up @@ -245,9 +259,7 @@ jobs:
}
# CMake exits with non-0 status if there are any warnings during the build, so
cmake --build $env:BUILD_BUILDDIRECTORY\tiledb -j $env:NUMBER_OF_PROCESSORS --target tiledb_unit --config $CMakeBuildType -- /verbosity:minimal
cmake --build $env:BUILD_BUILDDIRECTORY\tiledb -j $env:NUMBER_OF_PROCESSORS --target tiledb_regression --config $CMakeBuildType -- /verbosity:minimal
cmake --build $env:BUILD_BUILDDIRECTORY\tiledb -j $env:NUMBER_OF_PROCESSORS --target all_link_complete --config $CMakeBuildType -- /verbosity:minimal
cmake --build $env:BUILD_BUILDDIRECTORY\tiledb -j --target tiledb_unit tiledb_regression all_link_complete --config $CMakeBuildType
if ($env:TILEDB_AZURE -eq "ON") {
if($env.TILEDB_USE_CUSTOM_NODE_JS) {
Expand Down Expand Up @@ -278,15 +290,15 @@ jobs:
# Actually run tests
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\test\$CMakeBuildType\tiledb_unit.exe -d=yes"
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\test\$env:CONFIG_PATH_FIXUP\tiledb_unit.exe -d=yes"
Write-Host "cmds: '$cmds'"
Invoke-Expression $cmds
if ($LastExitCode -ne 0) {
Write-Host "Tests failed. tiledb_unit exit status: " $LastExitCocde
$host.SetShouldExit($LastExitCode)
}
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\test\ci\$CMakeBuildType\test_assert.exe -d=yes"
$cmds = "$env:BUILD_BUILDDIRECTORY\tiledb\test\ci\$env:CONFIG_PATH_FIXUP\test_assert.exe -d=yes"
Invoke-Expression $cmds
if ($LastExitCode -ne 0) {
Write-Host "Tests failed. test_assert exit status: " $LastExitCocde
Expand Down Expand Up @@ -316,7 +328,7 @@ jobs:
$TestAppDir = (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\c_api")
$TestAppDataDir = (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\c_api\test_app_data")
Get-ChildItem (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\c_api\$CMakeBuildType") -Filter *.exe |
Get-ChildItem (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\c_api\$env:CONFIG_PATH_FIXUP\") -Filter *.exe |
Foreach-Object {
try {
Set-Location -path $TestAppDir
Expand Down Expand Up @@ -349,7 +361,7 @@ jobs:
$TestAppDir = (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\cpp_api")
$TestAppDataDir = (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\cpp_api\test_app_data")
Get-ChildItem (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\cpp_api\$CMakeBuildType") -Filter *.exe |
Get-ChildItem (Join-Path $env:BUILD_BUILDDIRECTORY "tiledb\examples\cpp_api\$env:CONFIG_PATH_FIXUP\") -Filter *.exe |
Foreach-Object {
try {
Set-Location -path $TestAppDir
Expand Down Expand Up @@ -388,17 +400,17 @@ jobs:
cd build
# Build zip artifact
cmake -A X64 -DCMAKE_PREFIX_PATH="$env:BUILD_BUILDDIRECTORY\dist;$env:BUILD_BUILD_DIRECTORY\vcpkg_installed\x64-windows-mod" ..
cmake ${{ matrix.os != 'windows-2019' && '-G Ninja' || '' }} -DCMAKE_BUILD_TYPE="$CMakeBuildType" -DCMAKE_PREFIX_PATH="$env:BUILD_BUILDDIRECTORY\dist;$env:BUILD_BUILDDIRECTORY\vcpkg_installed\x64-windows" ..
cmake --build . --config $CMakeBuildType -v
#.\$CMakeBuildType\ExampleExe.exe
$cmd = ".\$CMakeBuildType\ExampleExe.exe"
#.\$env:CONFIG_PATH_FIXUP\ExampleExe.exe
$cmd = ".\$env:CONFIG_PATH_FIXUP\ExampleExe.exe"
Write-Host "cmd: '$cmd'"
Invoke-Expression $cmd
#.\$CMakeBuildType\ExampleExe_static.exe
$cmd = ".\$CMakeBuildType\ExampleExe_static.exe"
#.\$env:CONFIG_PATH_FIXUP\ExampleExe_static.exe
$cmd = ".\$env:CONFIG_PATH_FIXUP\ExampleExe_static.exe"
Write-Host "cmd: '$cmd'"
Invoke-Expression $cmd
Expand Down
11 changes: 10 additions & 1 deletion bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Installs files in tree rooted at PREFIX (defaults to TileDB\dist).
.PARAMETER Dependency
Semicolon separated list to binary dependencies.
.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.
Expand Down Expand Up @@ -119,6 +122,7 @@ https://github.com/TileDB-Inc/TileDB
Param(
[string]$Prefix,
[string]$Dependency,
[string]$Architecture,
[string]$CMakeGenerator,
[switch]$EnableAssert,
[switch]$EnableDebug,
Expand Down Expand Up @@ -305,6 +309,11 @@ if (![string]::IsNullOrEmpty($Dependency)) {
$DependencyDir = $Dependency
}

$ArchFlag = ""
if ($PSBoundParameters.ContainsKey("Architecture")) {
$ArchFlag = "-A $Architecture"
}

# Set CMake generator type.
$GeneratorFlag = ""
if ($PSBoundParameters.ContainsKey("CMakeGenerator")) {
Expand All @@ -326,7 +335,7 @@ if ($CMakeGenerator -eq $null) {

# Run CMake.
# We use Invoke-Expression so we can echo the command to the user.
$CommandString = "cmake -A X64 -DTILEDB_VCPKG=$UseVcpkg -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_INSTALL_PREFIX=""$InstallPrefix"" -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 -DTILEDB_STATIC=$TileDBStatic -DTILEDB_FORCE_ALL_DEPS=$TileDBBuildDeps -DTILEDB_REMOVE_DEPRECATIONS=$RemoveDeprecations -DTILEDB_TOOLS=$TileDBTools -DTILEDB_EXPERIMENTAL_FEATURES=$TileDBExperimentalFeatures -DTILEDB_WEBP=$BuildWebP -DTILEDB_CRC32=$BuildCrc32 -DTILEDB_ARROW_TESTS=$ArrowTests -DTILEDB_TESTS_ENABLE_REST=$RestTests -DTILEDB_TESTS_AWS_S3_CONFIG=$ConfigureS3 $GeneratorFlag ""$SourceDirectory"""
$CommandString = "cmake $ArchFlag -DTILEDB_VCPKG=$UseVcpkg -DCMAKE_BUILD_TYPE=$BuildType -DCMAKE_INSTALL_PREFIX=""$InstallPrefix"" -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 -DTILEDB_STATIC=$TileDBStatic -DTILEDB_FORCE_ALL_DEPS=$TileDBBuildDeps -DTILEDB_REMOVE_DEPRECATIONS=$RemoveDeprecations -DTILEDB_TOOLS=$TileDBTools -DTILEDB_EXPERIMENTAL_FEATURES=$TileDBExperimentalFeatures -DTILEDB_WEBP=$BuildWebP -DTILEDB_CRC32=$BuildCrc32 -DTILEDB_ARROW_TESTS=$ArrowTests -DTILEDB_TESTS_ENABLE_REST=$RestTests -DTILEDB_TESTS_AWS_S3_CONFIG=$ConfigureS3 $GeneratorFlag ""$SourceDirectory"""
Write-Host $CommandString
Write-Host
Invoke-Expression "$CommandString"
Expand Down

0 comments on commit 13c3eae

Please sign in to comment.