From 9b6325a14e2cf1cc29ab28c1855ad376f1ba4903 Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Tue, 2 Sep 2025 22:13:38 +0200 Subject: [PATCH] Create macOS amalgamation for core releases (#3768) --- .github/scripts/install-linux-deps | 4 +- .github/workflows/core-release.yml | 60 +++++++++++++++++-- .github/workflows/linux-ci.yml | 9 +++ CMakePresets.json | 10 +--- .../cmake => cmake}/find_static_library.cmake | 0 platform/linux/linux.cmake | 2 +- platform/macos/macos.cmake | 26 ++++++++ 7 files changed, 93 insertions(+), 18 deletions(-) rename {platform/linux/cmake => cmake}/find_static_library.cmake (100%) diff --git a/.github/scripts/install-linux-deps b/.github/scripts/install-linux-deps index 070f40531..c6a7e5537 100755 --- a/.github/scripts/install-linux-deps +++ b/.github/scripts/install-linux-deps @@ -11,5 +11,5 @@ DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ libopengl0 \ mesa-vulkan-drivers \ llvm \ - glslang-dev -cargo install armerge@2.2.0 + glslang-dev \ + libbz2-dev diff --git a/.github/workflows/core-release.yml b/.github/workflows/core-release.yml index dda079be5..bc4348306 100644 --- a/.github/workflows/core-release.yml +++ b/.github/workflows/core-release.yml @@ -6,6 +6,9 @@ permissions: on: workflow_dispatch: + pull_request: + paths: + - .github/workflows/core-release.yml jobs: create-release: @@ -25,7 +28,9 @@ jobs: vendor/maplibre-native-base/deps/geojson.hpp/include \ vendor/metal-cpp \ vendor/maplibre-native-base/extras/expected-lite/include + - name: Create Release + if: github.event_name == 'workflow_dispatch' run: | gh release create core-${{ github.sha }} \ --draft=false \ @@ -44,16 +49,36 @@ jobs: with: submodules: recursive + - run: brew install webp libuv + + - uses: taiki-e/install-action@020705266844b275b711684191e11281be48860c # v2 + with: + tool: armerge@2 + - name: Build mbgl-core for macOS run: | - cmake --preset macos-core -DCMAKE_CXX_COMPILER_LAUNCHER="" - cmake --build --preset macos-core + cmake --preset macos -DCMAKE_CXX_COMPILER_LAUNCHER="" -DMLN_WITH_GLFW=OFF + cmake --build build-macos --target mbgl-core - name: Rename artifact - run: cp build-macos/libmbgl-core.a libmaplibre-native-core-macos-arm64-metal.a + run: | + cp build-macos/libmbgl-core.a libmaplibre-native-core-macos-arm64-metal.a + cp build-macos/libmbgl-core-amalgam.a libmaplibre-native-core-amalgam-macos-arm64-metal.a - - name: Upload macOS artifact - run: gh release upload core-${{ github.sha }} libmaplibre-native-core-macos-arm64-metal.a + - name: Upload macOS artifacts + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: macos-metal-build + path: | + libmaplibre-native-core-macos-arm64-metal.a + libmaplibre-native-core-amalgam-macos-arm64-metal.a + + - name: Upload macOS artifacts (release) + if: github.event_name == 'workflow_dispatch' + run: | + gh release upload core-${{ github.sha }} libmaplibre-native-core-macos-arm64-metal.a + gh release upload core-${{ github.sha }} libmaplibre-native-core-amalgam-macos-arm64-metal.a env: GH_TOKEN: ${{ github.token }} @@ -79,6 +104,10 @@ jobs: - name: Install dependencies run: .github/scripts/install-linux-deps + - uses: taiki-e/install-action@020705266844b275b711684191e11281be48860c # v2 + with: + tool: armerge@2 + - name: Build mbgl-core for Linux run: | cmake --preset linux-${{ matrix.renderer }} -DCMAKE_CXX_COMPILER_LAUNCHER="" @@ -89,7 +118,17 @@ jobs: cp build-linux-${{ matrix.renderer }}/libmbgl-core.a libmaplibre-native-core-linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}.a cp build-linux-${{ matrix.renderer }}/libmbgl-core-amalgam.a libmaplibre-native-core-amalgam-linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}.a - - name: Upload Linux artifact + - name: Upload Linux artifacts + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}-build + path: | + libmaplibre-native-core-linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}.a + libmaplibre-native-core-amalgam-linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}.a + + - name: Upload Linux artifacts (release) + if: github.event_name == 'workflow_dispatch' run: | gh release upload core-${{ github.sha }} libmaplibre-native-core-linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}.a gh release upload core-${{ github.sha }} libmaplibre-native-core-amalgam-linux-${{ matrix.runner.arch }}-${{ matrix.renderer }}.a @@ -121,6 +160,15 @@ jobs: run: Copy-Item build-windows-${{ matrix.renderer }}/mbgl-core.lib maplibre-native-core-windows-x64-${{ matrix.renderer }}.lib - name: Upload Windows artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: windows-${{ matrix.renderer }}-build + path: | + maplibre-native-core-windows-x64-${{ matrix.renderer }}.lib + + - name: Upload Windows artifact (release) + if: github.event_name == 'workflow_dispatch' 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/linux-ci.yml b/.github/workflows/linux-ci.yml index 7568437a8..e88ca26e9 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -78,6 +78,15 @@ jobs: - name: Install dependencies run: .github/scripts/install-linux-deps + - run: cargo install armerge@2.2.0 + # TODO: use below once + # https://github.com/tux3/armerge/issues/14 + # is fixed + + # - uses: taiki-e/install-action@020705266844b275b711684191e11281be48860c # v2 + # with: + # tool: armerge@2 + - if: matrix.variant.rust run: cargo install cxxbridge-cmd --version 1.0.157 --locked diff --git a/CMakePresets.json b/CMakePresets.json index b60e0de1d..af2d6e6cc 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -70,14 +70,6 @@ "MLN_DARWIN_USE_LIBUV": "OFF" } }, - { - "name": "macos-core", - "inherits": "macos", - "cacheVariables": { - "MLN_CORE_INCLUDE_DEPS": "ON", - "MLN_WITH_GLFW": "OFF" - } - }, { "name": "linux", "hidden": true, @@ -185,7 +177,7 @@ "buildPresets": [ { "name": "macos-core", - "configurePreset": "macos-core", + "configurePreset": "macos", "targets": ["mbgl-core"] }, { diff --git a/platform/linux/cmake/find_static_library.cmake b/cmake/find_static_library.cmake similarity index 100% rename from platform/linux/cmake/find_static_library.cmake rename to cmake/find_static_library.cmake diff --git a/platform/linux/linux.cmake b/platform/linux/linux.cmake index 397e07935..85bf51e4f 100644 --- a/platform/linux/linux.cmake +++ b/platform/linux/linux.cmake @@ -184,7 +184,7 @@ target_link_libraries( # Bundle system provided libraries if(NOT MLN_USE_BUILTIN_ICU AND NOT "${ARMERGE}" STREQUAL "ARMERGE-NOTFOUND") message(STATUS "Found armerge: ${ARMERGE}") - include(${CMAKE_CURRENT_LIST_DIR}/cmake/find_static_library.cmake) + include(${PROJECT_SOURCE_DIR}/cmake/find_static_library.cmake) set(STATIC_LIBS "") find_static_library(STATIC_LIBS NAMES png) diff --git a/platform/macos/macos.cmake b/platform/macos/macos.cmake index 01d98a108..6dc62dfde 100644 --- a/platform/macos/macos.cmake +++ b/platform/macos/macos.cmake @@ -142,3 +142,29 @@ add_test( ${PROJECT_SOURCE_DIR}/test/storage/server.js $ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) + +find_program(ARMERGE NAMES armerge) + +if(NOT "${ARMERGE}" STREQUAL "ARMERGE-NOTFOUND") + message(STATUS "Found armerge: ${ARMERGE}") + include(${PROJECT_SOURCE_DIR}/cmake/find_static_library.cmake) + set(STATIC_LIBS "") + + find_static_library(STATIC_LIBS NAMES png) + find_static_library(STATIC_LIBS NAMES jpeg) + find_static_library(STATIC_LIBS NAMES webp) + find_static_library(STATIC_LIBS NAMES uv uv_a) + + add_custom_command( + TARGET mbgl-core + POST_BUILD + COMMAND armerge --keep-symbols 'mbgl.*' --output libmbgl-core-amalgam.a + $ + $ + $ + $ + $ + ${STATIC_LIBS} + ) + +endif()