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