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