From 32302a4c19acab623d4c75ea5bacc11293695ecc Mon Sep 17 00:00:00 2001 From: tdcosta100 Date: Tue, 24 Jun 2025 12:46:08 -0300 Subject: [PATCH] Windows build fixes and Windows inclusion in core releases (#3581) --- .../scripts/windows-ci_configure_wrapper.ps1 | 16 -- .github/workflows/core-release.yml | 26 +++ .github/workflows/node-ci.yml | 27 ++- .github/workflows/windows-ci.yml | 53 ++--- CMakePresets.json | 80 ++++++++ platform/node/CMakeLists.txt | 2 +- platform/windows/Get-VendorPackages.ps1 | 9 +- .../angle/004-fix-opengl32.dll-load.patch | 13 -- .../vcpkg-custom-ports/angle/portfile.cmake | 194 ------------------ platform/windows/windows.cmake | 58 ++++-- vendor/benchmark.cmake | 5 + 11 files changed, 202 insertions(+), 281 deletions(-) delete mode 100644 .github/scripts/windows-ci_configure_wrapper.ps1 delete mode 100644 platform/windows/vendor/vcpkg-custom-ports/angle/004-fix-opengl32.dll-load.patch delete mode 100644 platform/windows/vendor/vcpkg-custom-ports/angle/portfile.cmake diff --git a/.github/scripts/windows-ci_configure_wrapper.ps1 b/.github/scripts/windows-ci_configure_wrapper.ps1 deleted file mode 100644 index 27e48588c..000000000 --- a/.github/scripts/windows-ci_configure_wrapper.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -$compile_flags = @( - '-DCMAKE_POLICY_DEFAULT_CMP0141=NEW', - '-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded', - '-DCMAKE_BUILD_TYPE=RelWithDebInfo' -) - -switch ($env:RENDERER) -{ - 'opengl' { $compile_flags += '-DMLN_WITH_OPENGL=ON'; break; } - 'egl' { $compile_flags += '-DMLN_WITH_EGL=ON' ; break; } - 'vulkan' { $compile_flags += @('-DMLN_WITH_VULKAN=ON', '-DMLN_WITH_OPENGL=OFF'); break; } -} - -Write-Host 'Compile flags: ' $compile_flags - -& cmake -B build -G Ninja $($compile_flags) diff --git a/.github/workflows/core-release.yml b/.github/workflows/core-release.yml index 169c74d1b..b5c60e265 100644 --- a/.github/workflows/core-release.yml +++ b/.github/workflows/core-release.yml @@ -88,3 +88,29 @@ jobs: run: gh release upload core-${{ github.sha }} libmaplibre-native-core-linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}.a env: GH_TOKEN: ${{ github.token }} + + build-windows: + needs: [create-release] + runs-on: windows-2022 + strategy: + matrix: + renderer: [opengl, egl, vulkan] + steps: + - run: | + git config --system core.longpaths true + + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build mbgl-core for Windows + run: | + cmake --preset windows-${{ matrix.renderer }}-core -DCMAKE_CXX_COMPILER_LAUNCHER="" + cmake --build --preset windows-${{ matrix.renderer }}-core + + - name: Rename artifact + run: Copy-Item build-windows-${{ matrix.renderer }}/mbgl-core.lib maplibre-native-core-windows-x64-${{ matrix.renderer }}.lib + + - name: Upload Windows artifact + run: gh release upload core-${{ github.sha }} maplibre-native-core-windows-x64-${{ matrix.renderer }}.lib + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 0f50fafc8..4337867b5 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -209,27 +209,26 @@ jobs: -DCMAKE_C_COMPILER=gcc-12 \ -DMLN_WITH_NODE=ON - - name: "Create directory '${{ github.workspace }}/platform/windows/vendor/vcpkg/bincache' (Windows)" + - name: Get vcpkg commit id if: runner.os == 'Windows' - run: mkdir -p ${{ github.workspace }}/platform/windows/vendor/vcpkg/bincache - shell: bash + shell: pwsh + run: | + $vcpkg_commit_id = ($(git submodule status .\platform\windows\vendor\vcpkg).Trim() -split ' ')[0] + Add-Content -Path $env:GITHUB_ENV -Value "VCPKG_COMMIT_ID=${vcpkg_commit_id}" - - name: Restore vcpkg cache (Windows) + - name: Restore vcpkg binary cache if: runner.os == 'Windows' - uses: actions/cache@v4 + uses: actions/cache/restore@v4 with: - path: | - ${{ github.workspace }}/platform/windows/vendor/vcpkg - !${{ github.workspace }}/platform/windows/vendor/vcpkg/buildtrees - !${{ github.workspace }}/platform/windows/vendor/vcpkg/packages - !${{ github.workspace }}/platform/windows/vendor/vcpkg/downloads - !${{ github.workspace }}/platform/windows/vendor/vcpkg/installed - key: | - ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ hashFiles( '.git/modules/platform/windows/vendor/vcpkg/HEAD' ) }}-${{ hashFiles( 'platform/windows/Get-VendorPackages.ps1' ) }} + path: ${{ github.workspace }}\platform\windows\vendor\vcpkg\archives + key: vcpkg-${{ env.VCPKG_COMMIT_ID }} - name: Configure maplibre-native (Windows) if: runner.os == 'Windows' shell: pwsh + env: + VCPKG_INSTALL_OPTIONS: "--debug" + VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}\\platform\\windows\\vendor\\vcpkg\\archives,readwrite" run: | cmake . -B build ` -G Ninja ` @@ -279,7 +278,7 @@ jobs: LIBGL_ALWAYS_SOFTWARE: true GALLIUM_DRIVER: llvmpipe run: | - (Invoke-WebRequest https://api.github.com/repos/pal1000/mesa-dist-win/releases -Headers @{ Authorization = ('Bearer {0}' -f '${{ secrets.GITHUB_TOKEN }}') } | ConvertFrom-Json)[0].assets | Where-Object name -match 'mesa3d-.+-(release|devel)-msvc\.7z' | foreach { Invoke-WebRequest $_.browser_download_url -OutFile mesa3d.7z } + (Invoke-WebRequest https://api.github.com/repos/pal1000/mesa-dist-win/releases -Headers @{ Authorization = ('Bearer {0}' -f '${{ secrets.GITHUB_TOKEN }}') } | ConvertFrom-Json)[0].assets | Where-Object name -match 'mesa3d-.+-release-msvc\.7z' | foreach { Invoke-WebRequest $_.browser_download_url -OutFile mesa3d.7z } & 'C:\Program Files\7-Zip\7z.exe' e -olib\node-v131 .\mesa3d.7z x64\opengl32.dll x64\libgallium_wgl.dll x64\libGLESv2.dll npm test diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 3885dda0a..bb9282b6e 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -62,11 +62,13 @@ jobs: - uses: actions/checkout@v4 with: - submodules: recursive + sparse-checkout: | + platform/windows/vendor + platform/windows/Get-VendorPackages.ps1 - name: Get vcpkg commit id run: | - $vcpkg_commit_id = ($(git submodule status .\platform\windows\vendor\vcpkg).Trim() -split ' ')[0] + $vcpkg_commit_id = (Invoke-WebRequest ${{ github.api_url }}/repos/${{ github.repository }}/contents/platform/windows/vendor/vcpkg?ref=${{ github.ref }} -Headers @{ Authorization = ('Bearer {0}' -f '${{ secrets.GITHUB_TOKEN }}') } | ConvertFrom-Json).sha Add-Content -Path $env:GITHUB_ENV -Value "VCPKG_COMMIT_ID=${vcpkg_commit_id}" - name: Restore vcpkg binary cache @@ -77,6 +79,12 @@ jobs: key: vcpkg-${{ env.VCPKG_COMMIT_ID }} lookup-only: true + - name: Initialize vcpkg submodule + if: steps.vcpkg-cache.outputs.cache-hit != 'true' + run: | + git submodule sync --recursive + git submodule update --init --force --depth=1 --recursive platform/windows/vendor/vcpkg + - uses: ilammy/msvc-dev-cmd@v1 if: steps.vcpkg-cache.outputs.cache-hit != 'true' @@ -84,11 +92,10 @@ jobs: if: steps.vcpkg-cache.outputs.cache-hit != 'true' env: CI: 1, -# VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}\\platform\\windows\\vendor\\vcpkg\\archives,readwrite" timeout-minutes: 60 run: | - & ${{ github.workspace }}\platform\windows\Get-VendorPackages.ps1 -Triplet ${{ env.VSCMD_ARG_TGT_ARCH }}-windows -Renderer All + & ${{ github.workspace }}\platform\windows\Get-VendorPackages.ps1 -Triplet ${{ env.VSCMD_ARG_TGT_ARCH }}-windows -Renderer All -With-ICU - name: Save vcpkg binary cache if: steps.vcpkg-cache.outputs.cache-hit != 'true' @@ -99,7 +106,6 @@ jobs: windows-build-and-test: -# if: needs.pre-job.outputs.should_skip != 'true' needs: windows-get-or-build-dependencies strategy: matrix: @@ -142,19 +148,17 @@ jobs: env: CI: 1 VCPKG_INSTALL_OPTIONS: "--debug" -# VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}\\platform\\windows\\vendor\\vcpkg\\archives,readwrite" CMAKE_C_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}" CMAKE_CXX_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}" - RENDERER: "${{ matrix.renderer }}" timeout-minutes: 60 run: | cmake --version - & ${{ github.workspace }}\.github\scripts\windows-ci_configure_wrapper.ps1 + cmake --preset windows-${{ matrix.renderer }} -DCMAKE_POLICY_DEFAULT_CMP0141=NEW -DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded -DCMAKE_BUILD_TYPE=RelWithDebInfo - name: Build MapLibre Native Core run: | - cmake --build build --target mbgl-core mbgl-test-runner mbgl-render-test-runner mbgl-expression-test mbgl-render mbgl-benchmark-runner + cmake --build build-windows-${{ matrix.renderer }} --target mbgl-core mbgl-test-runner mbgl-render-test-runner mbgl-expression-test mbgl-render mbgl-benchmark-runner # CodeQL @@ -165,43 +169,42 @@ jobs: - name: Download Mesa3D run: | - (Invoke-WebRequest https://api.github.com/repos/pal1000/mesa-dist-win/releases -Headers @{ Authorization = ('Bearer {0}' -f '${{ secrets.GITHUB_TOKEN }}') } | ConvertFrom-Json)[0].assets | Where-Object name -match 'mesa3d-.+-(release|devel)-msvc\.7z' | foreach { Invoke-WebRequest $_.browser_download_url -OutFile mesa3d.7z } + (Invoke-WebRequest https://api.github.com/repos/pal1000/mesa-dist-win/releases -Headers @{ Authorization = ('Bearer {0}' -f '${{ secrets.GITHUB_TOKEN }}') } | ConvertFrom-Json)[0].assets | Where-Object name -match 'mesa3d-.+-release-msvc\.7z' | foreach { Invoke-WebRequest $_.browser_download_url -OutFile mesa3d.7z } - name: Extract Mesa3D files for OpenGL if: matrix.renderer != 'vulkan' run: | - & 'C:\Program Files\7-Zip\7z.exe' e -bb3 -obuild .\mesa3d.7z x64\opengl32.dll x64\libgallium_wgl.dll x64\libGLESv2.dll - - - name: Extract Mesa3D files for EGL - if: matrix.renderer == 'egl' - run: | - & 'C:\Program Files\7-Zip\7z.exe' e -bb3 -obuild .\mesa3d.7z x64\d3d10warp.dll + & 'C:\Program Files\7-Zip\7z.exe' e -obuild-windows-${{ matrix.renderer }} .\mesa3d.7z x64\libgallium_wgl.dll x64\libGLESv2.dll - name: Extract Mesa3D files for Vulkan if: matrix.renderer == 'vulkan' run: | - & 'C:\Program Files\7-Zip\7z.exe' e -bb3 -obuild .\mesa3d.7z x64\lvp_icd.x86_64.json x64\vulkan_lvp.dll + & 'C:\Program Files\7-Zip\7z.exe' e -obuild-windows-${{ matrix.renderer }} .\mesa3d.7z x64\lvp_icd.x86_64.json x64\vulkan_lvp.dll # unit tests - name: Configure Mesa3D drivers (OpenGL) if: matrix.renderer != 'vulkan' run: | + reg add 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers\MSOGL' /v DLL /t REG_SZ /d ('{0}\build-windows-${{ matrix.renderer }}\libgallium_wgl.dll' -f $PWD.Path) /f + reg add 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers\MSOGL' /v DriverVersion /t REG_DWORD /d 1 /f + reg add 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers\MSOGL' /v Flags /t REG_DWORD /d 1 /f + reg add 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers\MSOGL' /v Version /t REG_DWORD /d 2 /f Add-Content -Path $env:GITHUB_ENV -Value 'GALLIUM_DRIVER=llvmpipe' - name: Configure Mesa3D drivers (Vulkan) if: matrix.renderer == 'vulkan' run: | - reg add 'HKLM\Software\Khronos\Vulkan\Drivers' /f /v '${{ github.workspace }}\build\lvp_icd.x86_64.json' /t REG_DWORD /d 0 + reg add 'HKLM\Software\Khronos\Vulkan\Drivers' /f /v '${{ github.workspace }}\build-windows-${{ matrix.renderer }}\lvp_icd.x86_64.json' /t REG_DWORD /d 0 - name: Download and configure Vulkan if: matrix.renderer == 'vulkan' - # 1.4.313.1 doesn't have runtime components? - # $version = (Invoke-WebRequest -Uri "https://vulkan.lunarg.com/sdk/latest.json" | ConvertFrom-Json).windows run: | - $version = "1.4.313.0" + # 1.4.313.1 doesn't have runtime components? + # $version = (Invoke-WebRequest -Uri "https://vulkan.lunarg.com/sdk/latest.json" | ConvertFrom-Json).windows + $version = '1.4.313.0' Invoke-WebRequest https://sdk.lunarg.com/sdk/download/$version/windows/VulkanRT-X64-$version-Components.zip -OutFile VulkanRT.zip - & 'C:\Program Files\7-Zip\7z.exe' e -bb3 -obuild -r .\VulkanRT.zip *x64\vulkan-1.* + & 'C:\Program Files\7-Zip\7z.exe' e -obuild-windows-${{ matrix.renderer }} -r .\VulkanRT.zip *x64\vulkan-1.* - name: Run C++ tests continue-on-error: ${{ matrix.renderer == 'vulkan' }} @@ -209,7 +212,7 @@ jobs: ANGLE_DEFAULT_PLATFORM: 'gl' GALLIUM_DRIVER: llvmpipe LIBGL_ALWAYS_SOFTWARE: true - run: build/mbgl-test-runner.exe + run: build-windows-${{ matrix.renderer }}/mbgl-test-runner.exe # render tests @@ -220,7 +223,7 @@ jobs: ANGLE_DEFAULT_PLATFORM: 'gl' GALLIUM_DRIVER: llvmpipe LIBGL_ALWAYS_SOFTWARE: true - run: build/mbgl-render-test-runner.exe "--manifestPath=metrics/windows-${env:manifest_file}.json" + run: build-windows-${{ matrix.renderer }}/mbgl-render-test-runner.exe "--manifestPath=metrics/windows-${env:manifest_file}.json" - name: Upload render test result if: always() && steps.render_test.outcome == 'failure' @@ -233,7 +236,7 @@ jobs: # expression tests - name: Run expression test - run: build/expression-test/mbgl-expression-test.exe + run: build-windows-${{ matrix.renderer }}/expression-test/mbgl-expression-test.exe windows-ci-result: name: Windows CI Result diff --git a/CMakePresets.json b/CMakePresets.json index 5feb9708e..768fcdf01 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -129,6 +129,71 @@ "MLN_CORE_INCLUDE_DEPS": "ON", "MLN_USE_BUILTIN_ICU": "ON" } + }, + { + "name": "windows", + "hidden": true, + "generator": "Ninja", + "cacheVariables": { + "CMAKE_SYSTEM_NAME": "Windows", + "MLN_WITH_OPENGL": "OFF", + "MLN_WITH_EGL": "OFF", + "MLN_WITH_VULKAN": "OFF", + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "windows-opengl", + "binaryDir": "${sourceDir}/build-windows-opengl", + "generator": "Ninja", + "inherits": "windows", + "cacheVariables": { + "MLN_WITH_OPENGL": "ON" + } + }, + { + "name": "windows-opengl-core", + "inherits": "windows-opengl", + "cacheVariables": { + "MLN_CORE_INCLUDE_DEPS": "ON", + "MLN_USE_BUILTIN_ICU": "ON" + } + }, + { + "name": "windows-egl", + "binaryDir": "${sourceDir}/build-windows-egl", + "generator": "Ninja", + "inherits": "windows", + "cacheVariables": { + "MLN_WITH_OPENGL": "ON", + "MLN_WITH_EGL": "ON" + } + }, + { + "name": "windows-egl-core", + "inherits": "windows-egl", + "cacheVariables": { + "MLN_CORE_INCLUDE_DEPS": "ON", + "MLN_USE_BUILTIN_ICU": "ON" + } + }, + { + "name": "windows-vulkan", + "binaryDir": "${sourceDir}/build-windows-vulkan", + "inherits": "windows", + "cacheVariables": { + "MLN_WITH_OPENGL": "OFF", + "MLN_WITH_EGL": "OFF", + "MLN_WITH_VULKAN": "ON" + } + }, + { + "name": "windows-vulkan-core", + "inherits": "windows-vulkan", + "cacheVariables": { + "MLN_CORE_INCLUDE_DEPS": "ON", + "MLN_USE_BUILTIN_ICU": "ON" + } } ], "buildPresets": [ @@ -146,6 +211,21 @@ "name": "linux-vulkan-core", "configurePreset": "linux-vulkan", "targets": ["mbgl-core"] + }, + { + "name": "windows-opengl-core", + "configurePreset": "windows-opengl", + "targets": ["mbgl-core"] + }, + { + "name": "windows-egl-core", + "configurePreset": "windows-egl", + "targets": ["mbgl-core"] + }, + { + "name": "windows-vulkan-core", + "configurePreset": "windows-vulkan", + "targets": ["mbgl-core"] } ] } diff --git a/platform/node/CMakeLists.txt b/platform/node/CMakeLists.txt index b53a17fa5..3774b3678 100644 --- a/platform/node/CMakeLists.txt +++ b/platform/node/CMakeLists.txt @@ -1,5 +1,5 @@ set(NODE_MODULE_MINIMUM_ABI 83) # Minimum supported Node.js version: 14 -set(NODE_MODULE_CACHE_DIR ${CMAKE_SOURCE_DIR}/build/headers) +set(NODE_MODULE_CACHE_DIR ${CMAKE_BINARY_DIR}/headers) include(${CMAKE_CURRENT_LIST_DIR}/cmake/module.cmake) diff --git a/platform/windows/Get-VendorPackages.ps1 b/platform/windows/Get-VendorPackages.ps1 index b64ce4e2e..5874a32f1 100644 --- a/platform/windows/Get-VendorPackages.ps1 +++ b/platform/windows/Get-VendorPackages.ps1 @@ -1,12 +1,11 @@ param( [Parameter(Mandatory=$true)][string]$Triplet, - [Parameter(Mandatory=$true)][string]$Renderer + [Parameter(Mandatory=$true)][string]$Renderer, + [Parameter(Mandatory=$false)][switch]${With-ICU} ) Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent) -Copy-Item ('{0}\*' -f [System.IO.Path]::Combine($PWD.Path, 'vendor', 'vcpkg-custom-ports')) -Force -Recurse -Destination ('{0}\ports\' -f [System.IO.Path]::Combine($PWD.Path, 'vendor', 'vcpkg')) - $vcpkg_temp_dir = '***' foreach($letter in [byte][char]'Z'..[byte][char]'A') @@ -40,8 +39,8 @@ if(-not (Test-Path ('{0}\vcpkg.exe' -f $vcpkg_temp_dir))) ('--overlay-triplets={0}' -f [System.IO.Path]::Combine($PWD.Path, 'vendor', 'vcpkg-custom-triplets')), ('--triplet={0}' -f $Triplet), '--clean-after-build', - 'install', 'curl', 'dlfcn-win32', 'glfw3', 'icu', 'libuv', 'libjpeg-turbo', 'libpng', 'libwebp' - ) + $renderer_packages + 'install', 'curl', 'dlfcn-win32', 'glfw3', 'libuv', 'libjpeg-turbo', 'libpng', 'libwebp' + ) + $renderer_packages + $(if(${With-ICU}) {@('icu')} else {@()}) ) subst $vcpkg_temp_dir /D diff --git a/platform/windows/vendor/vcpkg-custom-ports/angle/004-fix-opengl32.dll-load.patch b/platform/windows/vendor/vcpkg-custom-ports/angle/004-fix-opengl32.dll-load.patch deleted file mode 100644 index 88b5d6480..000000000 --- a/platform/windows/vendor/vcpkg-custom-ports/angle/004-fix-opengl32.dll-load.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp b/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp -index b83b8971a6..a2c24cdb31 100644 ---- a/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp -+++ b/src/libANGLE/renderer/gl/wgl/DisplayWGL.cpp -@@ -128,7 +128,7 @@ egl::Error DisplayWGL::initializeImpl(egl::Display *display) - { - mDisplayAttributes = display->getAttributeMap(); - -- mOpenGLModule = LoadLibraryExA("opengl32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); -+ mOpenGLModule = LoadLibraryExA("opengl32.dll", NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32); - if (!mOpenGLModule) - { - return egl::EglNotInitialized() << "Failed to load OpenGL library."; diff --git a/platform/windows/vendor/vcpkg-custom-ports/angle/portfile.cmake b/platform/windows/vendor/vcpkg-custom-ports/angle/portfile.cmake deleted file mode 100644 index 0354308a2..000000000 --- a/platform/windows/vendor/vcpkg-custom-ports/angle/portfile.cmake +++ /dev/null @@ -1,194 +0,0 @@ -if (VCPKG_TARGET_IS_LINUX) - message(WARNING "Building with a gcc version less than 6.1 is not supported.") - message(WARNING "${PORT} currently requires the following libraries from the system package manager:\n libx11-dev\n mesa-common-dev\n libxi-dev\n libxext-dev\n\nThese can be installed on Ubuntu systems via apt-get install libx11-dev mesa-common-dev libxi-dev libxext-dev.") -endif() - -if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") - set(ANGLE_CPU_BITNESS ANGLE_IS_32_BIT_CPU) -elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - set(ANGLE_CPU_BITNESS ANGLE_IS_64_BIT_CPU) -elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") - set(ANGLE_CPU_BITNESS ANGLE_IS_32_BIT_CPU) -elseif (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") - set(ANGLE_CPU_BITNESS ANGLE_IS_64_BIT_CPU) -else() - message(FATAL_ERROR "Unsupported architecture: ${VCPKG_TARGET_ARCHITECTURE}") -endif() - -set(ANGLE_USE_D3D11_COMPOSITOR_NATIVE_WINDOW "OFF") -if (VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP) - set(ANGLE_BUILDSYSTEM_PORT "Win") - if (NOT VCPKG_TARGET_IS_MINGW) - set(ANGLE_USE_D3D11_COMPOSITOR_NATIVE_WINDOW "ON") - endif() -elseif (VCPKG_TARGET_IS_OSX) - set(ANGLE_BUILDSYSTEM_PORT "Mac") -elseif (VCPKG_TARGET_IS_LINUX) - set(ANGLE_BUILDSYSTEM_PORT "Linux") -else() - # default other platforms to "Linux" config - set(ANGLE_BUILDSYSTEM_PORT "Linux") -endif() - -# chromium/5414 -set(ANGLE_COMMIT aa63ea230e0c507e7b4b164a30e502fb17168c17) -set(ANGLE_VERSION 5414) -set(ANGLE_SHA512 a3b55d4b484e1e9ece515d60af1d47a80a0576b198d9a2397e4e68b16efd83468dcdfadc98dae57ff17f01d02d74526f8b59fdf00661b70a45b6dd266e5ffe38) -set(ANGLE_THIRDPARTY_ZLIB_COMMIT 44d9b490c721abdb923d5c6c23ac211e45ffb1a5) - -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO google/angle - REF ${ANGLE_COMMIT} - SHA512 ${ANGLE_SHA512} - # On update check headers against opengl-registry - PATCHES - 001-fix-uwp.patch - 002-fix-builder-error.patch - 003-fix-mingw.patch - 004-fix-opengl32.dll-load.patch -) - -# Generate angle_commit.h -set(ANGLE_COMMIT_HASH_SIZE 12) -string(SUBSTRING "${ANGLE_COMMIT}" 0 ${ANGLE_COMMIT_HASH_SIZE} ANGLE_COMMIT_HASH) -set(ANGLE_COMMIT_DATE "invalid-date") -set(ANGLE_REVISION "${ANGLE_VERSION}") -configure_file("${CMAKE_CURRENT_LIST_DIR}/angle_commit.h.in" "${SOURCE_PATH}/angle_commit.h" @ONLY) -configure_file("${CMAKE_CURRENT_LIST_DIR}/angle_commit.h.in" "${SOURCE_PATH}/src/common/angle_commit.h" @ONLY) -file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-angle-config.cmake" DESTINATION "${SOURCE_PATH}") - -set(ANGLE_WEBKIT_BUILDSYSTEM_COMMIT "bb1da00b9ba878d228a5e9834a0767dbca2fee43") - -# Download WebKit gni-to-cmake.py conversion script -vcpkg_download_distfile(GNI_TO_CMAKE_PY - URLS "https://github.com/WebKit/WebKit/raw/${ANGLE_WEBKIT_BUILDSYSTEM_COMMIT}/Source/ThirdParty/ANGLE/gni-to-cmake.py" - FILENAME "gni-to-cmake.py" - SHA512 9da35caf2db2e849d6cc85721ba0b77eee06b6f65a7c5314fb80483db4949b0b6e9bf4b2d4fc63613665629b24e9b052e03fb1451b09313d881297771a4f2736 -) - -# Generate CMake files from GN / GNI files -vcpkg_find_acquire_program(PYTHON3) - -set(_root_gni_files_to_convert - "compiler.gni Compiler.cmake" - "libGLESv2.gni GLESv2.cmake" -) -set(_renderer_gn_files_to_convert - "libANGLE/renderer/d3d/BUILD.gn D3D.cmake" - "libANGLE/renderer/gl/BUILD.gn GL.cmake" - "libANGLE/renderer/metal/BUILD.gn Metal.cmake" -) - -foreach(_root_gni_file IN LISTS _root_gni_files_to_convert) - separate_arguments(_file_values UNIX_COMMAND "${_root_gni_file}") - list(GET _file_values 0 _src_gn_file) - list(GET _file_values 1 _dst_file) - vcpkg_execute_required_process( - COMMAND "${PYTHON3}" "${GNI_TO_CMAKE_PY}" "src/${_src_gn_file}" "${_dst_file}" - WORKING_DIRECTORY "${SOURCE_PATH}" - LOGNAME "gni-to-cmake-${_dst_file}-${TARGET_TRIPLET}" - ) -endforeach() - -foreach(_renderer_gn_file IN LISTS _renderer_gn_files_to_convert) - separate_arguments(_file_values UNIX_COMMAND "${_renderer_gn_file}") - list(GET _file_values 0 _src_gn_file) - list(GET _file_values 1 _dst_file) - get_filename_component(_src_dir "${_src_gn_file}" DIRECTORY) - vcpkg_execute_required_process( - COMMAND "${PYTHON3}" "${GNI_TO_CMAKE_PY}" "src/${_src_gn_file}" "${_dst_file}" --prepend "src/${_src_dir}/" - WORKING_DIRECTORY "${SOURCE_PATH}" - LOGNAME "gni-to-cmake-${_dst_file}-${TARGET_TRIPLET}" - ) -endforeach() - -# Fetch additional CMake files from WebKit ANGLE buildsystem -vcpkg_download_distfile(WK_ANGLE_INCLUDE_CMAKELISTS - URLS "https://github.com/WebKit/WebKit/raw/${ANGLE_WEBKIT_BUILDSYSTEM_COMMIT}/Source/ThirdParty/ANGLE/include/CMakeLists.txt" - FILENAME "include_CMakeLists.txt" - SHA512 a7ddf3c6df7565e232f87ec651cc4fd84240b8866609e23e3e6e41d22532fd34c70e0f3b06120fd3d6d930ca29c1d0d470d4c8cb7003a66f8c1a840a42f32949 -) -configure_file("${WK_ANGLE_INCLUDE_CMAKELISTS}" "${SOURCE_PATH}/include/CMakeLists.txt" COPYONLY) - -vcpkg_download_distfile(WK_ANGLE_CMAKE_WEBKITCOMPILERFLAGS - URLS "https://github.com/WebKit/WebKit/raw/${ANGLE_WEBKIT_BUILDSYSTEM_COMMIT}/Source/cmake/WebKitCompilerFlags.cmake" - FILENAME "WebKitCompilerFlags.cmake" - SHA512 63f981694ae37d4c4ca4c34e2bf62b4d4602b6a1a660851304fa7a6ee834fc58fa6730eeb41ef4e075550f3c8b675823d4d00bdcd72ca869c6d5ab11196b33bb -) -file(COPY "${WK_ANGLE_CMAKE_WEBKITCOMPILERFLAGS}" DESTINATION "${SOURCE_PATH}/cmake") - -vcpkg_download_distfile(WK_ANGLE_CMAKE_DETECTSSE2 - URLS "https://github.com/WebKit/WebKit/raw/${ANGLE_WEBKIT_BUILDSYSTEM_COMMIT}/Source/cmake/DetectSSE2.cmake" - FILENAME "DetectSSE2.cmake" - SHA512 219a4c8591ee31d11eb3d1e4803cc3c9d4573984bb25ecac6f2c76e6a3dab598c00b0157d0f94b18016de6786e49d8b29a161693a5ce23d761c8fe6a798c1bca -) -file(COPY "${WK_ANGLE_CMAKE_DETECTSSE2}" DESTINATION "${SOURCE_PATH}/cmake") - -vcpkg_download_distfile(WK_ANGLE_CMAKE_WEBKITMACROS - URLS "https://github.com/WebKit/WebKit/raw/${ANGLE_WEBKIT_BUILDSYSTEM_COMMIT}/Source/cmake/WebKitMacros.cmake" - FILENAME "WebKitMacros.cmake" - SHA512 0d126b1d1b0ca995c2ea6e51c73326db363f560f3f07912ce58c7c022d9257d27b963dac56aee0e9604ca7a3d74c5aa9f0451c243fec922fb485dd2253685ab6 -) -file(COPY "${WK_ANGLE_CMAKE_WEBKITMACROS}" DESTINATION "${SOURCE_PATH}/cmake") - -# Copy additional custom CMake buildsystem into appropriate folders -file(GLOB MAIN_BUILDSYSTEM "${CMAKE_CURRENT_LIST_DIR}/cmake-buildsystem/CMakeLists.txt" "${CMAKE_CURRENT_LIST_DIR}/cmake-buildsystem/*.cmake") -file(COPY ${MAIN_BUILDSYSTEM} DESTINATION "${SOURCE_PATH}") -file(GLOB MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake-buildsystem/cmake/*.cmake") -file(COPY ${MODULES} DESTINATION "${SOURCE_PATH}/cmake") - -function(checkout_in_path PATH URL REF) - if(EXISTS "${PATH}") - return() - endif() - - vcpkg_from_git( - OUT_SOURCE_PATH DEP_SOURCE_PATH - URL "${URL}" - REF "${REF}" - ) - file(RENAME "${DEP_SOURCE_PATH}" "${PATH}") - file(REMOVE_RECURSE "${DEP_SOURCE_PATH}") -endfunction() - -checkout_in_path( - "${SOURCE_PATH}/third_party/zlib" - "https://chromium.googlesource.com/chromium/src/third_party/zlib" - "${ANGLE_THIRDPARTY_ZLIB_COMMIT}" -) - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=1 - OPTIONS - "-D${ANGLE_CPU_BITNESS}=1" - "-DPORT=${ANGLE_BUILDSYSTEM_PORT}" - "-DANGLE_USE_D3D11_COMPOSITOR_NATIVE_WINDOW=${ANGLE_USE_D3D11_COMPOSITOR_NATIVE_WINDOW}" - "-DVCPKG_TARGET_IS_WINDOWS=${VCPKG_TARGET_IS_WINDOWS}" -) - -vcpkg_cmake_install() - -vcpkg_cmake_config_fixup(CONFIG_PATH share/unofficial-angle PACKAGE_NAME unofficial-angle) - -vcpkg_copy_pdbs() - -file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) - -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -# Remove empty directories inside include directory -file(GLOB directory_children RELATIVE "${CURRENT_PACKAGES_DIR}/include" "${CURRENT_PACKAGES_DIR}/include/*") -foreach(directory_child ${directory_children}) - if(IS_DIRECTORY "${CURRENT_PACKAGES_DIR}/include/${directory_child}") - file(GLOB_RECURSE subdirectory_children "${CURRENT_PACKAGES_DIR}/include/${directory_child}/*") - if("${subdirectory_children}" STREQUAL "") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/${directory_child}") - endif() - endif() -endforeach() -unset(subdirectory_children) -unset(directory_child) -unset(directory_children) - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/platform/windows/windows.cmake b/platform/windows/windows.cmake index 94a302c08..d44ebb73b 100644 --- a/platform/windows/windows.cmake +++ b/platform/windows/windows.cmake @@ -6,7 +6,11 @@ else() set(_RENDERER OpenGL) endif() -execute_process(COMMAND powershell -ExecutionPolicy Bypass -File ${CMAKE_CURRENT_LIST_DIR}/Get-VendorPackages.ps1 -Triplet ${VCPKG_TARGET_TRIPLET} -Renderer ${_RENDERER}) +if(NOT MLN_USE_BUILTIN_ICU) + set(WITH_ICU -With-ICU) +endif() + +execute_process(COMMAND powershell -ExecutionPolicy Bypass -File ${CMAKE_CURRENT_LIST_DIR}/Get-VendorPackages.ps1 -Triplet ${VCPKG_TARGET_TRIPLET} -Renderer ${_RENDERER} ${WITH_ICU}) unset(_RENDERER) add_compile_definitions(NOMINMAX GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE) @@ -130,6 +134,15 @@ else() ) endif() +if (DEFINED ENV{CI}) + message("Building for CI") + target_compile_definitions( + mbgl-core + PRIVATE + CI_BUILD=1 + ) +endif() + # FIXME: Should not be needed, but now needed by node because of the headless frontend. target_include_directories( mbgl-core @@ -146,8 +159,8 @@ target_include_directories( include(${PROJECT_SOURCE_DIR}/vendor/nunicode.cmake) include(${PROJECT_SOURCE_DIR}/vendor/sqlite.cmake) -if(NOT ${ICU_FOUND} OR "${ICU_VERSION}" VERSION_LESS 62.0) - message(STATUS "ICU not found or too old, using builtin.") +if(NOT ${ICU_FOUND} OR "${ICU_VERSION}" VERSION_LESS 62.0 OR MLN_USE_BUILTIN_ICU) + message(STATUS "ICU not found, too old or MLN_USE_BUILTIN_ICU requestd, using builtin.") set(MLN_USE_BUILTIN_ICU TRUE) include(${PROJECT_SOURCE_DIR}/vendor/icu.cmake) @@ -158,6 +171,19 @@ if(NOT ${ICU_FOUND} OR "${ICU_VERSION}" VERSION_LESS 62.0) COMPILE_DEFINITIONS MBGL_USE_BUILTIN_ICU ) + + target_compile_definitions( + mbgl-vendor-icu + PRIVATE + U_STATIC_IMPLEMENTATION + ) + + target_include_directories( + mbgl-core + BEFORE + PRIVATE + ${PROJECT_SOURCE_DIR}/vendor/icu/include + ) endif() target_link_libraries( @@ -168,10 +194,10 @@ target_link_libraries( ${LIBUV_LIBRARIES} ${WEBP_LIBRARIES} dlfcn-win32::dl - $<$>:ICU::data> $<$>:ICU::i18n> $<$>:ICU::uc> - $<$:mbgl-vendor-icu> + $<$>:ICU::data> + $<$:$,$,mbgl-vendor-icu>> PNG::PNG mbgl-vendor-nunicode mbgl-vendor-sqlite @@ -179,7 +205,9 @@ target_link_libraries( add_subdirectory(${PROJECT_SOURCE_DIR}/bin) add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test) -add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw) +if(MLN_WITH_GLFW) + add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw) +endif() if(MLN_WITH_NODE) add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node) endif() @@ -191,9 +219,19 @@ add_executable( target_compile_definitions( mbgl-test-runner - PRIVATE MBGL_BUILDING_LIB WORK_DIRECTORY=${PROJECT_SOURCE_DIR} + PRIVATE + MBGL_BUILDING_LIB + WORK_DIRECTORY=${PROJECT_SOURCE_DIR} ) +if (DEFINED ENV{CI}) + target_compile_definitions( + mbgl-test-runner + PRIVATE + CI_BUILD=1 + ) +endif() + target_include_directories( mbgl-test-runner PRIVATE @@ -219,7 +257,6 @@ target_link_libraries( mbgl-compiler-options $ $,libuv::uv_a,libuv::uv> - shlwapi ) add_executable( @@ -227,11 +264,6 @@ add_executable( ${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/render-test/main.cpp ) -target_compile_definitions( - mbgl-render-test-runner - PRIVATE MBGL_BUILDING_LIB -) - target_link_libraries( mbgl-render-test-runner PRIVATE diff --git a/vendor/benchmark.cmake b/vendor/benchmark.cmake index 87d80c458..427254d65 100644 --- a/vendor/benchmark.cmake +++ b/vendor/benchmark.cmake @@ -35,6 +35,11 @@ if(WIN32) mbgl-vendor-benchmark PUBLIC BENCHMARK_STATIC_DEFINE ) + + target_link_libraries( + mbgl-vendor-benchmark + PRIVATE shlwapi + ) endif() target_include_directories(