diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f444d216d8..e5cead1dea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 - uses: actions/upload-artifact@v4 diff --git a/src/mavsdk_server/tools/package_mavsdk_server_framework.bash b/src/mavsdk_server/tools/package_mavsdk_server_framework.bash index 1fd9f247db..88dd8e5c98 100644 --- a/src/mavsdk_server/tools/package_mavsdk_server_framework.bash +++ b/src/mavsdk_server/tools/package_mavsdk_server_framework.bash @@ -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 diff --git a/third_party/openssl/CMakeLists.txt b/third_party/openssl/CMakeLists.txt index 1a40a6f7a7..5b49df8c04 100644 --- a/third_party/openssl/CMakeLists.txt +++ b/third_party/openssl/CMakeLists.txt @@ -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") @@ -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} /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} /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 ) @@ -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()