OLD | NEW |
| (Empty) |
1 #!/bin/bash | |
2 | |
3 # Invoked by the Xcode projects to build the protos needed for the unittests. | |
4 | |
5 set -eu | |
6 | |
7 readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/protos" | |
8 | |
9 # Helper for bailing. | |
10 die() { | |
11 echo "Error: $1" | |
12 exit 2 | |
13 } | |
14 | |
15 # What to do. | |
16 case "${ACTION}" in | |
17 "") | |
18 # Build, fall thru | |
19 ;; | |
20 "clean") | |
21 rm -rf "${OUTPUT_DIR}" | |
22 exit 0 | |
23 ;; | |
24 *) | |
25 die "Unknown action requested: ${ACTION}" | |
26 ;; | |
27 esac | |
28 | |
29 # Move to the top of the protobuf directories. | |
30 cd "${SRCROOT}/.." | |
31 | |
32 [[ -x src/protoc ]] || \ | |
33 die "Could not find the protoc binary; make sure you have built it (objectivec
/DevTools/full_mac_build.sh -h)." | |
34 | |
35 RUN_PROTOC=no | |
36 if [[ ! -d "${OUTPUT_DIR}" ]] ; then | |
37 RUN_PROTOC=yes | |
38 else | |
39 # Find the newest input file (protos, compiler, and this script). | |
40 # (these patterns catch some extra stuff, but better to over sample than | |
41 # under) | |
42 readonly NewestInput=$(find \ | |
43 src/google/protobuf/*.proto \ | |
44 objectivec/Tests/*.proto \ | |
45 src/.libs src/*.la src/protoc \ | |
46 objectivec/DevTools/compile_testing_protos.sh \ | |
47 -type f -print0 \ | |
48 | xargs -0 stat -f "%m %N" \ | |
49 | sort -n | tail -n1 | cut -f2- -d" ") | |
50 # Find the oldest output file. | |
51 readonly OldestOutput=$(find \ | |
52 "${OUTPUT_DIR}" \ | |
53 -type f -print0 \ | |
54 | xargs -0 stat -f "%m %N" \ | |
55 | sort -n -r | tail -n1 | cut -f2- -d" ") | |
56 # If the newest input is newer than the oldest output, regenerate. | |
57 if [[ "${NewestInput}" -nt "${OldestOutput}" ]] ; then | |
58 RUN_PROTOC=yes | |
59 fi | |
60 fi | |
61 | |
62 if [[ "${RUN_PROTOC}" != "yes" ]] ; then | |
63 # Up to date. | |
64 exit 0 | |
65 fi | |
66 | |
67 # Ensure the output dir exists | |
68 mkdir -p "${OUTPUT_DIR}/google/protobuf" | |
69 | |
70 CORE_PROTO_FILES=( \ | |
71 src/google/protobuf/unittest_custom_options.proto \ | |
72 src/google/protobuf/unittest_enormous_descriptor.proto \ | |
73 src/google/protobuf/unittest_embed_optimize_for.proto \ | |
74 src/google/protobuf/unittest_empty.proto \ | |
75 src/google/protobuf/unittest_import.proto \ | |
76 src/google/protobuf/unittest_import_lite.proto \ | |
77 src/google/protobuf/unittest_lite.proto \ | |
78 src/google/protobuf/unittest_mset.proto \ | |
79 src/google/protobuf/unittest_no_generic_services.proto \ | |
80 src/google/protobuf/unittest_optimize_for.proto \ | |
81 src/google/protobuf/unittest.proto \ | |
82 src/google/protobuf/unittest_import_public.proto \ | |
83 src/google/protobuf/unittest_import_public_lite.proto \ | |
84 src/google/protobuf/unittest_drop_unknown_fields.proto \ | |
85 src/google/protobuf/unittest_preserve_unknown_enum.proto \ | |
86 src/google/protobuf/map_lite_unittest.proto \ | |
87 src/google/protobuf/map_proto2_unittest.proto \ | |
88 src/google/protobuf/map_unittest.proto \ | |
89 ) | |
90 | |
91 compile_proto() { | |
92 src/protoc \ | |
93 --objc_out="${OUTPUT_DIR}/google/protobuf" \ | |
94 --proto_path=src/google/protobuf/ \ | |
95 --proto_path=src \ | |
96 $* | |
97 } | |
98 | |
99 for a_proto in "${CORE_PROTO_FILES[@]}" ; do | |
100 compile_proto "${a_proto}" | |
101 done | |
102 | |
103 OBJC_PROTO_FILES=( \ | |
104 objectivec/Tests/unittest_cycle.proto \ | |
105 objectivec/Tests/unittest_runtime_proto2.proto \ | |
106 objectivec/Tests/unittest_runtime_proto3.proto \ | |
107 objectivec/Tests/unittest_objc.proto \ | |
108 objectivec/Tests/unittest_objc_startup.proto \ | |
109 ) | |
110 | |
111 for a_proto in "${OBJC_PROTO_FILES[@]}" ; do | |
112 compile_proto --proto_path="objectivec/Tests" "${a_proto}" | |
113 done | |
OLD | NEW |