Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: add macOS arm runners and update macOS CI in general #2277

Merged
merged 3 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 51 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,20 +405,31 @@ jobs:

macOS:
name: ${{ matrix.name }}
runs-on: macos-12
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- name: macOS
- name: macOS x64
build-framework: OFF
- name: macOS-framework
runner: macos-13
architecture: 'x64'
- name: macOS arm64
build-framework: OFF
runner: macos-14
architecture: 'arm64'
- name: macOS framework x64
build-framework: ON
runner: macos-13
architecture: 'x64'
- name: macOS framework arm64
build-framework: ON
runner: macos-14
architecture: 'arm64'
steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
architecture: 'x64'
- uses: actions/checkout@v4
with:
submodules: recursive
Expand All @@ -427,7 +438,7 @@ jobs:
id: cache
with:
path: ./build/macos/third_party/install
key: ${{ github.job }}-${{ matrix.name }}-${{ hashFiles('./third_party/**') }}
key: ${{ github.job }}-${{ matrix.name }}-${{ hashFiles('./third_party/**') }}-1
- name: disable superbuild on cache hit
if: steps.cache.outputs.cache-hit == 'true'
run: echo "superbuild=-DSUPERBUILD=OFF" >> $GITHUB_ENV && echo "cmake_prefix_path=-DCMAKE_PREFIX_PATH=$(pwd)/build/macos/third_party/install" >> $GITHUB_ENV
Expand All @@ -447,31 +458,44 @@ jobs:
if: ${{ matrix.build-framework == 'ON' }}
uses: actions/upload-artifact@v4
with:
name: mavsdk_server_macos.framework
name: mavsdk_server_macos_${{ matrix.architecture }}.framework
path: ./build/macos/src/mavsdk_server/src/mavsdk_server.framework
retention-days: 2
- name: Upload binary as artefact
if: ${{ matrix.build-framework == 'OFF' }}
uses: actions/upload-artifact@v4
with:
name: mavsdk_server_macos_${{ matrix.architecture }}
path: build/macos/install/bin/mavsdk_server
retention-days: 2
- name: Publish mavsdk_server_macos to github release
if: ${{ startsWith(github.ref, 'refs/tags/v') && matrix.build-framework == 'OFF' }}
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: 'build/macos/install/bin/mavsdk_server'
asset_name: 'mavsdk_server_macos'
file: build/macos/install/bin/mavsdk_server
asset_name: mavsdk_server_macos_${{ matrix.architecture }}
tag: ${{ github.ref }}
overwrite: true

iOS:
name: ${{ matrix.name }}
runs-on: macos-12
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- name: ios
platform: OS64
sdk: iphoneos
- name: ios_simulator
runner: macos-14
- name: ios_simulator_x64
platform: SIMULATOR64
sdk: iphonesimulator
runner: macos-13
- name: ios_simulator_arm64
platform: SIMULATORARM64
sdk: iphonesimulator
runner: macos-14
steps:
- name: Install Python
uses: actions/setup-python@v4
Expand All @@ -486,7 +510,7 @@ jobs:
id: cache
with:
path: ./build/${{ matrix.name }}/third_party/install
key: ${{ github.job }}-${{ matrix.name }}-${{ hashFiles('./third_party/**', './tools/ios.toolchain.cmake') }}
key: ${{ github.job }}-${{ matrix.name }}-${{ hashFiles('./third_party/**', './tools/ios.toolchain.cmake') }}-1
- name: disable superbuild on cache hit
if: steps.cache.outputs.cache-hit == 'true'
run: echo "superbuild=-DSUPERBUILD=OFF" >> $GITHUB_ENV && echo "cmake_prefix_path=-DCMAKE_PREFIX_PATH=$(pwd)/build/${{ matrix.name }}/third_party/install" >> $GITHUB_ENV
Expand All @@ -501,7 +525,7 @@ jobs:
- name: configure
run: cmake $superbuild $cmake_prefix_path -DENABLE_STRICT_TRY_COMPILE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=$(pwd)/tools/ios.toolchain.cmake -DENABLE_BITCODE=Off -DPLATFORM=${{ matrix.platform }} -DDEPLOYMENT_TARGET=14.0 -DBUILD_MAVSDK_SERVER=ON -DBUILD_SHARED_LIBS=OFF -DWERROR=ON -Bbuild/${{ matrix.name }} -H.
- name: build
run: cmake --build build/${{ matrix.name }} -j2
run: cmake --build build/${{ matrix.name }} -j$(nproc)
- uses: actions/upload-artifact@v4
with:
name: mavsdk_server_${{ matrix.name }}.framework
Expand All @@ -511,7 +535,7 @@ jobs:
iOS-XCFramework:
name: iOS XCFramework
needs: [macOS, iOS]
runs-on: macos-12
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -522,12 +546,22 @@ jobs:
path: ./build/ios/src/mavsdk_server/src/mavsdk_server.framework
- uses: actions/download-artifact@v4
with:
name: mavsdk_server_ios_simulator.framework
path: ./build/ios_simulator/src/mavsdk_server/src/mavsdk_server.framework
name: mavsdk_server_ios_simulator_x64.framework
path: ./build/ios_simulator_x64/src/mavsdk_server/src/mavsdk_server.framework
- uses: actions/download-artifact@v4
with:
name: mavsdk_server_macos.framework
path: ./build/macos/src/mavsdk_server/src/mavsdk_server.framework
name: mavsdk_server_ios_simulator_arm64.framework
path: ./build/ios_simulator_arm64/src/mavsdk_server/src/mavsdk_server.framework
- uses: actions/download-artifact@v4
with:
name: mavsdk_server_macos_x64.framework
path: ./build/macos_x64/src/mavsdk_server/src/mavsdk_server.framework
- uses: actions/download-artifact@v4
with:
name: mavsdk_server_macos_arm64.framework
path: ./build/macos_arm64/src/mavsdk_server/src/mavsdk_server.framework
- name: Install tree
run: brew install tree
- name: Package
run: bash ./src/mavsdk_server/tools/package_mavsdk_server_framework.bash
julianoes marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/upload-artifact@v4
Expand Down
52 changes: 43 additions & 9 deletions src/mavsdk_server/tools/package_mavsdk_server_framework.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,61 @@ set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR=${SCRIPT_DIR}/../../../build

IOS_BACKEND_DIR=${BUILD_DIR}/ios/src/mavsdk_server/src
IOS_SIM_BACKEND_DIR=${BUILD_DIR}/ios_simulator/src/mavsdk_server/src
MACOS_BACKEND_DIR=${BUILD_DIR}/macos/src/mavsdk_server/src
IOS_SIM_X64_BACKEND_DIR=${BUILD_DIR}/ios_simulator_x64/src/mavsdk_server/src
IOS_SIM_ARM64_BACKEND_DIR=${BUILD_DIR}/ios_simulator_arm64/src/mavsdk_server/src
IOS_SIM_FAT_BACKEND_DIR=${BUILD_DIR}/ios_simulator/src/mavsdk_server/src

MACOS_X64_BACKEND_DIR=${BUILD_DIR}/macos_x64/src/mavsdk_server/src
MACOS_ARM64_BACKEND_DIR=${BUILD_DIR}/macos_arm64/src/mavsdk_server/src
MACOS_FAT_BACKEND_DIR=${BUILD_DIR}/macos/src/mavsdk_server/src

if [ -d ${BUILD_DIR}/mavsdk_server.xcframework ]; then
echo "${BUILD_DIR}/mavsdk_server.xcframework already exists! Aborting..."
exit 1
fi

echo "Fixing Modules in macOS framework"
ln -sf Versions/Current/Modules ${MACOS_BACKEND_DIR}/mavsdk_server.framework

echo "Creating xcframework..."
xcodebuild -create-xcframework -framework ${IOS_BACKEND_DIR}/mavsdk_server.framework -framework ${IOS_SIM_BACKEND_DIR}/mavsdk_server.framework -framework ${MACOS_BACKEND_DIR}/mavsdk_server.framework -output ${BUILD_DIR}/mavsdk_server.xcframework
echo "Running lipo for simulator"
mkdir -p ${IOS_SIM_FAT_BACKEND_DIR}
cp -a ${IOS_SIM_X64_BACKEND_DIR}/mavsdk_server.framework ${IOS_SIM_FAT_BACKEND_DIR}
xcrun lipo -create -output ${IOS_SIM_FAT_BACKEND_DIR}/mavsdk_server.framework/mavsdk_server \
${IOS_SIM_X64_BACKEND_DIR}/mavsdk_server.framework/mavsdk_server \
${IOS_SIM_ARM64_BACKEND_DIR}/mavsdk_server.framework/mavsdk_server

tree ${IOS_SIM_FAT_BACKEND_DIR}/mavsdk_server.framework

echo "Running codesign for simulator"
xcrun codesign --verbose --sign - ${IOS_SIM_FAT_BACKEND_DIR}/mavsdk_server.framework


tree ${BUILD_DIR}/mavsdk_server.xcframework

echo "Running lipo for macos"
mkdir -p ${MACOS_FAT_BACKEND_DIR}
cp -a ${MACOS_X64_BACKEND_DIR}/mavsdk_server.framework ${MACOS_FAT_BACKEND_DIR}
xcrun lipo -create -output ${MACOS_FAT_BACKEND_DIR}/mavsdk_server.framework/mavsdk_server \
${MACOS_X64_BACKEND_DIR}/mavsdk_server.framework/mavsdk_server \
${MACOS_ARM64_BACKEND_DIR}/mavsdk_server.framework/mavsdk_server

tree ${MACOS_FAT_BACKEND_DIR}/mavsdk_server.framework

echo "Running codesign for macos"
xcrun codesign --verbose --sign - ${MACOS_FAT_BACKEND_DIR}/mavsdk_server.framework/Versions/Current

echo "Creating xcframework..."
xcodebuild -create-xcframework \
-framework ${IOS_BACKEND_DIR}/mavsdk_server.framework \
-framework ${IOS_SIM_FAT_BACKEND_DIR}/mavsdk_server.framework \
-framework ${MACOS_FAT_BACKEND_DIR}/mavsdk_server.framework \
-output ${BUILD_DIR}/mavsdk_server.xcframework

echo "Setting executable bit"
chmod +x ${BUILD_DIR}/mavsdk_server.xcframework/ios-arm64/mavsdk_server.framework/mavsdk_server
chmod +x ${BUILD_DIR}/mavsdk_server.xcframework/ios-x86_64-simulator/mavsdk_server.framework/mavsdk_server
chmod +x ${BUILD_DIR}/mavsdk_server.xcframework/macos-x86_64/mavsdk_server.framework/mavsdk_server
chmod +x ${BUILD_DIR}/mavsdk_server.xcframework/ios-arm64_x86_64-simulator/mavsdk_server.framework/mavsdk_server
chmod +x ${BUILD_DIR}/mavsdk_server.xcframework/macos-arm64_x86_64/mavsdk_server.framework/mavsdk_server

echo "Creating zip archive"
cd ${BUILD_DIR}
zip -9 -y -r mavsdk_server.xcframework.zip mavsdk_server.xcframework

Expand Down
6 changes: 4 additions & 2 deletions third_party/openssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include(ExternalProject)

message(STATUS "Preparing external project \"openssl\"")

set(OPENSSL_VERSION 3.0.9)
set(OPENSSL_VERSION 3.3.0)

if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(OPENSSL_BUILD_TYPE "--debug")
Expand Down Expand Up @@ -35,7 +35,7 @@ if(ANDROID)
URL https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
PREFIX openssl
PATCH_COMMAND patch -p 0 < ${PROJECT_SOURCE_DIR}/dockcross-android.patch
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ANDROID_NDK=$ENV{CROSS_ROOT} <SOURCE_DIR>/Configure --sysroot=$ENV{CROSS_ROOT}/sysroot ${OPENSSL_PLATFORM} --prefix=${CMAKE_INSTALL_PREFIX} ${OPENSSL_BUILD_TYPE} no-shared
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ANDROID_NDK=$ENV{CROSS_ROOT} <SOURCE_DIR>/Configure --sysroot=$ENV{CROSS_ROOT}/sysroot ${OPENSSL_PLATFORM} --prefix=${CMAKE_INSTALL_PREFIX} ${OPENSSL_BUILD_TYPE} no-asm no-shared
BUILD_COMMAND make
INSTALL_COMMAND make install_sw
)
Expand All @@ -45,6 +45,8 @@ elseif(IOS)
set(OPENSSL_PLATFORM "ios64-xcrun")
elseif(${PLATFORM} STREQUAL "SIMULATOR64")
set(OPENSSL_PLATFORM "iossimulator-xcrun")
elseif(${PLATFORM} STREQUAL "SIMULATORARM64")
set(OPENSSL_PLATFORM "iossimulator-arm64-xcrun")
else()
message(FATAL_ERROR "Unexpected PLATFORM: \"${PLATFORM}\"")
endif()
Expand Down
Loading