Skip to content

Commit

Permalink
Add option to build macos framework
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasVautherin committed Nov 24, 2020
1 parent 5e8aafa commit 20cc4d2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,23 @@ jobs:
tag: ${{ github.ref }}
overwrite: true

macOS-framework:
name: macOS-framework
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: configure
run: cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=build/release/install -DBUILD_BACKEND=ON -DBUILD_SHARED_LIBS=OFF -DMACOS_FRAMEWORK=ON -DWERROR=OFF -j 2 -Bbuild/macos -H.
- name: build
run: cmake --build build/macos -j 2 --target install
- uses: actions/upload-artifact@v2
with:
name: mavsdk_server_macos.framework
path: ./build/macos/src/backend/src/mavsdk_server.framework
retention-days: 2

iOS:
name: iOS
runs-on: macos-latest
Expand Down Expand Up @@ -406,7 +423,7 @@ jobs:

iOS-XCFramework:
name: iOS XCFramework
needs: [iOS, iOS-Simulator]
needs: [macOS-framework, iOS, iOS-Simulator]
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -420,6 +437,10 @@ jobs:
with:
name: mavsdk_server_ios_simulator.framework
path: ./build/ios_simulator/src/backend/src/mavsdk_server.framework
- uses: actions/download-artifact@v2
with:
name: mavsdk_server_macos.framework
path: ./build/macos/src/backend/src/mavsdk_server.framework
- name: Package
run: bash ./src/backend/tools/package_backend_framework.bash
- uses: actions/upload-artifact@v2
Expand Down
6 changes: 3 additions & 3 deletions src/backend/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ set(BACKEND_SOURCES
grpc_server.cpp
)

if(IOS)
if(IOS OR (APPLE AND MACOS_FRAMEWORK))
set_property(SOURCE module.modulemap
PROPERTY MACOSX_PACKAGE_LOCATION "Modules")

list(APPEND BACKEND_SOURCES module.modulemap)
endif()

if(IOS OR ANDROID)
if(IOS OR ANDROID OR (APPLE AND MACOS_FRAMEWORK))
add_library(mavsdk_server SHARED ${BACKEND_SOURCES})
else()
add_library(mavsdk_server ${BACKEND_SOURCES})
Expand Down Expand Up @@ -116,7 +116,7 @@ if(NOT IOS AND NOT ANDROID)
endif()

# iOS builds mavsdk_server.framework
if(IOS)
if(IOS OR (APPLE AND MACOS_FRAMEWORK))
set_target_properties(mavsdk_server PROPERTIES
FRAMEWORK TRUE
BUILD_WITH_INSTALL_RPATH TRUE
Expand Down
6 changes: 5 additions & 1 deletion src/backend/tools/package_backend_framework.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR=${SCRIPT_DIR}/../../../build
IOS_BACKEND_DIR=${BUILD_DIR}/ios/src/backend/src
IOS_SIM_BACKEND_DIR=${BUILD_DIR}/ios_simulator/src/backend/src
MACOS_BACKEND_DIR=${BUILD_DIR}/macos/src/backend/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 -s 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 -output ${BUILD_DIR}/mavsdk_server.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

cd ${BUILD_DIR}
zip -9 -r mavsdk_server.zip mavsdk_server.xcframework
Expand Down

0 comments on commit 20cc4d2

Please sign in to comment.