From 2544cce75374add864cfd87f13df7a263186f981 Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Sat, 22 Mar 2025 23:24:47 +0100 Subject: [PATCH] Create `core-release.yml` for MapLibre Native Core releases (#3331) --- .github/scripts/install-linux-deps | 12 ++++ .github/workflows/core-release.yml | 83 ++++++++++++++++++++++++++++ .github/workflows/linux-ci.yml | 25 +-------- .github/workflows/pr-linux-tests.yml | 12 +--- CMakeLists.txt | 2 + CMakePresets.json | 65 +++++++++++++++++++++- platform/glfw/CMakeLists.txt | 3 +- platform/macos/macos.cmake | 2 + vendor/csscolorparser.cmake | 2 +- vendor/icu.cmake | 2 +- vendor/parsedate.cmake | 2 +- 11 files changed, 170 insertions(+), 40 deletions(-) create mode 100755 .github/scripts/install-linux-deps create mode 100644 .github/workflows/core-release.yml diff --git a/.github/scripts/install-linux-deps b/.github/scripts/install-linux-deps new file mode 100755 index 000000000..298c5c924 --- /dev/null +++ b/.github/scripts/install-linux-deps @@ -0,0 +1,12 @@ +#!/usr/bin/bash + +sudo apt-get update +DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ + libcurl4-openssl-dev \ + libuv1-dev \ + libjpeg-dev \ + libpng-dev \ + libglfw3-dev \ + libwebp-dev \ + libopengl0 \ + mesa-vulkan-drivers diff --git a/.github/workflows/core-release.yml b/.github/workflows/core-release.yml new file mode 100644 index 000000000..3000d4a70 --- /dev/null +++ b/.github/workflows/core-release.yml @@ -0,0 +1,83 @@ + +name: core-release + +permissions: + contents: write + +on: + workflow_dispatch: + +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create maplibre-native-headers.tar.gz + run: tar czf maplibre-native-headers.tar.gz include + + - name: Create Release + run: | + gh release create core-${{ github.sha }} \ + --draft=false \ + --prerelease=false \ + --latest=false \ + --title "core-${{ github.sha }}" \ + maplibre-native-headers.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-macos: + needs: [create-release] + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build mbgl-core for macOS + run: | + cmake --preset macos-core -DCMAKE_CXX_COMPILER_LAUNCHER="" + cmake --build --preset macos-core + + - name: Rename artifact + run: cp build-macos/libmbgl-core.a libmaplibre-native-core-macos-arm64-metal.a + + - name: Upload macOS artifact + run: gh release upload core-${{ github.sha }} libmaplibre-native-core-macos-arm64-metal.a + env: + GH_TOKEN: ${{ github.token }} + + build-linux: + needs: [create-release] + runs-on: ${{ matrix.runner.os }} + strategy: + matrix: + include: + - renderer: opengl + runner: { os: ubuntu-latest, arch: x64 } + - renderer: vulkan + runner: { os: ubuntu-latest, arch: x64 } + - renderer: opengl + runner: { os: ubuntu-24.04-arm, arch: arm64 } + - renderer: vulkan + runner: { os: ubuntu-24.04-arm, arch: arm64 } + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install dependencies + run: .github/scripts/install-linux-deps + + - name: Build mbgl-core for Linux + run: | + cmake --preset linux-${{ matrix.renderer }}-core -DCMAKE_CXX_COMPILER_LAUNCHER="" + cmake --build --preset linux-${{ matrix.renderer }}-core + + - name: Rename artifact + run: cp build-linux-${{ matrix.renderer }}/libmbgl-core.a libmaplibre-native-core-linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}.a + + - name: Upload Linux artifact + run: gh release upload core-${{ github.sha }} libmaplibre-native-core-linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}.a + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index d3aa17676..4b888d5d9 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -77,17 +77,7 @@ jobs: ninjaVersion: latest - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y \ - libcurl4-openssl-dev \ - libuv1-dev \ - libjpeg-dev \ - libpng-dev \ - libglfw3-dev \ - libwebp-dev \ - libopengl0 \ - mesa-vulkan-drivers + run: .github/scripts/install-linux-deps - if: matrix.renderer == 'drawable' run: echo renderer_flag_cmake=-DMLN_DRAWABLE_RENDERER=ON >> "$GITHUB_ENV" @@ -198,18 +188,7 @@ jobs: fetch-depth: 0 - name: Install dependencies - run: | - sudo apt-get update - DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ - libcurl4-openssl-dev \ - libuv1-dev \ - libjpeg-dev \ - libpng-dev \ - libwebp-dev \ - libglfw3-dev \ - libsqlite3-dev \ - xvfb \ - x11-xserver-utils + run: .github/scripts/install-linux-deps - name: Cache Bazel uses: actions/cache@v4 diff --git a/.github/workflows/pr-linux-tests.yml b/.github/workflows/pr-linux-tests.yml index 659cc74fe..c4dc2ee95 100644 --- a/.github/workflows/pr-linux-tests.yml +++ b/.github/workflows/pr-linux-tests.yml @@ -149,18 +149,8 @@ jobs: - name: Install scipy run: pip3 install scipy - # not sure which one of these are runtime dependencies - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y \ - libcurl4-openssl-dev \ - libuv1-dev \ - libjpeg-dev \ - libpng-dev \ - libglfw3-dev \ - libwebp-dev \ - libopengl0 + run: .github/scripts/install-linux-deps - name: Run Benchmarks # excluding the API tests because they hang https://github.com/maplibre/maplibre-native/issues/1808 diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b5916de3..0d56e4785 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ option(MLN_WITH_CLANG_TIDY "Build with clang-tidy checks enabled" OFF) option(MLN_WITH_COVERAGE "Enable code coverage collection" OFF) option(MLN_WITH_QT "Build MapLibre Native Qt bindings" OFF) option(MLN_WITH_NODE "Build MapLibre Native Node.js bindings" OFF) +option(MLN_WITH_GLFW "Set up targets for GLFW platform" ON) option(MLN_WITH_SANITIZER "Use [address|thread|undefined] here" OFF) option(MLN_WITH_RTTI "Compile with runtime type information" OFF) option(MLN_WITH_OPENGL "Build with OpenGL renderer" ON) @@ -18,6 +19,7 @@ option(MLN_DRAWABLE_RENDERER "Include the drawable rendering pathway" OFF) option(MLN_USE_UNORDERED_DENSE "Use ankerl dense containers for performance" ON) option(MLN_USE_TRACY "Enable Tracy instrumentation" OFF) option(MLN_USE_RUST "Use components in Rust" OFF) +option(MLN_CORE_INCLUDE_DEPS "Include depdendencies in static build of core" OFF) if (MLN_WITH_CLANG_TIDY) find_program(CLANG_TIDY_COMMAND NAMES clang-tidy) diff --git a/CMakePresets.json b/CMakePresets.json index f6be192d2..cdc0275e5 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,5 +1,5 @@ { - "version": 10, + "version": 3, "cmakeMinimumRequired": { "major": 3, "minor": 21, @@ -54,6 +54,69 @@ "MLN_WITH_NODE": "ON", "MLN_WITH_WERROR": "OFF" } + }, + { + "name": "macos-core", + "inherits": "macos", + "cacheVariables": { + "MLN_CORE_INCLUDE_DEPS": "ON", + "MLN_WITH_GLFW": "OFF" + } + }, + { + "name": "linux-opengl", + "binaryDir": "${sourceDir}/build-linux-opengl", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_SYSTEM_NAME": "Linux", + "CMAKE_CXX_COMPILER_LAUNCHER": "ccache", + "MLN_WITH_METAL": "OFF", + "MLN_WITH_OPENGL": "ON", + "MLN_DRAWABLE_RENDERER": "ON", + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + } + }, + { + "name": "linux-opengl-core", + "inherits": "linux-opengl", + "cacheVariables": { + "MLN_CORE_INCLUDE_DEPS": "ON" + } + }, + { + "name": "linux-vulkan", + "binaryDir": "${sourceDir}/build-linux-vulkan", + "generator": "Ninja", + "inherits": "linux-opengl", + "cacheVariables": { + "MLN_WITH_OPENGL": "OFF", + "MLN_WITH_VULKAN": "ON" + } + }, + { + "name": "linux-vulkan-core", + "inherits": "linux-vulkan", + "cacheVariables": { + "MLN_CORE_INCLUDE_DEPS": "ON" + } + } + ], + "buildPresets": [ + { + "name": "macos-core", + "configurePreset": "macos-core", + "targets": ["mbgl-core"] + }, + { + "name": "linux-opengl-core", + "configurePreset": "linux-opengl", + "targets": ["mbgl-core"] + }, + { + "name": "linux-vulkan-core", + "configurePreset": "linux-vulkan", + "targets": ["mbgl-core"] } ] } diff --git a/platform/glfw/CMakeLists.txt b/platform/glfw/CMakeLists.txt index 387479b94..887ab8df7 100644 --- a/platform/glfw/CMakeLists.txt +++ b/platform/glfw/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(OpenGL REQUIRED) - if(WIN32) if(MLN_WITH_OSMESA) message(WARNING "mbgl-glfw does not work with -DMLN_WITH_OSMESA=ON. If you want to build this target, don't use this option.") @@ -39,6 +37,7 @@ set_property( ) if(MLN_WITH_OPENGL) + find_package(OpenGL REQUIRED) target_sources( mbgl-glfw PRIVATE ${PROJECT_SOURCE_DIR}/platform/glfw/glfw_gl_backend.cpp diff --git a/platform/macos/macos.cmake b/platform/macos/macos.cmake index 910310776..01d98a108 100644 --- a/platform/macos/macos.cmake +++ b/platform/macos/macos.cmake @@ -73,7 +73,9 @@ target_include_directories( add_subdirectory(${PROJECT_SOURCE_DIR}/bin) add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test) +if(MLN_WITH_GLFW) add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw) +endif() if(MLN_WITH_NODE) add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node) endif() diff --git a/vendor/csscolorparser.cmake b/vendor/csscolorparser.cmake index e5f15cc38..22d26ccfb 100644 --- a/vendor/csscolorparser.cmake +++ b/vendor/csscolorparser.cmake @@ -2,7 +2,7 @@ if(TARGET mbgl-vendor-csscolorparser) return() endif() -if(MLN_WITH_QT) +if(MLN_WITH_QT OR MLN_CORE_INCLUDE_DEPS) add_library(mbgl-vendor-csscolorparser OBJECT) else() add_library(mbgl-vendor-csscolorparser STATIC) diff --git a/vendor/icu.cmake b/vendor/icu.cmake index e43dc5ad0..5f1169e31 100644 --- a/vendor/icu.cmake +++ b/vendor/icu.cmake @@ -2,7 +2,7 @@ if(TARGET mbgl-vendor-icu) return() endif() -if(MLN_WITH_QT) +if(MLN_WITH_QT OR MLN_CORE_INCLUDE_DEPS) add_library(mbgl-vendor-icu OBJECT) else() add_library(mbgl-vendor-icu STATIC) diff --git a/vendor/parsedate.cmake b/vendor/parsedate.cmake index 9cdedf20e..d16d496ca 100644 --- a/vendor/parsedate.cmake +++ b/vendor/parsedate.cmake @@ -2,7 +2,7 @@ if(TARGET mbgl-vendor-parsedate) return() endif() -if(MLN_WITH_QT) +if(MLN_WITH_QT OR MLN_CORE_INCLUDE_DEPS) add_library(mbgl-vendor-parsedate OBJECT) else() add_library(mbgl-vendor-parsedate STATIC)