16
16
#
17
17
# Builds and runs the tests, meant to be used on a bash environment.
18
18
19
- usage (){
19
+ usage () {
20
20
echo " Usage: $0 [options]
21
21
options:
22
22
-b, build path default: ios_unity
@@ -30,15 +30,20 @@ usage(){
30
30
31
31
set -e
32
32
33
- readonly SUPPORTED_PLATFORMS=(device) # simulator) only support device arch for now
34
- readonly SUPPORTED_ARCHITECTURES=" arm64;armv7" # ;x86_64;i386" only support device arch for now
35
- # readonly DEVICE_ARCHITECTURES="arm64;armv7" only support device arch for now
36
- # readonly SIMULATOR_ARCHITECTURES="arm64;x86_64;i386" only support device arch for now
33
+ readonly SUPPORTED_PLATFORMS=(device simulator)
34
+ readonly SUPPORTED_ARCHITECTURES=(arm64 armv7 x86_64 i386)
35
+ readonly DEVICE_ARCHITECTURES=(arm64 armv7)
36
+ readonly SIMULATOR_ARCHITECTURES=(arm64 x86_64 i386)
37
+ readonly DEVICE_IOS_PLATFORM_LOCATION=" iPhoneOS.platform"
38
+ readonly SIMULATOR_IOS_PLATFORM_LOCATION=" iPhoneSimulator.platform"
39
+ readonly DEVICE_OSX_SYSROOT=" iphoneos"
40
+ readonly SIMULATOR_OSX_SYSROOT=" iphonesimulator"
37
41
38
42
# build default value
39
43
buildpath=" ios_unity"
40
44
sourcepath=" ."
41
45
platforms=(" ${SUPPORTED_PLATFORMS[@]} " )
46
+ architectures=(" ${SUPPORTED_ARCHITECTURES[@]} " )
42
47
cmake_extra=" "
43
48
44
49
# Enable utf8 output
@@ -48,57 +53,117 @@ export LANG=en_US.UTF-8
48
53
IFS=' ,' # split options on ',' characters
49
54
while getopts " hb:s:p:a:c:" opt; do
50
55
case $opt in
51
- h)
52
- usage
53
- exit 0
54
- ;;
55
- b)
56
- buildpath=$OPTARG
57
- ;;
58
- s)
59
- sourcepath=$OPTARG
60
- if [[ ! -d " ${sourcepath} " ]]; then
61
- echo " Source path ${sourcepath} not found."
56
+ h)
57
+ usage
58
+ exit 0
59
+ ;;
60
+ b)
61
+ buildpath=$OPTARG
62
+ ;;
63
+ s)
64
+ sourcepath=$OPTARG
65
+ if [[ ! -d " ${sourcepath} " ]]; then
66
+ echo " Source path ${sourcepath} not found."
67
+ exit 2
68
+ fi
69
+ ;;
70
+ p)
71
+ platforms=($OPTARG )
72
+ for platform in ${platforms[@]} ; do
73
+ if [[ ! " ${SUPPORTED_PLATFORMS[@]} " =~ " ${platform} " ]]; then
74
+ echo " invalid platform: ${platform} "
75
+ echo " Supported platforms are: ${SUPPORTED_PLATFORMS[@]} "
62
76
exit 2
63
77
fi
64
- ;;
65
- p)
66
- platforms=($OPTARG )
67
- for platform in ${platforms[@]} ; do
68
- if [[ ! " ${SUPPORTED_PLATFORMS[@]} " =~ " ${platform} " ]]; then
69
- echo " invalid platform: ${platform} "
70
- echo " Supported platforms are: ${SUPPORTED_PLATFORMS[@]} "
71
- exit 2
72
- fi
73
- done
74
- ;;
75
- a)
76
- architectures=($OPTARG )
77
- for arch in ${architectures[@]} ; do
78
- if [[ ! " ${SUPPORTED_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
79
- echo " invalid architecture: ${arch} "
80
- echo " Supported architectures are: ${SUPPORTED_ARCHITECTURES[@]} "
81
- exit 2
82
- fi
83
- done
84
- ;;
85
- c)
86
- cmake_extra=$OPTARG
87
- ;;
88
- * )
89
- echo " unknown parameter"
90
- exit 2
91
- ;;
78
+ done
79
+ ;;
80
+ a)
81
+ architectures=($OPTARG )
82
+ for arch in ${architectures[@]} ; do
83
+ if [[ ! " ${SUPPORTED_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
84
+ echo " invalid architecture: ${arch} "
85
+ echo " Supported architectures are: ${SUPPORTED_ARCHITECTURES[@]} "
86
+ exit 2
87
+ fi
88
+ done
89
+ ;;
90
+ c)
91
+ cmake_extra=$OPTARG
92
+ ;;
93
+ * )
94
+ echo " unknown parameter"
95
+ exit 2
96
+ ;;
92
97
esac
93
98
done
94
99
echo " *********************** Build Unity iOS SDK *******************************"
95
100
echo " build path: ${buildpath} "
96
101
echo " source path: ${sourcepath} "
97
102
echo " build platforms: ${platforms[@]} "
103
+ echo " architectures: ${architectures[@]} "
98
104
echo " cmake extras: ${cmake_extra} "
99
105
echo " ***************************************************************************"
100
- sourcepath=$( cd ${sourcepath} && pwd) # full path
101
- buildpath=$( mkdir -p ${buildpath} && cd ${buildpath} && pwd) # full path
106
+ sourcepath=$( cd ${sourcepath} && pwd) # full path
107
+ buildpath=$( mkdir -p ${buildpath} && cd ${buildpath} && pwd) # full path
108
+
109
+ ios_location=" "
110
+ osx_sysroot=" "
111
+ xcode_platforms=" "
112
+ cmake_archs=" "
113
+ # build necessary cmake args
114
+ if [[ " ${platforms[@]} " =~ " device " ]]; then
115
+ echo " Build cmake args for device"
116
+ ios_location=${DEVICE_IOS_PLATFORM_LOCATION}
117
+ osx_sysroot=${DEVICE_OSX_SYSROOT}
118
+ xcode_platforms=" -${DEVICE_OSX_SYSROOT} "
119
+ for arch in ${architectures[@]} ; do
120
+ if [[ " ${DEVICE_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
121
+ if [ " $cmake_archs " == " " ]; then
122
+ cmake_archs=${arch}
123
+ else
124
+ cmake_archs=" ${cmake_archs} ;${arch} "
125
+ fi
126
+ fi
127
+ done
128
+ fi
129
+
130
+ if [[ " ${platforms[@]} " =~ " simulator " ]]; then
131
+ echo " Build cmake args for simulator"
132
+ if [ " $ios_location " == " " ]; then
133
+ ios_location=${SIMULATOR_IOS_PLATFORM_LOCATION}
134
+ else
135
+ ios_location=" ${ios_location} ;${SIMULATOR_IOS_PLATFORM_LOCATION} "
136
+ fi
137
+ if [ " $osx_sysroot " == " " ]; then
138
+ osx_sysroot=${SIMULATOR_OSX_SYSROOT}
139
+ else
140
+ osx_sysroot=" ${osx_sysroot} ;${SIMULATOR_OSX_SYSROOT} "
141
+ fi
142
+ if [ " $xcode_platforms " == " " ]; then
143
+ xcode_platforms=" -${SIMULATOR_OSX_SYSROOT} "
144
+ else
145
+ xcode_platforms=" ${xcode_platforms} ;-${SIMULATOR_OSX_SYSROOT} "
146
+ fi
147
+
148
+ for arch in ${architectures[@]} ; do
149
+ if [[ " ${SIMULATOR_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
150
+ if [ " $cmake_archs " == " " ]; then
151
+ cmake_archs=${arch}
152
+ else
153
+ if [[ ! " ${DEVICE_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
154
+ cmake_archs=" ${cmake_archs} ;${arch} "
155
+ fi
156
+ fi
157
+ fi
158
+ done
159
+ fi
160
+
161
+ echo " *********************** CMake Args *******************************"
162
+ echo " ios_location: ${ios_location} "
163
+ echo " osx_sysroot: ${osx_sysroot} "
164
+ echo " xcode_platforms: ${xcode_platforms} "
165
+ echo " cmake_archs: ${cmake_archs} "
166
+ echo " ***************************************************************************"
102
167
103
168
# Stop display commands being run.
104
169
set +x
@@ -107,17 +172,17 @@ set +x
107
172
FIRST_FAILED_EXITCODE=0
108
173
109
174
function check_exit_code {
110
- if [ " $1 " -ne " 0" ] && [ " $FIRST_FAILED_EXITCODE " -eq 0 ]; then
111
- FIRST_FAILED_EXITCODE=$1
112
- fi
175
+ if [ " $1 " -ne " 0" ] && [ " $FIRST_FAILED_EXITCODE " -eq 0 ]; then
176
+ FIRST_FAILED_EXITCODE=$1
177
+ fi
113
178
}
114
179
115
180
CMAKE_OPTIONS=" -DFIREBASE_UNITY_BUILD_TESTS=ON"
116
181
CMAKE_OPTIONS=" ${CMAKE_OPTIONS} -DFIREBASE_CPP_BUILD_STUB_TESTS=ON" # enable a stub gtest target to get abseil-cpp working.
117
182
118
183
if [ -d " ../firebase-cpp-sdk" ]; then
119
- REAL_PATH=` python -c " import os; print(os.path.realpath('../firebase-cpp-sdk'))" `
120
- CMAKE_OPTIONS=" ${CMAKE_OPTIONS} -DFIREBASE_CPP_SDK_DIR=$REAL_PATH "
184
+ REAL_PATH=$( python -c " import os; print(os.path.realpath('../firebase-cpp-sdk'))" )
185
+ CMAKE_OPTIONS=" ${CMAKE_OPTIONS} -DFIREBASE_CPP_SDK_DIR=$REAL_PATH "
121
186
fi
122
187
123
188
# Display commands being run.
@@ -128,25 +193,28 @@ mkdir -p "$buildpath"
128
193
129
194
pushd " $buildpath "
130
195
131
- # Configure cmake with option value
132
- cmake $sourcepath \
196
+ # Configure cmake with option value
197
+ cmake $sourcepath \
133
198
-DCMAKE_TOOLCHAIN_FILE=$sourcepath /cmake/unity_ios.cmake \
134
- -DCMAKE_OSX_ARCHITECTURES=$SUPPORTED_ARCHITECTURES \
199
+ -DCMAKE_OSX_ARCHITECTURES=$cmake_archs \
200
+ -DCMAKE_OSX_SYSROOT=$osx_sysroot \
201
+ -DCMAKE_XCODE_EFFECTIVE_PLATFORMS=$xcode_platforms \
202
+ -DIOS_PLATFORM_LOCATION=$ios_location \
135
203
-DUNITY_ROOT_DIR=${UNITY_ROOT_DIR} \
136
204
$CMAKE_OPTIONS \
137
205
$cmake_extra
138
- check_exit_code $?
206
+ check_exit_code $?
139
207
140
- # Build the SDK
141
- make
142
- check_exit_code $?
208
+ # Build the SDK
209
+ make
210
+ check_exit_code $?
143
211
144
- # Package build output into zip
145
- cpack .
146
- check_exit_code $?
212
+ # Package build output into zip
213
+ cpack .
214
+ check_exit_code $?
147
215
148
- # Stop display commands being run.
149
- set +x
216
+ # Stop display commands being run.
217
+ set +x
150
218
151
219
popd
152
220
0 commit comments