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}/../.." |
11 | 11 |
12 printUsage() { | 12 printUsage() { |
13 NAME=$(basename "${0}") | 13 NAME=$(basename "${0}") |
14 cat << EOF | 14 cat << EOF |
15 usage: ${NAME} [OPTIONS] | 15 usage: ${NAME} [OPTIONS] |
16 | 16 |
17 This script does the common build steps needed. | 17 This script does the common build steps needed. |
18 | 18 |
19 OPTIONS: | 19 OPTIONS: |
20 | 20 |
21 General: | 21 General: |
22 | 22 |
23 -h, --help | 23 -h, --help |
24 Show this message | 24 Show this message |
25 -c, --clean | 25 -c, --clean |
26 Issue a clean before the normal build. | 26 Issue a clean before the normal build. |
27 -a, --autogen | 27 -a, --autogen |
28 Start by rerunning autogen & configure. | 28 Start by rerunning autogen & configure. |
29 -r, --regenerate-cpp-descriptors | 29 -r, --regenerate-descriptors |
30 The descriptor.proto is checked in generated, cause it to regenerate. | 30 Run generate_descriptor_proto.sh to regenerate all the checked in |
| 31 proto sources. |
31 -j #, --jobs # | 32 -j #, --jobs # |
32 Force the number of parallel jobs (useful for debugging build issues). | 33 Force the number of parallel jobs (useful for debugging build issues). |
33 --core-only | 34 --core-only |
34 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. |
35 --skip-xcode | 36 --skip-xcode |
36 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. |
37 --skip-xcode-ios | 38 --skip-xcode-ios |
38 Skip the invoke of Xcode to test the runtime on iOS. | 39 Skip the invoke of Xcode to test the runtime on iOS. |
39 --skip-xcode-osx | 40 --skip-xcode-osx |
40 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. |
(...skipping 23 matching lines...) Expand all Loading... |
64 set -e | 65 set -e |
65 } | 66 } |
66 | 67 |
67 NUM_MAKE_JOBS=$(/usr/sbin/sysctl -n hw.ncpu) | 68 NUM_MAKE_JOBS=$(/usr/sbin/sysctl -n hw.ncpu) |
68 if [[ "${NUM_MAKE_JOBS}" -lt 4 ]] ; then | 69 if [[ "${NUM_MAKE_JOBS}" -lt 4 ]] ; then |
69 NUM_MAKE_JOBS=4 | 70 NUM_MAKE_JOBS=4 |
70 fi | 71 fi |
71 | 72 |
72 DO_AUTOGEN=no | 73 DO_AUTOGEN=no |
73 DO_CLEAN=no | 74 DO_CLEAN=no |
74 REGEN_CPP_DESCRIPTORS=no | 75 REGEN_DESCRIPTORS=no |
75 CORE_ONLY=no | 76 CORE_ONLY=no |
76 DO_XCODE_IOS_TESTS=yes | 77 DO_XCODE_IOS_TESTS=yes |
77 DO_XCODE_OSX_TESTS=yes | 78 DO_XCODE_OSX_TESTS=yes |
78 DO_OBJC_CONFORMANCE_TESTS=yes | 79 DO_OBJC_CONFORMANCE_TESTS=yes |
79 while [[ $# != 0 ]]; do | 80 while [[ $# != 0 ]]; do |
80 case "${1}" in | 81 case "${1}" in |
81 -h | --help ) | 82 -h | --help ) |
82 printUsage | 83 printUsage |
83 exit 0 | 84 exit 0 |
84 ;; | 85 ;; |
85 -c | --clean ) | 86 -c | --clean ) |
86 DO_CLEAN=yes | 87 DO_CLEAN=yes |
87 ;; | 88 ;; |
88 -a | --autogen ) | 89 -a | --autogen ) |
89 DO_AUTOGEN=yes | 90 DO_AUTOGEN=yes |
90 ;; | 91 ;; |
91 -r | --regenerate-cpp-descriptors ) | 92 -r | --regenerate-descriptors ) |
92 REGEN_CPP_DESCRIPTORS=yes | 93 REGEN_DESCRIPTORS=yes |
93 ;; | 94 ;; |
94 -j | --jobs ) | 95 -j | --jobs ) |
95 shift | 96 shift |
96 NUM_MAKE_JOBS="${1}" | 97 NUM_MAKE_JOBS="${1}" |
97 ;; | 98 ;; |
98 --core-only ) | 99 --core-only ) |
99 CORE_ONLY=yes | 100 CORE_ONLY=yes |
100 ;; | 101 ;; |
101 --skip-xcode ) | 102 --skip-xcode ) |
102 DO_XCODE_IOS_TESTS=no | 103 DO_XCODE_IOS_TESTS=no |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 XCODEBUILD_CLEAN_BASE_OSX=( | 158 XCODEBUILD_CLEAN_BASE_OSX=( |
158 xcodebuild | 159 xcodebuild |
159 -project objectivec/ProtocolBuffers_OSX.xcodeproj | 160 -project objectivec/ProtocolBuffers_OSX.xcodeproj |
160 -scheme ProtocolBuffers | 161 -scheme ProtocolBuffers |
161 ) | 162 ) |
162 "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Debug clean | 163 "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Debug clean |
163 "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Release clean | 164 "${XCODEBUILD_CLEAN_BASE_OSX[@]}" -configuration Release clean |
164 fi | 165 fi |
165 fi | 166 fi |
166 | 167 |
167 if [[ "${REGEN_CPP_DESCRIPTORS}" == "yes" ]] ; then | 168 if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then |
168 header "Regenerating the C++ descriptor sources." | 169 header "Regenerating the descriptor sources." |
169 ./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}" | 170 ./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}" |
170 fi | 171 fi |
171 | 172 |
172 if [[ "${CORE_ONLY}" == "yes" ]] ; then | 173 if [[ "${CORE_ONLY}" == "yes" ]] ; then |
173 header "Building core Only" | 174 header "Building core Only" |
174 wrapped_make -j "${NUM_MAKE_JOBS}" | 175 wrapped_make -j "${NUM_MAKE_JOBS}" |
175 else | 176 else |
176 header "Building" | 177 header "Building" |
177 # Can't issue these together, when fully parallel, something sometimes chokes | 178 # Can't issue these together, when fully parallel, something sometimes chokes |
178 # at random. | 179 # at random. |
179 wrapped_make -j "${NUM_MAKE_JOBS}" all | 180 wrapped_make -j "${NUM_MAKE_JOBS}" all |
180 wrapped_make -j "${NUM_MAKE_JOBS}" check | 181 wrapped_make -j "${NUM_MAKE_JOBS}" check |
181 # Fire off the conformance tests also. | 182 # Fire off the conformance tests also. |
182 cd conformance | 183 cd conformance |
183 wrapped_make -j "${NUM_MAKE_JOBS}" test_cpp | 184 wrapped_make -j "${NUM_MAKE_JOBS}" test_cpp |
184 cd .. | 185 cd .. |
185 fi | 186 fi |
186 | 187 |
187 header "Ensuring the ObjC descriptors are current." | 188 # Ensure the WKT sources checked in are current. |
188 # Find the newest input file (protos, compiler, and the generator script). | 189 objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}" |
189 # (these patterns catch some extra stuff, but better to over sample than under) | |
190 readonly NewestInput=$(find \ | |
191 src/google/protobuf/*.proto \ | |
192 src/.libs src/*.la src/protoc \ | |
193 objectivec/generate_descriptors_proto.sh \ | |
194 -type f -print0 \ | |
195 | xargs -0 stat -f "%m %N" \ | |
196 | sort -n | tail -n1 | cut -f2- -d" ") | |
197 # Find the oldest output file. | |
198 readonly OldestOutput=$(find \ | |
199 "${ProtoRootDir}/objectivec/google" \ | |
200 -type f -print0 \ | |
201 | xargs -0 stat -f "%m %N" \ | |
202 | sort -n -r | tail -n1 | cut -f2- -d" ") | |
203 # If the newest input is newer than the oldest output, regenerate. | |
204 if [[ "${NewestInput}" -nt "${OldestOutput}" ]] ; then | |
205 echo ">> Newest input is newer than oldest output, regenerating." | |
206 objectivec/generate_descriptors_proto.sh -j "${NUM_MAKE_JOBS}" | |
207 else | |
208 echo ">> Newest input is older than oldest output, no need to regenerating." | |
209 fi | |
210 | 190 |
211 header "Checking on the ObjC Runtime Code" | 191 header "Checking on the ObjC Runtime Code" |
212 objectivec/DevTools/pddm_tests.py | 192 objectivec/DevTools/pddm_tests.py |
213 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 |
214 echo "" | 194 echo "" |
215 echo "Update by running:" | 195 echo "Update by running:" |
216 echo " objectivec/DevTools/pddm.py objectivec/*.[hm] objectivec/Tests/*.[hm]
" | 196 echo " objectivec/DevTools/pddm.py objectivec/*.[hm] objectivec/Tests/*.[hm]
" |
217 exit 1 | 197 exit 1 |
218 fi | 198 fi |
219 | 199 |
220 if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then | 200 if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then |
221 XCODEBUILD_TEST_BASE_IOS=( | 201 XCODEBUILD_TEST_BASE_IOS=( |
222 xcodebuild | 202 xcodebuild |
223 -project objectivec/ProtocolBuffers_iOS.xcodeproj | 203 -project objectivec/ProtocolBuffers_iOS.xcodeproj |
224 -scheme ProtocolBuffers | 204 -scheme ProtocolBuffers |
225 ) | 205 ) |
226 # 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; |
227 # just pick a mix of OS Versions and 32/64 bit. | 207 # just pick a mix of OS Versions and 32/64 bit. |
228 # NOTE: Different Xcode have different simulated hardware/os support. | 208 # NOTE: Different Xcode have different simulated hardware/os support. |
229 readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )" | 209 readonly XCODE_VERSION_LINE="$(xcodebuild -version | grep Xcode\ )" |
230 readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix. | 210 readonly XCODE_VERSION="${XCODE_VERSION_LINE/Xcode /}" # drop the prefix. |
231 IOS_SIMULATOR_NAME="Simulator" | 211 IOS_SIMULATOR_NAME="Simulator" |
232 case "${XCODE_VERSION}" in | 212 case "${XCODE_VERSION}" in |
233 6.* ) | 213 6.* ) |
234 echo "ERROR: Xcode 6.3/6.4 no longer supported for building, please use 7.
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 |
235 exit 10 | 215 exit 10 |
236 ;; | 216 ;; |
237 7.* ) | 217 7.1* ) |
238 XCODEBUILD_TEST_BASE_IOS+=( | 218 XCODEBUILD_TEST_BASE_IOS+=( |
239 -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit | 219 -destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit |
240 -destination "platform=iOS Simulator,name=iPhone 6,OS=9.0" # 64bit | 220 -destination "platform=iOS Simulator,name=iPhone 6,OS=9.0" # 64bit |
241 -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit | 221 -destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit |
242 -destination "platform=iOS Simulator,name=iPad Air,OS=9.0" # 64bit | 222 -destination "platform=iOS Simulator,name=iPad Air,OS=9.0" # 64bit |
243 ) | 223 ) |
244 ;; | 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 ) |
| 240 ;; |
245 * ) | 241 * ) |
246 echo "Time to update the simulator targets for Xcode ${XCODE_VERSION}" | 242 echo "Time to update the simulator targets for Xcode ${XCODE_VERSION}" |
247 exit 2 | 243 exit 2 |
248 ;; | 244 ;; |
249 esac | 245 esac |
250 header "Doing Xcode iOS build/tests - Debug" | 246 header "Doing Xcode iOS build/tests - Debug" |
251 "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Debug test | 247 "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Debug test |
252 header "Doing Xcode iOS build/tests - Release" | 248 header "Doing Xcode iOS build/tests - Release" |
253 "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test | 249 "${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test |
254 # Don't leave the simulator in the developer's face. | 250 # Don't leave the simulator in the developer's face. |
(...skipping 11 matching lines...) Expand all Loading... |
266 "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Debug test | 262 "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Debug test |
267 header "Doing Xcode OS X build/tests - Release" | 263 header "Doing Xcode OS X build/tests - Release" |
268 "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Release test | 264 "${XCODEBUILD_TEST_BASE_OSX[@]}" -configuration Release test |
269 fi | 265 fi |
270 | 266 |
271 if [[ "${DO_OBJC_CONFORMANCE_TESTS}" == "yes" ]] ; then | 267 if [[ "${DO_OBJC_CONFORMANCE_TESTS}" == "yes" ]] ; then |
272 cd conformance | 268 cd conformance |
273 wrapped_make -j "${NUM_MAKE_JOBS}" test_objc | 269 wrapped_make -j "${NUM_MAKE_JOBS}" test_objc |
274 cd .. | 270 cd .. |
275 fi | 271 fi |
OLD | NEW |