Skip to content

Commit

Permalink
Build OpenCV's OpenEXR and enable TinyXML2 dependency for iOS platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
light-tech committed Oct 3, 2022
1 parent b8a0688 commit 0983043
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ jobs:
platformArch: [macOS, iOS, iOS_Simulator, iOS_Simulator_M1, macCatalyst, macCatalyst_M1] # macOS_M1
steps:
- uses: actions/checkout@v3

- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.23.x'

# - name: Setup Python
# uses: actions/setup-python@v4
# with:
Expand All @@ -30,7 +32,7 @@ jobs:
- name: Build dependencies
id: build_dependencies
run: ./build_deps.sh ${{ matrix.platformArch }}
if: ${{ false && startsWith(matrix.platformArch, 'macOS') }}
if: ${{ true }}

- name: Archive dependencies
run: tar cJf ros2deps_${{ matrix.platformArch }}.tar.xz ros2_${{ matrix.platformArch }}/
Expand All @@ -47,7 +49,7 @@ jobs:
- name: Download and extract prebuilt dependencies
id: download_dependencies
run: curl -OL https://github.com/light-tech/ROS2-On-iOS/releases/download/humble-macos/ros2deps_${{ matrix.platformArch }}.tar.xz && tar xzf ros2deps_${{ matrix.platformArch }}.tar.xz
if: ${{ true && steps.build_dependencies.outcome != 'success' && startsWith(matrix.platformArch, 'macOS') }}
if: ${{ false && steps.build_dependencies.outcome != 'success' && startsWith(matrix.platformArch, 'macOS') }}

# On macOS, only build ROS2 if either building or downloading dependencies succeeds
- name: Build ROS2
Expand Down
41 changes: 36 additions & 5 deletions build_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,37 @@ function setupPlatform() {
platformBasicConfigureArgs+=(--host=aarch64-apple-darwin)
platformBasicConfigureArgsPixmanCairo+=(--host=arm-apple-darwin) # For pixman and cairo we must use arm-apple thank to https://gist.github.com/jvcleave/9d78de9bb27434bde2b0c3a1af355d9c
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;

"iOS_Simulator")
target=x86_64
targetArch=x86_64
boostArch=ia64
targetSysroot=`xcodebuild -version -sdk iphonesimulator Path`
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;

"iOS_Simulator_M1")
targetArch=arm64
boostArch=arm
targetSysroot=`xcodebuild -version -sdk iphonesimulator Path`
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;

"macCatalyst")
targetArch=x86_64
boostArch=ia64
targetSysroot=`xcodebuild -version -sdk macosx Path`
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;

"macCatalyst_M1")
targetArch=arm64
boostArch=arm
targetSysroot=`xcodebuild -version -sdk macosx Path`
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;

"macOS")
targetArch=x86_64
boostArch=ia64
targetSysroot=`xcodebuild -version -sdk macosx Path`
platformExtraCMakeArgs+=(-DCMAKE_OSX_ARCHITECTURES=$targetArch);;

"macOS_M1")
targetArch=arm64
boostArch=arm
Expand All @@ -107,7 +128,16 @@ function setupPlatform() {
}

function setCompilerFlags() {
export CFLAGS="-isysroot $targetSysroot -arch $targetArch -I$ros2SystemDependenciesPath/include/"
case $targetPlatform in
"macCatalyst")
export CFLAGS="-isysroot $targetSysroot -target x86_64-apple-ios14.1-macabi -I$ros2SystemDependenciesPath/include/";;

"macCatalyst_M1")
export CFLAGS="-isysroot $targetSysroot -target arm64-apple-ios14.1-macabi -I$ros2SystemDependenciesPath/include/";;

*)
export CFLAGS="-isysroot $targetSysroot -arch $targetArch -I$ros2SystemDependenciesPath/include/";;
esac
export CXXFLAGS=$CFLAGS
export CPPFLAGS=$CFLAGS # Without this, encounter error ZLIB_VERNUM != PNG_ZLIB_VERNUM when building libpng
}
Expand Down Expand Up @@ -333,7 +363,8 @@ function buildPCL() {
function buildOpenCV() {
echo "Build OpenCV"
cd $ros2DependenciesSourceExtractionPath/opencv-4.6.0
buildCMake -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_python2=OFF -DBUILD_JAVA=OFF -DBUILD_OBJC=OFF -DBUILD_ZLIB=NO
# https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html
buildCMake -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_python2=OFF -DBUILD_JAVA=OFF -DBUILD_OBJC=OFF -DBUILD_ZLIB=NO -DBUILD_OPENEXR=YES
}

function buildAll() {
Expand Down Expand Up @@ -384,8 +415,8 @@ case $targetPlatform in
buildBoost
buildOpenCV;;

*) # Build dependencies for ROS2 cartographer package
echo "We currently do not build any dependencies for iOS";;
*) # Build useful dependencies for iOS
buildTinyXML2;;
esac

cd $REPO_ROOT

0 comments on commit 0983043

Please sign in to comment.