12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ # Generate output in-place. So long as the build is idempotent this helps
16
+ # verify that the protoc-generated output isn't changing.
17
+ set (OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
18
+
19
+ # Filename "roots" (i.e. without the .proto) from within the proto directory,
20
+ # excluding anything in google/protobuf.
21
+ set (
22
+ PROTO_FILE_ROOTS
23
+ firestore/local/maybe_document
24
+ firestore/local/mutation
25
+ firestore/local/target
26
+ google/api/annotations
27
+ google/api/http
28
+ google/firestore/v1beta1/common
29
+ google/firestore/v1beta1/document
30
+ google/firestore/v1beta1/firestore
31
+ google/firestore/v1beta1/query
32
+ google/firestore/v1beta1/write
33
+ google/rpc/status
34
+ google/type/latlng
35
+ )
36
+
37
+ # Filename "roots" (i.e. without the .proto) from within the proto directory,
38
+ # from the google/protobuf package.
39
+ set (
40
+ WELL_KNOWN_PROTO_FILE_ROOTS
41
+ google/protobuf/any
42
+ google/protobuf/empty
43
+ google/protobuf/struct
44
+ google/protobuf/timestamp
45
+ google/protobuf/wrappers
46
+ )
47
+
48
+ # Populate NANOPB_GENERATED_SOURCES with the list of nanopb-generated sources.
49
+ # The nanopb runtime does not include the well-known protos so we have to build
50
+ # them ourselves.
51
+ foreach (root ${PROTO_FILE_ROOTS} ${WELL_KNOWN_PROTO_FILE_ROOTS} )
52
+ list (
53
+ APPEND NANOPB_GENERATED_SOURCES
54
+ ${OUTPUT_DIR} /nanopb/${root}.nanopb.c
55
+ ${OUTPUT_DIR} /nanopb/${root}.nanopb.h
56
+ )
57
+ endforeach ()
58
+
59
+ # Populate PROTOBUF_CPP_GENERATED_SOURCES with the list of libprotobuf C++
60
+ # sources. These are used for verifying interoperation from nanopb.
61
+ #
62
+ # Libprotobuf includes the well-known protos so they must be omitted here.
63
+ foreach (root ${PROTO_FILE_ROOTS} )
64
+ list (
65
+ APPEND PROTOBUF_CPP_GENERATED_SOURCES
66
+ ${OUTPUT_DIR} /cpp/${root}.pb.cc
67
+ ${OUTPUT_DIR} /cpp/${root}.pb.h
68
+ )
69
+ endforeach ()
70
+
71
+ # Populate PROTOBUF_OBJC_GENERATED_SOURCES with the list of libprotobuf
72
+ # Objective-C sources. These are used by the old Objective-C implementation
73
+ # that we're replacing.
74
+ #
75
+ # Libprotobuf Objective-C also includes the well-known protos so they must be
76
+ # omitted here.
77
+ #
78
+ # The Objective-C client also uses the generated gRPC stubs for the Firestore
79
+ # service.
80
+ set (
81
+ PROTOBUF_OBJC_GENERATED_SOURCES
82
+ ${OUTPUT_DIR} /objc/google/firestore/v1beta1/Firestore.pbrpc.h
83
+ ${OUTPUT_DIR} /objc/google/firestore/v1beta1/Firestore.pbrpc.m
84
+ )
85
+ foreach (root ${PROTO_FILE_ROOTS} )
86
+ list (
87
+ APPEND PROTOBUF_OBJC_GENERATED_SOURCES
88
+ ${OUTPUT_DIR} /objc/${root}.pbobjc.h
89
+ ${OUTPUT_DIR} /objc/${root}.pbobjc.m
90
+ )
91
+ endforeach ()
92
+
93
+
15
94
cc_library (
16
95
firebase_firestore_protos_nanopb
17
96
SOURCES
18
- nanopb/firestore/local/maybe_document.pb.c
19
- nanopb/firestore/local/maybe_document.nanopb.h
20
- nanopb/firestore/local/mutation.pb.c
21
- nanopb/firestore/local/mutation.nanopb.h
22
- nanopb/firestore/local/target.pb.c
23
- nanopb/firestore/local/target.nanopb.h
24
- nanopb/google/api/annotations.pb.c
25
- nanopb/google/api/annotations.nanopb.h
26
- nanopb/google/api/http.pb.c
27
- nanopb/google/api/http.nanopb.h
28
- nanopb/google/firestore/v1beta1/common.pb.c
29
- nanopb/google/firestore/v1beta1/common.nanopb.h
30
- nanopb/google/firestore/v1beta1/document.pb.c
31
- nanopb/google/firestore/v1beta1/document.nanopb.h
32
- nanopb/google/firestore/v1beta1/firestore.pb.c
33
- nanopb/google/firestore/v1beta1/firestore.nanopb.h
34
- nanopb/google/firestore/v1beta1/query.pb.c
35
- nanopb/google/firestore/v1beta1/query.nanopb.h
36
- nanopb/google/firestore/v1beta1/write.pb.c
37
- nanopb/google/firestore/v1beta1/write.nanopb.h
38
- nanopb/google/protobuf/any.pb.c
39
- nanopb/google/protobuf/any.nanopb.h
40
- nanopb/google/protobuf/empty.pb.c
41
- nanopb/google/protobuf/empty.nanopb.h
42
- nanopb/google/protobuf/struct.pb.c
43
- nanopb/google/protobuf/struct.nanopb.h
44
- nanopb/google/protobuf/timestamp.pb.c
45
- nanopb/google/protobuf/timestamp.nanopb.h
46
- nanopb/google/protobuf/wrappers.pb.c
47
- nanopb/google/protobuf/wrappers.nanopb.h
48
- nanopb/google/rpc/status.pb.c
49
- nanopb/google/rpc/status.nanopb.h
50
- nanopb/google/type/latlng.pb.c
51
- nanopb/google/type/latlng.nanopb.h
97
+ ${NANOPB_GENERATED_SOURCES}
52
98
DEPENDS
53
99
protobuf-nanopb
54
100
)
@@ -64,30 +110,7 @@ target_include_directories(
64
110
cc_library (
65
111
firebase_firestore_protos_libprotobuf
66
112
SOURCES
67
- cpp/firestore/local/maybe_document.pb.cc
68
- cpp/firestore/local/maybe_document.pb.h
69
- cpp/firestore/local/mutation.pb.cc
70
- cpp/firestore/local/mutation.pb.h
71
- cpp/firestore/local/target.pb.cc
72
- cpp/firestore/local/target.pb.h
73
- cpp/google/api/annotations.pb.cc
74
- cpp/google/api/annotations.pb.h
75
- cpp/google/api/http.pb.cc
76
- cpp/google/api/http.pb.h
77
- cpp/google/firestore/v1beta1/common.pb.cc
78
- cpp/google/firestore/v1beta1/common.pb.h
79
- cpp/google/firestore/v1beta1/document.pb.cc
80
- cpp/google/firestore/v1beta1/document.pb.h
81
- cpp/google/firestore/v1beta1/firestore.pb.cc
82
- cpp/google/firestore/v1beta1/firestore.pb.h
83
- cpp/google/firestore/v1beta1/query.pb.cc
84
- cpp/google/firestore/v1beta1/query.pb.h
85
- cpp/google/firestore/v1beta1/write.pb.cc
86
- cpp/google/firestore/v1beta1/write.pb.h
87
- cpp/google/rpc/status.pb.cc
88
- cpp/google/rpc/status.pb.h
89
- cpp/google/type/latlng.pb.cc
90
- cpp/google/type/latlng.pb.h
113
+ ${PROTOBUF_CPP_GENERATED_SOURCES}
91
114
DEPENDS
92
115
protobuf::libprotobuf
93
116
EXCLUDE_FROM_ALL
@@ -97,3 +120,141 @@ target_include_directories(
97
120
firebase_firestore_protos_libprotobuf PUBLIC
98
121
${FIREBASE_SOURCE_DIR} /Firestore/Protos/cpp
99
122
)
123
+
124
+
125
+ # Generate the python representation of descriptor.proto.
126
+ set (PROTOBUF_DIR ${FIREBASE_BINARY_DIR} /external/src/grpc/third_party/protobuf )
127
+ set (PROTOBUF_PROTO ${PROTOBUF_DIR} /src/google/protobuf/descriptor.proto )
128
+ set (PROTOBUF_PYTHON ${PROTOBUF_DIR} /python/google/protobuf/descriptor_pb2.py )
129
+
130
+ add_custom_command (
131
+ COMMENT "Generating protoc python plugins"
132
+ OUTPUT ${PROTOBUF_PYTHON}
133
+ COMMAND
134
+ protoc
135
+ -I${PROTOBUF_DIR}/src
136
+ --python_out=${PROTOBUF_DIR}/python
137
+ ${PROTOBUF_PROTO}
138
+ VERBATIM
139
+ DEPENDS
140
+ protoc
141
+ ${PROTOBUF_PROTO}
142
+ )
143
+
144
+
145
+ # Generate the python representation of nanopb's protos
146
+ set (NANOPB_DIR ${FIREBASE_BINARY_DIR} /external/src/nanopb )
147
+ set (
148
+ NANOPB_PROTO
149
+ ${NANOPB_DIR} /generator/proto/nanopb.proto
150
+ ${NANOPB_DIR} /generator/proto/plugin.proto
151
+ )
152
+ set (
153
+ NANOPB_PYTHON
154
+ ${NANOPB_DIR} /generator/proto/nanopb_pb2.py
155
+ ${NANOPB_DIR} /generator/proto/plugin_pb2.py
156
+ )
157
+
158
+ set (
159
+ PROTO_INCLUDES
160
+ -I${CMAKE_CURRENT_SOURCE_DIR}/protos
161
+ -I${NANOPB_DIR}/generator
162
+ -I${PROTOBUF_DIR}/src
163
+ )
164
+
165
+ add_custom_command (
166
+ COMMENT "Generating nanopb python plugins"
167
+ OUTPUT ${NANOPB_PYTHON}
168
+ COMMAND
169
+ protoc
170
+ -I${NANOPB_DIR}/generator
171
+ -I${PROTOBUF_DIR}/src
172
+ --python_out=${NANOPB_DIR}/generator
173
+ ${NANOPB_PROTO}
174
+ VERBATIM
175
+ DEPENDS
176
+ protoc
177
+ ${NANOPB_PROTO}
178
+ )
179
+
180
+ add_custom_command (
181
+ COMMENT "Generating nanopb sources"
182
+ OUTPUT ${NANOPB_GENERATED_SOURCES}
183
+ COMMAND
184
+ ${CMAKE_CURRENT_SOURCE_DIR} /build_protos.py
185
+ --nanopb
186
+ --protoc=$<TARGET_FILE:protoc>
187
+ --pythonpath=${PROTOBUF_DIR}/python:${NANOPB_DIR}/generator
188
+ --output_dir=${OUTPUT_DIR}
189
+ ${PROTO_INCLUDES}
190
+ VERBATIM
191
+ DEPENDS
192
+ protoc
193
+ ${CMAKE_CURRENT_SOURCE_DIR} /build_protos.py
194
+ ${CMAKE_CURRENT_SOURCE_DIR} /nanopb_cpp_generator.py
195
+ ${NANOPB_PYTHON}
196
+ ${PROTOBUF_PYTHON}
197
+ )
198
+
199
+ add_custom_target (
200
+ generate_nanopb_protos
201
+ DEPENDS
202
+ ${NANOPB_GENERATED_SOURCES}
203
+ )
204
+
205
+ add_custom_command (
206
+ COMMENT "Generating C++ protobuf sources"
207
+ OUTPUT ${PROTOBUF_CPP_GENERATED_SOURCES}
208
+ COMMAND
209
+ ${CMAKE_CURRENT_SOURCE_DIR} /build_protos.py
210
+ --cpp
211
+ --protoc=$<TARGET_FILE:protoc>
212
+ --output_dir=${OUTPUT_DIR}
213
+ ${PROTO_INCLUDES}
214
+ VERBATIM
215
+ DEPENDS
216
+ protoc
217
+ ${CMAKE_CURRENT_SOURCE_DIR} /build_protos.py
218
+ )
219
+
220
+ add_custom_target (
221
+ generate_cpp_protos
222
+ DEPENDS
223
+ ${PROTOBUF_CPP_GENERATED_SOURCES}
224
+ )
225
+
226
+ add_custom_command (
227
+ COMMENT "Generating Objective-C protobuf sources"
228
+ OUTPUT ${PROTOBUF_OBJC_GENERATED_SOURCES}
229
+ COMMAND
230
+ ${CMAKE_CURRENT_SOURCE_DIR} /build_protos.py
231
+ --objc
232
+ --protoc=$<TARGET_FILE:protoc>
233
+ --protoc_gen_grpc=$<TARGET_FILE:grpc_objective_c_plugin>
234
+ --output_dir=${OUTPUT_DIR}
235
+ ${PROTO_INCLUDES}
236
+ VERBATIM
237
+ DEPENDS
238
+ grpc_objective_c_plugin
239
+ protoc
240
+ ${CMAKE_CURRENT_SOURCE_DIR} /build_protos.py
241
+ )
242
+
243
+ add_custom_target (
244
+ generate_objc_protos
245
+ DEPENDS
246
+ ${PROTOBUF_OBJC_GENERATED_SOURCES}
247
+ )
248
+
249
+ # Custom target that runs a script to generate the proto sources. This isn't
250
+ # hooked into the build, so must be run manually. (It would be easy enough to
251
+ # hook into the (posix) cmake build, but for consistency with windows and xcode
252
+ # builds, we require this to be run manually with the results checked into
253
+ # source control.)
254
+ add_custom_target (
255
+ generate_protos
256
+ DEPENDS
257
+ generate_nanopb_protos
258
+ generate_cpp_protos
259
+ generate_objc_protos
260
+ )
0 commit comments