OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # Helper to do build so you don't have to remember all the steps/args. | 3 # Helper to do build so you don't have to remember all the steps/args. |
4 | 4 |
5 | 5 |
6 set -eu | 6 set -eu |
7 | 7 |
8 # Some base locations. | 8 # Some base locations. |
9 readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")") | 9 readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")") |
10 readonly ProtoRootDir="${ScriptDir}/../.." | 10 readonly ProtoRootDir="${ScriptDir}/../.." |
(...skipping 19 matching lines...) Expand all Loading... |
30 Run generate_descriptor_proto.sh to regenerate all the checked in | 30 Run generate_descriptor_proto.sh to regenerate all the checked in |
31 proto sources. | 31 proto sources. |
32 -j #, --jobs # | 32 -j #, --jobs # |
33 Force the number of parallel jobs (useful for debugging build issues). | 33 Force the number of parallel jobs (useful for debugging build issues). |
34 --core-only | 34 --core-only |
35 Skip some of the core protobuf build/checks to shorten the build time. | 35 Skip some of the core protobuf build/checks to shorten the build time. |
36 --skip-xcode | 36 --skip-xcode |
37 Skip the invoke of Xcode to test the runtime on both iOS and OS X. | 37 Skip the invoke of Xcode to test the runtime on both iOS and OS X. |
38 --skip-xcode-ios | 38 --skip-xcode-ios |
39 Skip the invoke of Xcode to test the runtime on iOS. | 39 Skip the invoke of Xcode to test the runtime on iOS. |
40 --skip-xcode-debug | |
41 Skip the Xcode Debug configuration. | |
42 --skip-xcode-release | |
43 Skip the Xcode Release configuration. | |
44 --skip-xcode-osx | 40 --skip-xcode-osx |
45 Skip the invoke of Xcode to test the runtime on OS X. | 41 Skip the invoke of Xcode to test the runtime on OS X. |
46 --skip-objc-conformance | 42 --skip-objc-conformance |
47 Skip the Objective C conformance tests (run on OS X). | 43 Skip the Objective C conformance tests (run on OS X). |
48 --xcode-quiet | |
49 Pass -quiet to xcodebuild. | |
50 | 44 |
51 EOF | 45 EOF |
52 } | 46 } |
53 | 47 |
54 header() { | 48 header() { |
55 echo "" | 49 echo "" |
56 echo "========================================================================
" | 50 echo "========================================================================
" |
57 echo " ${@}" | 51 echo " ${@}" |
58 echo "========================================================================
" | 52 echo "========================================================================
" |
59 } | 53 } |
60 | 54 |
61 # Thanks to libtool, builds can fail in odd ways and since it eats some output | 55 # Thanks to libtool, builds can fail in odd ways and since it eats some output |
62 # it can be hard to spot, so force error output if make exits with a non zero. | 56 # it can be hard to spot, so force error output if make exits with a non zero. |
63 wrapped_make() { | 57 wrapped_make() { |
64 set +e # Don't stop if the command fails. | 58 set +e # Don't stop if the command fails. |
65 make $* | 59 make $* |
66 MAKE_EXIT_STATUS=$? | 60 MAKE_EXIT_STATUS=$? |
67 if [ ${MAKE_EXIT_STATUS} -ne 0 ]; then | 61 if [ ${MAKE_EXIT_STATUS} -ne 0 ]; then |
68 echo "Error: 'make $*' exited with status ${MAKE_EXIT_STATUS}" | 62 echo "Error: 'make $*' exited with status ${MAKE_EXIT_STATUS}" |
69 exit ${MAKE_EXIT_STATUS} | 63 exit ${MAKE_EXIT_STATUS} |
70 fi | 64 fi |
71 set -e | 65 set -e |
72 } | 66 } |
73 | 67 |
74 NUM_MAKE_JOBS=$(/usr/sbin/sysctl -n hw.ncpu) | 68 NUM_MAKE_JOBS=$(/usr/sbin/sysctl -n hw.ncpu) |
75 if [[ "${NUM_MAKE_JOBS}" -lt 2 ]] ; then | 69 if [[ "${NUM_MAKE_JOBS}" -lt 4 ]] ; then |
76 NUM_MAKE_JOBS=2 | 70 NUM_MAKE_JOBS=4 |
77 fi | 71 fi |
78 | 72 |
79 DO_AUTOGEN=no | 73 DO_AUTOGEN=no |
80 DO_CLEAN=no | 74 DO_CLEAN=no |
81 REGEN_DESCRIPTORS=no | 75 REGEN_DESCRIPTORS=no |
82 CORE_ONLY=no | 76 CORE_ONLY=no |
83 DO_XCODE_IOS_TESTS=yes | 77 DO_XCODE_IOS_TESTS=yes |
84 DO_XCODE_OSX_TESTS=yes | 78 DO_XCODE_OSX_TESTS=yes |
85 DO_XCODE_DEBUG=yes | |
86 DO_XCODE_RELEASE=yes | |
87 DO_OBJC_CONFORMANCE_TESTS=yes | 79 DO_OBJC_CONFORMANCE_TESTS=yes |
88 XCODE_QUIET=no | |
89 while [[ $# != 0 ]]; do | 80 while [[ $# != 0 ]]; do |
90 case "${1}" in | 81 case "${1}" in |
91 -h | --help ) | 82 -h | --help ) |
92 printUsage | 83 printUsage |
93 exit 0 | 84 exit 0 |
94 ;; | 85 ;; |
95 -c | --clean ) | 86 -c | --clean ) |
96 DO_CLEAN=yes | 87 DO_CLEAN=yes |
97 ;; | 88 ;; |
98 -a | --autogen ) | 89 -a | --autogen ) |
(...skipping 12 matching lines...) Expand all Loading... |
111 --skip-xcode ) | 102 --skip-xcode ) |
112 DO_XCODE_IOS_TESTS=no | 103 DO_XCODE_IOS_TESTS=no |
113 DO_XCODE_OSX_TESTS=no | 104 DO_XCODE_OSX_TESTS=no |
114 ;; | 105 ;; |
115 --skip-xcode-ios ) | 106 --skip-xcode-ios ) |
116 DO_XCODE_IOS_TESTS=no | 107 DO_XCODE_IOS_TESTS=no |
117 ;; | 108 ;; |
118 --skip-xcode-osx ) | 109 --skip-xcode-osx ) |
119 DO_XCODE_OSX_TESTS=no | 110 DO_XCODE_OSX_TESTS=no |
120 ;; | 111 ;; |
121 --skip-xcode-debug ) | |
122 DO_XCODE_DEBUG=no | |
123 ;; | |
124 --skip-xcode-release ) | |
125 DO_XCODE_RELEASE=no | |
126 ;; | |
127 --skip-objc-conformance ) | 112 --skip-objc-conformance ) |
128 DO_OBJC_CONFORMANCE_TESTS=no | 113 DO_OBJC_CONFORMANCE_TESTS=no |
129 ;; | 114 ;; |
130 --xcode-quiet ) | |
131 XCODE_QUIET=yes | |
132 ;; | |
133 -*) | 115 -*) |
134 echo "ERROR: Unknown option: ${1}" 1>&2 | 116 echo "ERROR: Unknown option: ${1}" 1>&2 |
135 printUsage | 117 printUsage |
136 exit 1 | 118 exit 1 |
137 ;; | 119 ;; |
138 *) | 120 *) |
139 echo "ERROR: Unknown argument: ${1}" 1>&2 | 121 echo "ERROR: Unknown argument: ${1}" 1>&2 |
140 printUsage | 122 printUsage |
141 exit 1 | 123 exit 1 |
142 ;; | 124 ;; |
(...skipping 19 matching lines...) Expand all Loading... |
162 | 144 |
163 if [[ "${DO_CLEAN}" == "yes" ]] ; then | 145 if [[ "${DO_CLEAN}" == "yes" ]] ; then |
164 header "Cleaning" | 146 header "Cleaning" |
165 wrapped_make clean | 147 wrapped_make clean |
166 if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then | 148 if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then |
167 XCODEBUILD_CLEAN_BASE_IOS=( | 149 XCODEBUILD_CLEAN_BASE_IOS=( |
168 xcodebuild | 150 xcodebuild |
169 -project objectivec/ProtocolBuffers_iOS.xcodeproj | 151 -project objectivec/ProtocolBuffers_iOS.xcodeproj |
170 -scheme ProtocolBuffers | 152 -scheme ProtocolBuffers |
171 ) | 153 ) |
172 if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then | 154 "${XCODEBUILD_CLEAN_BASE_IOS[@]}" -configuration Debug clean |
173 "${XCODEBUILD_CLEAN_BASE_IOS[@]}" -configuration Debug clean | 155 "${XCODEBUILD_CLEAN_BASE_IOS[@]}" -configuration Release clean |
174 fi | |
175 if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then | |
176 "${XCODEBUILD_CLEAN_BASE_IOS[@]}" -configuration Release clean | |
177 fi | |
178 fi | 156 fi |
179 if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then | 157 if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then |
180 XCODEBUILD_CLEAN_BASE_OSX=( | 158 XCODEBUILD_CLEAN_BASE_OSX=( |
181 xcodebuild | 159 xcodebuild |
182 -project objectivec/ProtocolBuffers_OSX.xcodeproj | 160 -project objectivec/ProtocolBuffers_OSX.xcodeproj |
183 -scheme ProtocolBuffers | 161 -scheme ProtocolBuffers |
184 ) | 162 ) |
185 if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then | 163 "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Debug clean |
186 "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Debug clean | 164 "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Release clean |
187 fi | |
188 if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then | |
189 "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Release clean | |
190 fi | |
191 fi | 165 fi |
192 fi | 166 fi |
193 | 167 |
194 if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then | 168 if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then |
195 header "Regenerating the descriptor sources." | 169 header "Regenerating the descriptor sources." |
196 ./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}" | 170 ./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}" |
197 fi | 171 fi |
198 | 172 |
199 if [[ "${CORE_ONLY}" == "yes" ]] ; then | 173 if [[ "${CORE_ONLY}" == "yes" ]] ; then |
200 header "Building core Only" | 174 header "Building core Only" |
(...skipping 15 matching lines...) Expand all Loading... |
216 | 190 |
217 header "Checking on the ObjC Runtime Code" | 191 header "Checking on the ObjC Runtime Code" |
218 objectivec/DevTools/pddm_tests.py | 192 objectivec/DevTools/pddm_tests.py |
219 if ! objectivec/DevTools/pddm.py --dry-run objectivec/*.[hm] objectivec/Tests/*.
[hm] ; then | 193 if ! objectivec/DevTools/pddm.py --dry-run objectivec/*.[hm] objectivec/Tests/*.
[hm] ; then |
220 echo "" | 194 echo "" |
221 echo "Update by running:" | 195 echo "Update by running:" |
222 echo " objectivec/DevTools/pddm.py objectivec/*.[hm] objectivec/Tests/*.[hm]
" | 196 echo " objectivec/DevTools/pddm.py objectivec/*.[hm] objectivec/Tests/*.[hm]
" |
223 exit 1 | 197 exit 1 |
224 fi | 198 fi |
225 | 199 |
226 readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )" | |
227 readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix. | |
228 | |
229 if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then | 200 if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then |
230 XCODEBUILD_TEST_BASE_IOS=( | 201 XCODEBUILD_TEST_BASE_IOS=( |
231 xcodebuild | 202 xcodebuild |
232 -project objectivec/ProtocolBuffers_iOS.xcodeproj | 203 -project objectivec/ProtocolBuffers_iOS.xcodeproj |
233 -scheme ProtocolBuffers | 204 -scheme ProtocolBuffers |
234 ) | 205 ) |
235 if [[ "${XCODE_QUIET}" == "yes" ]] ; then | |
236 XCODEBUILD_TEST_BASE_IOS+=( -quiet ) | |
237 fi | |
238 # Don't need to worry about form factors or retina/non retina; | 206 # Don't need to worry about form factors or retina/non retina; |
239 # just pick a mix of OS Versions and 32/64 bit. | 207 # just pick a mix of OS Versions and 32/64 bit. |
240 # NOTE: Different Xcode have different simulated hardware/os support. | 208 # NOTE: Different Xcode have different simulated hardware/os support. |
| 209 readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )" |
| 210 readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix. |
| 211 IOS_SIMULATOR_NAME="Simulator" |
241 case "${XCODE_VERSION}" in | 212 case "${XCODE_VERSION}" in |
242 6.* ) | 213 6.* ) |
243 echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 8.
0 or higher." 1>&2 | 214 echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 7.
0 or higher." 1>&2 |
244 exit 10 | 215 exit 10 |
245 ;; | 216 ;; |
246 7.* ) | 217 7.1* ) |
247 echo "ERROR: The unittests include Swift code that is now Swift 3.0." 1>&2 | |
248 echo "ERROR: Xcode 8.0 or higher is required to build the test suite, but
the library works with Xcode 7.x." 1>&2 | |
249 exit 11 | |
250 ;; | |
251 8.0* ) | |
252 # The 8.* device seem to hang and never start under Xcode 8. | |
253 XCODEBUILD_TEST_BASE_IOS+=( | 218 XCODEBUILD_TEST_BASE_IOS+=( |
254 -destination "platform=iOS Simulator,name=iPhone 4s,OS=9.0" # 32bit | 219 -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit |
255 -destination "platform=iOS Simulator,name=iPhone 7,OS=10.0" # 64bit | 220 -destination "platform=iOS Simulator,name=iPhone 6,OS=9.0" # 64bit |
256 -destination "platform=iOS Simulator,name=iPad 2,OS=9.0" # 32bit | 221 -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit |
257 -destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.0"
# 64bit | 222 -destination "platform=iOS Simulator,name=iPad Air,OS=9.0" # 64bit |
258 ) | 223 ) |
259 ;; | 224 ;; |
260 8.1* ) | 225 7.3* ) |
261 XCODEBUILD_TEST_BASE_IOS+=( | 226 XCODEBUILD_TEST_BASE_IOS+=( |
262 -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit | 227 -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit |
263 -destination "platform=iOS Simulator,name=iPhone 7,OS=10.1" # 64bit | 228 -destination "platform=iOS Simulator,name=iPhone 6,OS=9.3" # 64bit |
264 -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit | 229 -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit |
265 -destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.1"
# 64bit | 230 -destination "platform=iOS Simulator,name=iPad Air,OS=9.3" # 64bit |
| 231 ) |
| 232 ;; |
| 233 7.* ) |
| 234 XCODEBUILD_TEST_BASE_IOS+=( |
| 235 -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit |
| 236 -destination "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit |
| 237 -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit |
| 238 -destination "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit |
266 ) | 239 ) |
267 ;; | 240 ;; |
268 * ) | 241 * ) |
269 echo "Time to update the simulator targets for Xcode ${XCODE_VERSION}" | 242 echo "Time to update the simulator targets for Xcode ${XCODE_VERSION}" |
270 exit 2 | 243 exit 2 |
271 ;; | 244 ;; |
272 esac | 245 esac |
273 if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then | 246 header "Doing Xcode iOS build/tests - Debug" |
274 header "Doing Xcode iOS build/tests - Debug" | 247 "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Debug test |
275 "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Debug test | 248 header "Doing Xcode iOS build/tests - Release" |
276 fi | 249 "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test |
277 if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then | |
278 header "Doing Xcode iOS build/tests - Release" | |
279 "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test | |
280 fi | |
281 # Don't leave the simulator in the developer's face. | 250 # Don't leave the simulator in the developer's face. |
282 killall Simulator | 251 killall "${IOS_SIMULATOR_NAME}" |
283 fi | 252 fi |
284 if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then | 253 if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then |
285 XCODEBUILD_TEST_BASE_OSX=( | 254 XCODEBUILD_TEST_BASE_OSX=( |
286 xcodebuild | 255 xcodebuild |
287 -project objectivec/ProtocolBuffers_OSX.xcodeproj | 256 -project objectivec/ProtocolBuffers_OSX.xcodeproj |
288 -scheme ProtocolBuffers | 257 -scheme ProtocolBuffers |
289 # Since the ObjC 2.0 Runtime is required, 32bit OS X isn't supported. | 258 # Since the ObjC 2.0 Runtime is required, 32bit OS X isn't supported. |
290 -destination "platform=OS X,arch=x86_64" # 64bit | 259 -destination "platform=OS X,arch=x86_64" # 64bit |
291 ) | 260 ) |
292 if [[ "${XCODE_QUIET}" == "yes" ]] ; then | 261 header "Doing Xcode OS X build/tests - Debug" |
293 XCODEBUILD_TEST_BASE_OSX+=( -quiet ) | 262 "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Debug test |
294 fi | 263 header "Doing Xcode OS X build/tests - Release" |
295 case "${XCODE_VERSION}" in | 264 "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Release test |
296 6.* ) | |
297 echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 8.
0 or higher." 1>&2 | |
298 exit 10 | |
299 ;; | |
300 7.* ) | |
301 echo "ERROR: The unittests include Swift code that is now Swift 3.0." 1>&2 | |
302 echo "ERROR: Xcode 8.0 or higher is required to build the test suite, but
the library works with Xcode 7.x." 1>&2 | |
303 exit 11 | |
304 ;; | |
305 esac | |
306 if [[ "${DO_XCODE_DEBUG}" == "yes" ]] ; then | |
307 header "Doing Xcode OS X build/tests - Debug" | |
308 "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Debug test | |
309 fi | |
310 if [[ "${DO_XCODE_RELEASE}" == "yes" ]] ; then | |
311 header "Doing Xcode OS X build/tests - Release" | |
312 "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Release test | |
313 fi | |
314 fi | 265 fi |
315 | 266 |
316 if [[ "${DO_OBJC_CONFORMANCE_TESTS}" == "yes" ]] ; then | 267 if [[ "${DO_OBJC_CONFORMANCE_TESTS}" == "yes" ]] ; then |
317 header "Running ObjC Conformance Tests" | |
318 cd conformance | 268 cd conformance |
319 wrapped_make -j "${NUM_MAKE_JOBS}" test_objc | 269 wrapped_make -j "${NUM_MAKE_JOBS}" test_objc |
320 cd .. | 270 cd .. |
321 fi | 271 fi |
OLD | NEW |