Skip to content

Commit 0c4946e

Browse files
committed
Use array to simplify commands to build dependencies
1 parent 295b8b6 commit 0c4946e

File tree

2 files changed

+20
-42
lines changed

2 files changed

+20
-42
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
timeout-minutes: 1200
1212
strategy:
1313
matrix:
14-
platformArch: [macOS, iOS, iOS_Simulator, iOS_Simulator_M1, macCatalyst, macCatalyst_M1]
14+
platformArch: [macOS, iOS] # , iOS_Simulator, iOS_Simulator_M1, macCatalyst, macCatalyst_M1]
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Setup cmake

build_deps.sh

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export PATH=$ros2SystemDependenciesPath/bin:$PATH
2020
export PKG_CONFIG=$ros2SystemDependenciesPath/bin/pkg-config
2121
export PKG_CONFIG_PATH=$ros2SystemDependenciesPath/lib/pkgconfig
2222

23+
platformExtraCMakeArgs=(-DCMAKE_INSTALL_PREFIX=$ros2SystemDependenciesPath -DCMAKE_PREFIX_PATH=$ros2SystemDependenciesPath)
24+
platformBasicConfigureArgs=(--prefix=$ros2SystemDependenciesPath) # Configure args for regular situation
25+
platformBasicConfigureArgsPixmanCairo=(--prefix=$ros2SystemDependenciesPath) # Special configure args for pixman and cairo
26+
2327
function getSource() {
2428
mkdir -p $ros2DependenciesSourceDownloadPath
2529
cd $ros2DependenciesSourceDownloadPath
@@ -78,17 +82,17 @@ function setupPlatform() {
7882
"iOS")
7983
targetArch=arm64
8084
targetSysroot=`xcodebuild -version -sdk iphoneos Path`
81-
targetHostTripleForPixmanAndCairo=arm-apple-darwin # For pixman and cairo we must use arm-apple and not arm64-apple thank to https://gist.github.com/jvcleave/9d78de9bb27434bde2b0c3a1af355d9c
82-
targetHostTriple=aarch64-apple-darwin
83-
platformExtraCMakeArgs=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;
85+
platformBasicConfigureArgs+=(--host=aarch64-apple-darwin)
86+
platformBasicConfigureArgsPixmanCairo+=(--host=arm-apple-darwin) # For pixman and cairo we must use arm-apple thank to https://gist.github.com/jvcleave/9d78de9bb27434bde2b0c3a1af355d9c
87+
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;
8488
"iOS_Simulator")
8589
target=x86_64
8690
targetSysroot=`xcodebuild -version -sdk iphonesimulator Path`
87-
platformExtraCMakeArgs=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;
91+
platformExtraCMakeArgs+=(-DCMAKE_TOOLCHAIN_FILE=$REPO_ROOT/cmake/$targetPlatform.cmake);;
8892
"macOS")
8993
targetArch=x86_64
9094
targetSysroot=`xcodebuild -version -sdk macosx Path`
91-
platformExtraCMakeArgs=(-DCMAKE_OSX_ARCHITECTURES=$targetArch);;
95+
platformExtraCMakeArgs+=(-DCMAKE_OSX_ARCHITECTURES=$targetArch);;
9296
esac
9397
}
9498

@@ -100,50 +104,20 @@ function setCompilerFlags() {
100104

101105
function buildCMake() {
102106
rm -rf _build && mkdir _build && cd _build
103-
cmake -DCMAKE_INSTALL_PREFIX=$ros2SystemDependenciesPath -DCMAKE_PREFIX_PATH=$ros2SystemDependenciesPath "${platformExtraCMakeArgs[@]}" "$@" .. # >/dev/null 2>&1
107+
cmake "${platformExtraCMakeArgs[@]}" "$@" .. # >/dev/null 2>&1
104108
cmake --build . --target install # >/dev/null 2>&1 --parallel 1
105109
}
106110

107-
function configureThenMakeArm() {
108-
setCompilerFlags
109-
110-
if [ -z "$targetHostTripleForPixmanAndCairo" ]
111-
then
112-
./configure --prefix=$ros2SystemDependenciesPath "$@" # >/dev/null 2>&1
113-
else
114-
./configure --prefix=$ros2SystemDependenciesPath --host=$targetHostTripleForPixmanAndCairo "$@" # >/dev/null 2>&1
115-
fi
116-
117-
make && make install # >/dev/null 2>&1
118-
119-
export -n CFLAGS
120-
export -n CXXFLAGS
121-
}
122-
123111
function configureThenMake() {
124112
setCompilerFlags
125-
126-
if [ -z "$targetHostTriple" ]
127-
then
128-
./configure --prefix=$ros2SystemDependenciesPath "$@" # >/dev/null 2>&1
129-
else
130-
./configure --prefix=$ros2SystemDependenciesPath --host=$targetHostTriple "$@" # >/dev/null 2>&1
131-
fi
132-
113+
./configure "${platformBasicConfigureArgs[@]}" "$@" # >/dev/null 2>&1
133114
make && make install #>/dev/null 2>&1
134-
135-
export -n CFLAGS
136-
export -n CXXFLAGS
137115
}
138116

139-
function configureThenMakeNoHost() {
117+
function configureThenMakeArm() {
140118
setCompilerFlags
141-
142-
./configure --prefix=$ros2SystemDependenciesPath "$@" # >/dev/null 2>&1
143-
make && make install #>/dev/null 2>&1
144-
145-
export -n CFLAGS
146-
export -n CXXFLAGS
119+
./configure "${platformBasicConfigureArgsPixmanCairo[@]}" "$@" # >/dev/null 2>&1
120+
make && make install # >/dev/null 2>&1
147121
}
148122

149123
function buildHostTools() {
@@ -172,7 +146,11 @@ function buildHostTools() {
172146
function buildZlib() {
173147
echo "Build zlib"
174148
cd $ros2DependenciesSourceExtractionPath/zlib-1.2.12
175-
configureThenMakeNoHost # Note that zlib's configure does not set --host
149+
150+
# Note that zlib's configure does not set --host but relies on compiler flags environment variables
151+
setCompilerFlags
152+
./configure --prefix=$ros2SystemDependenciesPath "$@" # >/dev/null 2>&1
153+
make && make install #>/dev/null 2>&1
176154
}
177155

178156
function buildTinyXML2() {

0 commit comments

Comments
 (0)