Skip to content

Commit 0983043

Browse files
committed
Build OpenCV's OpenEXR and enable TinyXML2 dependency for iOS platforms
1 parent b8a0688 commit 0983043

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ jobs:
1515
platformArch: [macOS, iOS, iOS_Simulator, iOS_Simulator_M1, macCatalyst, macCatalyst_M1] # macOS_M1
1616
steps:
1717
- uses: actions/checkout@v3
18+
1819
- name: Setup cmake
1920
uses: jwlawson/[email protected]
2021
with:
2122
cmake-version: '3.23.x'
23+
2224
# - name: Setup Python
2325
# uses: actions/setup-python@v4
2426
# with:
@@ -30,7 +32,7 @@ jobs:
3032
- name: Build dependencies
3133
id: build_dependencies
3234
run: ./build_deps.sh ${{ matrix.platformArch }}
33-
if: ${{ false && startsWith(matrix.platformArch, 'macOS') }}
35+
if: ${{ true }}
3436

3537
- name: Archive dependencies
3638
run: tar cJf ros2deps_${{ matrix.platformArch }}.tar.xz ros2_${{ matrix.platformArch }}/
@@ -47,7 +49,7 @@ jobs:
4749
- name: Download and extract prebuilt dependencies
4850
id: download_dependencies
4951
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
50-
if: ${{ true && steps.build_dependencies.outcome != 'success' && startsWith(matrix.platformArch, 'macOS') }}
52+
if: ${{ false && steps.build_dependencies.outcome != 'success' && startsWith(matrix.platformArch, 'macOS') }}
5153

5254
# On macOS, only build ROS2 if either building or downloading dependencies succeeds
5355
- name: Build ROS2

build_deps.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,37 @@ function setupPlatform() {
8686
platformBasicConfigureArgs+=(--host=aarch64-apple-darwin)
8787
platformBasicConfigureArgsPixmanCairo+=(--host=arm-apple-darwin) # For pixman and cairo we must use arm-apple thank to https://gist.github.com/jvcleave/9d78de9bb27434bde2b0c3a1af355d9c
8888
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;
89+
8990
"iOS_Simulator")
90-
target=x86_64
91+
targetArch=x86_64
9192
boostArch=ia64
9293
targetSysroot=`xcodebuild -version -sdk iphonesimulator Path`
9394
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;
95+
96+
"iOS_Simulator_M1")
97+
targetArch=arm64
98+
boostArch=arm
99+
targetSysroot=`xcodebuild -version -sdk iphonesimulator Path`
100+
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;
101+
102+
"macCatalyst")
103+
targetArch=x86_64
104+
boostArch=ia64
105+
targetSysroot=`xcodebuild -version -sdk macosx Path`
106+
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;
107+
108+
"macCatalyst_M1")
109+
targetArch=arm64
110+
boostArch=arm
111+
targetSysroot=`xcodebuild -version -sdk macosx Path`
112+
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;
113+
94114
"macOS")
95115
targetArch=x86_64
96116
boostArch=ia64
97117
targetSysroot=`xcodebuild -version -sdk macosx Path`
98118
platformExtraCMakeArgs+=(-DCMAKE_OSX_ARCHITECTURES=$targetArch);;
119+
99120
"macOS_M1")
100121
targetArch=arm64
101122
boostArch=arm
@@ -107,7 +128,16 @@ function setupPlatform() {
107128
}
108129

109130
function setCompilerFlags() {
110-
export CFLAGS="-isysroot $targetSysroot -arch $targetArch -I$ros2SystemDependenciesPath/include/"
131+
case $targetPlatform in
132+
"macCatalyst")
133+
export CFLAGS="-isysroot $targetSysroot -target x86_64-apple-ios14.1-macabi -I$ros2SystemDependenciesPath/include/";;
134+
135+
"macCatalyst_M1")
136+
export CFLAGS="-isysroot $targetSysroot -target arm64-apple-ios14.1-macabi -I$ros2SystemDependenciesPath/include/";;
137+
138+
*)
139+
export CFLAGS="-isysroot $targetSysroot -arch $targetArch -I$ros2SystemDependenciesPath/include/";;
140+
esac
111141
export CXXFLAGS=$CFLAGS
112142
export CPPFLAGS=$CFLAGS # Without this, encounter error ZLIB_VERNUM != PNG_ZLIB_VERNUM when building libpng
113143
}
@@ -333,7 +363,8 @@ function buildPCL() {
333363
function buildOpenCV() {
334364
echo "Build OpenCV"
335365
cd $ros2DependenciesSourceExtractionPath/opencv-4.6.0
336-
buildCMake -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_python2=OFF -DBUILD_JAVA=OFF -DBUILD_OBJC=OFF -DBUILD_ZLIB=NO
366+
# https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html
367+
buildCMake -DCMAKE_BUILD_TYPE=Release -DBUILD_opencv_python2=OFF -DBUILD_JAVA=OFF -DBUILD_OBJC=OFF -DBUILD_ZLIB=NO -DBUILD_OPENEXR=YES
337368
}
338369

339370
function buildAll() {
@@ -384,8 +415,8 @@ case $targetPlatform in
384415
buildBoost
385416
buildOpenCV;;
386417

387-
*) # Build dependencies for ROS2 cartographer package
388-
echo "We currently do not build any dependencies for iOS";;
418+
*) # Build useful dependencies for iOS
419+
buildTinyXML2;;
389420
esac
390421

391422
cd $REPO_ROOT

0 commit comments

Comments
 (0)