Skip to content

Commit

Permalink
Add windows support (#707)
Browse files Browse the repository at this point in the history
Co-authored-by: acalcutt <[email protected]>
Co-authored-by: Bart Louwers <[email protected]>
Co-authored-by: Ovidiu Voda <[email protected]>
  • Loading branch information
4 people authored Feb 25, 2023
1 parent 23cba4b commit f06f608
Show file tree
Hide file tree
Showing 34 changed files with 2,371 additions and 92 deletions.
110 changes: 77 additions & 33 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ jobs:
arch: x86_64
- runs-on: macos-12-arm
arch: arm64
- runs-on: windows-2022
arch: x86_64
continue-on-error: true
env:
BUILDTYPE: ${{github.ref == 'refs/heads/main' && 'Release' || 'Debug'}}
Expand All @@ -72,21 +74,24 @@ jobs:
shell: bash

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0

- name: Setup submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c core.longpaths=true -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive || true
- name: Get OS Architecture
if: runner.os == 'MacOS' || runner.os == 'Linux'
run: uname -m

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies macOS
if: runner.os == 'macOS'
- name: Install dependencies (MacOS)
if: runner.os == 'MacOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
Expand All @@ -98,7 +103,7 @@ jobs:
brew list glfw || brew install glfw
brew list libuv || brew install libuv
- name: Install dependencies Linux
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
env:
DEBIAN_FRONTEND: noninteractive
Expand All @@ -118,63 +123,102 @@ jobs:
libc++abi-9-dev
/usr/sbin/update-ccache-symlinks
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: npm ci
run: npm ci --ignore-scripts

- name: Prepare ccache
run: ccache --clear --set-config cache_dir=~/.ccache
- name: Set up msvc dev cmd (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Cache ccache
uses: actions/cache@v3
env:
cache-name: ccache-v1
- name: Update ccache (Windows)
if: runner.os == 'Windows'

run: |
choco.exe upgrade ccache
ccache.exe --version
echo "CCACHE_CONFIGPATH=C:/Users/runneradmin/AppData/Roaming/ccache/ccache.conf" >> $GITHUB_ENV
- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1
with:
path: ~/.ccache
key: ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }}
restore-keys: |
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}
- name: Clear ccache statistics
run: |
ccache --zero-stats --set-config cache_dir=~/.ccache
ccache --max-size=2G --set-config cache_dir=~/.ccache
ccache --show-stats --set-config cache_dir=~/.ccache
- name: CMake
- name: Configure maplibre-gl-native (MacOS)
if: runner.os == 'MacOS'
run: |
cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }}
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
- name: CMake
- name: Configure maplibre-gl-native (Linux)
if: runner.os == 'Linux'
run: |
cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=gcc-10 \
-DCMAKE_CXX_COMPILER=g++-10
- name: Configure maplibre-gl-native (Windows)
if: runner.os == 'Windows'
run: |
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache.exe
- name: Build
- name: Build maplibre-gl-native (MacOS/Linux)
if: runner.os == 'MacOS' || runner.os == 'Linux'
run: |
cmake --build build -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)
- name: Build maplibre-gl-native (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
cmake --build build
- name: Run render tests on macOS
if: runner.os == 'macOS'
run: set -o pipefail && ./build/mbgl-render-test-runner --manifestPath metrics/macos-xcode11-release-style.json

- name: Upload render test artifacts
- name: Upload render test artifacts (MacOS)
if: runner.os == 'MacOS'
uses: actions/upload-artifact@v3
if: always()
with:
name: render-query-test-results
path: metrics/macos-xcode11-release-style.html

- name: Test
- name: Test (Linux)
if: runner.os == 'Linux'
run: xvfb-run --auto-servernum npm test

- name: Test
if: runner.os == 'macOS'
- name: Test (MacOS)
if: runner.os == 'MacOS'
run: npm test

- name: Test (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
LIBGL_ALWAYS_SOFTWARE: true
GALLIUM_DRIVER: softpipe
run: |
Invoke-WebRequest https://github.com/pal1000/mesa-dist-win/releases/download/22.3.5/mesa3d-22.3.5-release-msvc.7z -OutFile mesa3d.7z
& 'C:\Program Files\7-Zip\7z.exe' e -olib\node-v108 .\mesa3d.7z x64\opengl32.dll x64\libgallium_wgl.dll x64\libGLESv2.dll x64\libglapi.dll
npm test
# On PRs make sure that the npm package can be packaged.
- name: Pack
if: github.ref != 'refs/heads/main'
Expand Down
111 changes: 59 additions & 52 deletions .github/workflows/node-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
arch: x86_64
- runs-on: macos-12-arm
arch: arm64
- runs-on: windows-2022
arch: x86_64
needs: bump_version
continue-on-error: true
env:
Expand All @@ -70,24 +72,27 @@ jobs:
shell: bash

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0

- name: Get Latest Version
run: git pull

- name: Setup submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c core.longpaths=true -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 || true
- name: Get OS Architecture
if: runner.os == 'MacOS' || runner.os == 'Linux'
run: uname -m

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies macOS
if: runner.os == 'macOS'
- name: Install dependencies (MacOS)
if: runner.os == 'MacOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
Expand All @@ -99,7 +104,7 @@ jobs:
brew list glfw || brew install glfw
brew list libuv || brew install libuv
- name: Install dependencies Linux
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
env:
DEBIAN_FRONTEND: noninteractive
Expand All @@ -119,68 +124,70 @@ jobs:
libc++abi-9-dev
/usr/sbin/update-ccache-symlinks
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18

- name: npm ci
run: npm ci --ignore-scripts

- name: Prepare ccache
run: ccache --clear --set-config cache_dir=~/.ccache
- name: Set up msvc dev cmd (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Cache ccache
uses: actions/cache@v3
env:
cache-name: ccache-v1
- name: Update ccache (Windows)
if: runner.os == 'Windows'
run: |
choco.exe upgrade ccache
ccache.exe --version
echo "CCACHE_CONFIGPATH=C:/Users/runneradmin/AppData/Roaming/ccache/ccache.conf" >> $GITHUB_ENV
- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1
with:
path: ~/.ccache
key: ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }}
restore-keys: |
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}
- name: Clear ccache statistics
run: |
ccache --zero-stats --set-config cache_dir=~/.ccache
ccache --max-size=2G --set-config cache_dir=~/.ccache
ccache --show-stats --set-config cache_dir=~/.ccache
- name: CMake
- name: Configure maplibre-gl-native (MacOS)
if: runner.os == 'MacOS'
run: |
cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }}
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
- name: CMake
- name: Configure maplibre-gl-native (Linux)
if: runner.os == 'Linux'
run: |
cmake . -B build -G Ninja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=gcc-10 \
-DCMAKE_CXX_COMPILER=g++-10
- name: Configure maplibre-gl-native (Windows)
if: runner.os == 'Windows'
run: |
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache.exe
- name: Build
- name: Build maplibre-gl-native (MacOS/Linux)
if: runner.os == 'MacOS' || runner.os == 'Linux'
run: |
cmake --build build -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)
#- name: Run render tests on macOS
# if: runner.os == 'macOS'
# run: ./build/mbgl-render-test-runner --manifestPath metrics/macos-xcode11-release-style.json

#- name: Upload render test artifacts
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: render-query-test-results
# path: metrics/macos-xcode11-release-style.html

#- name: Test
# if: runner.os == 'Linux'
# run: xvfb-run --auto-servernum npm test

#- name: Test
# if: runner.os == 'macOS' && matrix.arch != 'arm64'
# run: npm test

# On PRs make sure that the npm package can be packaged.
#- name: Pack
# if: github.ref != 'refs/heads/main'
# run: |
# npm pack --dry-run
- name: Build maplibre-gl-native (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
cmake --build build
- name: Publish X64 Release to Github
if: github.ref == 'refs/heads/main' && matrix.arch == 'x86_64'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/platform/android/build
/platform/android/MapboxGLAndroidSDK/src/main/assets/sdk_versions/com.mapbox.mapboxsdk
/platform/ios/platform/ios/Mapbox.playground/build/
/platform/windows/vendor/mesa3d/
*.code-workspace

.DS_Store
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@
[submodule "docs/doxygen/doxygen-awesome-css"]
path = docs/doxygen/doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
[submodule "platform/windows/vendor/vcpkg"]
path = platform/windows/vendor/vcpkg
url = https://github.com/microsoft/vcpkg.git
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ option(MBGL_WITH_SANITIZER "Use [address|thread|undefined] here" OFF)
option(MBGL_WITH_RTTI "Compile with runtime type information" OFF)
option(MBGL_WITH_OPENGL "Build with OpenGL renderer" ON)
option(MBGL_WITH_EGL "Build with EGL renderer" OFF)
option(MBGL_WITH_OSMESA "Build with OSMesa (Software) renderer" OFF)
option(MBGL_WITH_WERROR "Make all compilation warnings errors" ON)

if (MBGL_WITH_QT AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0)
endif()

if(WIN32 AND NOT MBGL_WITH_QT)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/platform/windows/custom-toolchain.cmake)
endif()

project("Mapbox GL Native" LANGUAGES CXX C)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand Down Expand Up @@ -1097,6 +1102,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
include(${PROJECT_SOURCE_DIR}/platform/linux/linux.cmake)
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
include(${PROJECT_SOURCE_DIR}/platform/macos/macos.cmake)
elseif(WIN32)
include(${PROJECT_SOURCE_DIR}/platform/windows/windows.cmake)
else()
message(FATAL_ERROR "Unsupported target platform: " ${CMAKE_SYSTEM_NAME})
endif()
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ The documentation of MapLibre GL Native is a work in progress. To get an archite
- [⭐️ iOS](platform/ios/platform/ios/README.md)
- [GLFW](platform/glfw)
- [Linux](platform/linux/README.md)
- [macOS](platform/ios/platform/macos/README.md)
- [Node.js](platform/node/README.md)
- [Qt](platform/qt/README.md)
- [Windows](platform/windows/README.md)
- [macOS](platform/ios/platform/macos/README.md)

Platforms with a ⭐️ are **MapLibre Core Projects** and have a substantial amount of financial resources allocated to them. Learn about the different [project tiers](https://github.com/maplibre/maplibre/blob/main/PROJECT_TIERS.md#project-tiers).

Expand Down
Loading

0 comments on commit f06f608

Please sign in to comment.