blob: 5177e43df3fab4d5fb324fefc2ecfe46b87860ee [file] [log] [blame]
Jisi Liud19604f2015-06-17 17:37:58 -07001# Bazel (http://bazel.io/) BUILD file for Protobuf.
2
3licenses(["notice"])
4
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -07005################################################################################
6# Protobuf Runtime Library
7################################################################################
8
Jisi Liud19604f2015-06-17 17:37:58 -07009COPTS = [
10 "-DHAVE_PTHREAD",
11 "-Wall",
12 "-Wwrite-strings",
13 "-Woverloaded-virtual",
14 "-Wno-sign-compare",
15 "-Wno-error=unused-function",
16]
17
18# Bazel should provide portable link_opts for pthread.
19LINK_OPTS = ["-lpthread"]
20
21cc_library(
22 name = "protobuf_lite",
23 srcs = [
24 # AUTOGEN(protobuf_lite_srcs)
25 "src/google/protobuf/arena.cc",
26 "src/google/protobuf/arenastring.cc",
27 "src/google/protobuf/extension_set.cc",
28 "src/google/protobuf/generated_message_util.cc",
29 "src/google/protobuf/io/coded_stream.cc",
30 "src/google/protobuf/io/zero_copy_stream.cc",
31 "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
32 "src/google/protobuf/message_lite.cc",
33 "src/google/protobuf/repeated_field.cc",
34 "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
35 "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070036 "src/google/protobuf/stubs/bytestream.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070037 "src/google/protobuf/stubs/common.cc",
38 "src/google/protobuf/stubs/once.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070039 "src/google/protobuf/stubs/status.cc",
40 "src/google/protobuf/stubs/statusor.cc",
41 "src/google/protobuf/stubs/stringpiece.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070042 "src/google/protobuf/stubs/stringprintf.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070043 "src/google/protobuf/stubs/strutil.cc",
44 "src/google/protobuf/stubs/time.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070045 "src/google/protobuf/wire_format_lite.cc",
46 ],
47 copts = COPTS,
48 includes = ["src/"],
49 linkopts = LINK_OPTS,
50 visibility = ["//visibility:public"],
51)
52
53cc_library(
54 name = "protobuf",
55 srcs = [
56 # AUTOGEN(protobuf_srcs)
57 "src/google/protobuf/any.cc",
58 "src/google/protobuf/any.pb.cc",
59 "src/google/protobuf/api.pb.cc",
60 "src/google/protobuf/compiler/importer.cc",
61 "src/google/protobuf/compiler/parser.cc",
62 "src/google/protobuf/descriptor.cc",
63 "src/google/protobuf/descriptor.pb.cc",
64 "src/google/protobuf/descriptor_database.cc",
65 "src/google/protobuf/duration.pb.cc",
66 "src/google/protobuf/dynamic_message.cc",
67 "src/google/protobuf/empty.pb.cc",
68 "src/google/protobuf/extension_set_heavy.cc",
69 "src/google/protobuf/field_mask.pb.cc",
70 "src/google/protobuf/generated_message_reflection.cc",
71 "src/google/protobuf/io/gzip_stream.cc",
72 "src/google/protobuf/io/printer.cc",
73 "src/google/protobuf/io/strtod.cc",
74 "src/google/protobuf/io/tokenizer.cc",
75 "src/google/protobuf/io/zero_copy_stream_impl.cc",
76 "src/google/protobuf/map_field.cc",
77 "src/google/protobuf/message.cc",
78 "src/google/protobuf/reflection_ops.cc",
79 "src/google/protobuf/service.cc",
80 "src/google/protobuf/source_context.pb.cc",
81 "src/google/protobuf/struct.pb.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070082 "src/google/protobuf/stubs/mathlimits.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070083 "src/google/protobuf/stubs/structurally_valid.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070084 "src/google/protobuf/stubs/substitute.cc",
85 "src/google/protobuf/text_format.cc",
86 "src/google/protobuf/timestamp.pb.cc",
87 "src/google/protobuf/type.pb.cc",
88 "src/google/protobuf/unknown_field_set.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070089 "src/google/protobuf/util/field_comparator.cc",
90 "src/google/protobuf/util/internal/datapiece.cc",
91 "src/google/protobuf/util/internal/default_value_objectwriter.cc",
92 "src/google/protobuf/util/internal/error_listener.cc",
93 "src/google/protobuf/util/internal/field_mask_utility.cc",
94 "src/google/protobuf/util/internal/json_escaping.cc",
95 "src/google/protobuf/util/internal/json_objectwriter.cc",
96 "src/google/protobuf/util/internal/json_stream_parser.cc",
97 "src/google/protobuf/util/internal/object_writer.cc",
98 "src/google/protobuf/util/internal/protostream_objectsource.cc",
99 "src/google/protobuf/util/internal/protostream_objectwriter.cc",
100 "src/google/protobuf/util/internal/type_info.cc",
101 "src/google/protobuf/util/internal/type_info_test_helper.cc",
102 "src/google/protobuf/util/internal/utility.cc",
103 "src/google/protobuf/util/json_util.cc",
104 "src/google/protobuf/util/message_differencer.cc",
105 "src/google/protobuf/util/type_resolver_util.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700106 "src/google/protobuf/wire_format.cc",
107 "src/google/protobuf/wrappers.pb.cc",
108 ],
109 copts = COPTS,
110 includes = ["src/"],
111 linkopts = LINK_OPTS,
112 visibility = ["//visibility:public"],
113 deps = [":protobuf_lite"],
114)
115
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700116objc_library(
117 name = "protobuf_objc",
118 hdrs = ["objectivec/GPBProtocolBuffers.h"],
119 includes = ["objectivec"],
120 non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
121 visibility = ["//visibility:public"],
122)
123
124WELL_KNOWN_PROTOS = [
125 # AUTOGEN(well_known_protos)
126 "google/protobuf/any.proto",
127 "google/protobuf/api.proto",
128 "google/protobuf/compiler/plugin.proto",
129 "google/protobuf/descriptor.proto",
130 "google/protobuf/duration.proto",
131 "google/protobuf/empty.proto",
132 "google/protobuf/field_mask.proto",
133 "google/protobuf/source_context.proto",
134 "google/protobuf/struct.proto",
135 "google/protobuf/timestamp.proto",
136 "google/protobuf/type.proto",
137 "google/protobuf/wrappers.proto",
138]
139
140################################################################################
141# Protocol Buffers Compiler
142################################################################################
143
Jisi Liud19604f2015-06-17 17:37:58 -0700144cc_library(
145 name = "protoc_lib",
146 srcs = [
147 # AUTOGEN(protoc_lib_srcs)
148 "src/google/protobuf/compiler/code_generator.cc",
149 "src/google/protobuf/compiler/command_line_interface.cc",
150 "src/google/protobuf/compiler/cpp/cpp_enum.cc",
151 "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
152 "src/google/protobuf/compiler/cpp/cpp_extension.cc",
153 "src/google/protobuf/compiler/cpp/cpp_field.cc",
154 "src/google/protobuf/compiler/cpp/cpp_file.cc",
155 "src/google/protobuf/compiler/cpp/cpp_generator.cc",
156 "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
157 "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
158 "src/google/protobuf/compiler/cpp/cpp_message.cc",
159 "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
160 "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
161 "src/google/protobuf/compiler/cpp/cpp_service.cc",
162 "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
163 "src/google/protobuf/compiler/csharp/csharp_enum.cc",
164 "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
165 "src/google/protobuf/compiler/csharp/csharp_extension.cc",
166 "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
167 "src/google/protobuf/compiler/csharp/csharp_generator.cc",
168 "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
169 "src/google/protobuf/compiler/csharp/csharp_message.cc",
170 "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
171 "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
172 "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
173 "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
174 "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
175 "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
176 "src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc",
177 "src/google/protobuf/compiler/csharp/csharp_writer.cc",
178 "src/google/protobuf/compiler/java/java_context.cc",
179 "src/google/protobuf/compiler/java/java_doc_comment.cc",
180 "src/google/protobuf/compiler/java/java_enum.cc",
181 "src/google/protobuf/compiler/java/java_enum_field.cc",
182 "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
183 "src/google/protobuf/compiler/java/java_extension.cc",
184 "src/google/protobuf/compiler/java/java_field.cc",
185 "src/google/protobuf/compiler/java/java_file.cc",
186 "src/google/protobuf/compiler/java/java_generator.cc",
187 "src/google/protobuf/compiler/java/java_generator_factory.cc",
188 "src/google/protobuf/compiler/java/java_helpers.cc",
189 "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
190 "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
191 "src/google/protobuf/compiler/java/java_map_field.cc",
192 "src/google/protobuf/compiler/java/java_map_field_lite.cc",
193 "src/google/protobuf/compiler/java/java_message.cc",
194 "src/google/protobuf/compiler/java/java_message_builder.cc",
195 "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
196 "src/google/protobuf/compiler/java/java_message_field.cc",
197 "src/google/protobuf/compiler/java/java_message_field_lite.cc",
198 "src/google/protobuf/compiler/java/java_message_lite.cc",
199 "src/google/protobuf/compiler/java/java_name_resolver.cc",
200 "src/google/protobuf/compiler/java/java_primitive_field.cc",
201 "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
202 "src/google/protobuf/compiler/java/java_service.cc",
203 "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
204 "src/google/protobuf/compiler/java/java_string_field.cc",
205 "src/google/protobuf/compiler/java/java_string_field_lite.cc",
206 "src/google/protobuf/compiler/javanano/javanano_enum.cc",
207 "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
208 "src/google/protobuf/compiler/javanano/javanano_extension.cc",
209 "src/google/protobuf/compiler/javanano/javanano_field.cc",
210 "src/google/protobuf/compiler/javanano/javanano_file.cc",
211 "src/google/protobuf/compiler/javanano/javanano_generator.cc",
212 "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
213 "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
214 "src/google/protobuf/compiler/javanano/javanano_message.cc",
215 "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
216 "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
217 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
218 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
219 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
220 "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
221 "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
222 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
223 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
224 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
225 "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
226 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
227 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
228 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
229 "src/google/protobuf/compiler/plugin.cc",
230 "src/google/protobuf/compiler/plugin.pb.cc",
231 "src/google/protobuf/compiler/python/python_generator.cc",
232 "src/google/protobuf/compiler/ruby/ruby_generator.cc",
233 "src/google/protobuf/compiler/subprocess.cc",
234 "src/google/protobuf/compiler/zip_writer.cc",
235 ],
236 copts = COPTS,
237 includes = ["src/"],
238 linkopts = LINK_OPTS,
239 visibility = ["//visibility:public"],
240 deps = [":protobuf"],
241)
242
243cc_binary(
244 name = "protoc",
245 srcs = ["src/google/protobuf/compiler/main.cc"],
Jisi Liud19604f2015-06-17 17:37:58 -0700246 linkopts = LINK_OPTS,
247 visibility = ["//visibility:public"],
248 deps = [":protoc_lib"],
249)
250
Jisi Liud19604f2015-06-17 17:37:58 -0700251################################################################################
252# Tests
253################################################################################
254
255LITE_TEST_PROTOS = [
256 # AUTOGEN(lite_test_protos)
257 "google/protobuf/map_lite_unittest.proto",
258 "google/protobuf/unittest_import_lite.proto",
259 "google/protobuf/unittest_import_public_lite.proto",
260 "google/protobuf/unittest_lite.proto",
261]
262
Jisi Liud19604f2015-06-17 17:37:58 -0700263TEST_PROTOS = [
264 # AUTOGEN(test_protos)
265 "google/protobuf/any_test.proto",
266 "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
267 "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
268 "google/protobuf/map_proto2_unittest.proto",
269 "google/protobuf/map_unittest.proto",
270 "google/protobuf/unittest.proto",
271 "google/protobuf/unittest_arena.proto",
272 "google/protobuf/unittest_custom_options.proto",
273 "google/protobuf/unittest_drop_unknown_fields.proto",
274 "google/protobuf/unittest_embed_optimize_for.proto",
275 "google/protobuf/unittest_empty.proto",
276 "google/protobuf/unittest_enormous_descriptor.proto",
277 "google/protobuf/unittest_import.proto",
278 "google/protobuf/unittest_import_public.proto",
279 "google/protobuf/unittest_lite_imports_nonlite.proto",
280 "google/protobuf/unittest_mset.proto",
281 "google/protobuf/unittest_no_arena.proto",
282 "google/protobuf/unittest_no_arena_import.proto",
283 "google/protobuf/unittest_no_field_presence.proto",
284 "google/protobuf/unittest_no_generic_services.proto",
285 "google/protobuf/unittest_optimize_for.proto",
286 "google/protobuf/unittest_preserve_unknown_enum.proto",
287 "google/protobuf/unittest_preserve_unknown_enum2.proto",
288 "google/protobuf/unittest_proto3_arena.proto",
289 "google/protobuf/unittest_well_known_types.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700290 "google/protobuf/util/internal/testdata/anys.proto",
291 "google/protobuf/util/internal/testdata/books.proto",
292 "google/protobuf/util/internal/testdata/default_value.proto",
293 "google/protobuf/util/internal/testdata/default_value_test.proto",
294 "google/protobuf/util/internal/testdata/field_mask.proto",
295 "google/protobuf/util/internal/testdata/maps.proto",
296 "google/protobuf/util/internal/testdata/struct.proto",
297 "google/protobuf/util/internal/testdata/timestamp_duration.proto",
298 "google/protobuf/util/json_format_proto3.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700299]
300
Jisi Liud19604f2015-06-17 17:37:58 -0700301PROTOS = LITE_TEST_PROTOS + TEST_PROTOS
302
303INPUTS = PROTOS + WELL_KNOWN_PROTOS
304
Jisi Liu7a0c4312015-06-18 16:45:27 -0700305OUTPUTS = ["src/" + x[:-5] + "pb.h" for x in PROTOS] + \
306 ["src/" + x[:-5] + "pb.cc" for x in PROTOS]
307
Jisi Liud19604f2015-06-17 17:37:58 -0700308genrule(
309 name = "gen_test_protos",
310 srcs = ["src/" + x for x in INPUTS],
Jisi Liu7a0c4312015-06-18 16:45:27 -0700311 outs = OUTPUTS,
Jisi Liud19604f2015-06-17 17:37:58 -0700312 cmd =
313 "$(location :protoc) --cpp_out=$(@D)/src" +
314 "".join([" -I" + x + "=$(location src/" + x + ")" for x in INPUTS]) +
315 "".join([" $(location src/" + x + ")" for x in PROTOS]),
316 tools = [":protoc"],
317)
318
319COMMON_TEST_SRCS = [
320 # AUTOGEN(common_test_srcs)
321 "src/google/protobuf/arena_test_util.cc",
322 "src/google/protobuf/map_test_util.cc",
323 "src/google/protobuf/test_util.cc",
324 "src/google/protobuf/testing/file.cc",
325 "src/google/protobuf/testing/googletest.cc",
326]
327
Jisi Liu7a0c4312015-06-18 16:45:27 -0700328cc_binary(
329 name = "test_plugin",
330 srcs = [
331 # AUTOGEN(test_plugin_srcs)
332 "src/google/protobuf/compiler/mock_code_generator.cc",
333 "src/google/protobuf/compiler/test_plugin.cc",
334 "src/google/protobuf/testing/file.cc",
335 ],
336 deps = [
337 ":protobuf",
338 ":protoc_lib",
339 "//external:gtest",
340 ],
341)
342
343cc_test(
344 name = "protobuf_test",
345 srcs = OUTPUTS + COMMON_TEST_SRCS + [
346 # AUTOGEN(test_srcs)
347 "src/google/protobuf/any_test.cc",
348 "src/google/protobuf/arena_unittest.cc",
349 "src/google/protobuf/arenastring_unittest.cc",
350 "src/google/protobuf/compiler/command_line_interface_unittest.cc",
351 "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
352 "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
353 "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
354 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
355 "src/google/protobuf/compiler/importer_unittest.cc",
356 "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
357 "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
358 "src/google/protobuf/compiler/mock_code_generator.cc",
359 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
360 "src/google/protobuf/compiler/parser_unittest.cc",
361 "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
362 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
363 "src/google/protobuf/descriptor_database_unittest.cc",
364 "src/google/protobuf/descriptor_unittest.cc",
365 "src/google/protobuf/drop_unknown_fields_test.cc",
366 "src/google/protobuf/dynamic_message_unittest.cc",
367 "src/google/protobuf/extension_set_unittest.cc",
368 "src/google/protobuf/generated_message_reflection_unittest.cc",
369 "src/google/protobuf/io/coded_stream_unittest.cc",
370 "src/google/protobuf/io/printer_unittest.cc",
371 "src/google/protobuf/io/tokenizer_unittest.cc",
372 "src/google/protobuf/io/zero_copy_stream_unittest.cc",
373 "src/google/protobuf/map_field_test.cc",
374 "src/google/protobuf/map_test.cc",
375 "src/google/protobuf/message_unittest.cc",
376 "src/google/protobuf/no_field_presence_test.cc",
377 "src/google/protobuf/preserve_unknown_enum_test.cc",
378 "src/google/protobuf/proto3_arena_unittest.cc",
379 "src/google/protobuf/reflection_ops_unittest.cc",
380 "src/google/protobuf/repeated_field_reflection_unittest.cc",
381 "src/google/protobuf/repeated_field_unittest.cc",
382 "src/google/protobuf/stubs/bytestream_unittest.cc",
383 "src/google/protobuf/stubs/common_unittest.cc",
384 "src/google/protobuf/stubs/once_unittest.cc",
385 "src/google/protobuf/stubs/status_test.cc",
386 "src/google/protobuf/stubs/statusor_test.cc",
387 "src/google/protobuf/stubs/stringpiece_unittest.cc",
388 "src/google/protobuf/stubs/stringprintf_unittest.cc",
389 "src/google/protobuf/stubs/structurally_valid_unittest.cc",
390 "src/google/protobuf/stubs/strutil_unittest.cc",
391 "src/google/protobuf/stubs/template_util_unittest.cc",
392 "src/google/protobuf/stubs/time_test.cc",
393 "src/google/protobuf/stubs/type_traits_unittest.cc",
394 "src/google/protobuf/text_format_unittest.cc",
395 "src/google/protobuf/unknown_field_set_unittest.cc",
396 "src/google/protobuf/util/field_comparator_test.cc",
397 "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
398 "src/google/protobuf/util/internal/json_objectwriter_test.cc",
399 "src/google/protobuf/util/internal/json_stream_parser_test.cc",
400 "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
401 "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
402 "src/google/protobuf/util/internal/type_info_test_helper.cc",
403 "src/google/protobuf/util/json_util_test.cc",
404 "src/google/protobuf/util/type_resolver_util_test.cc",
405 "src/google/protobuf/well_known_types_unittest.cc",
406 "src/google/protobuf/wire_format_unittest.cc",
407 ],
408 copts = COPTS,
409 data = [
410 ":test_plugin",
411 ],
412 includes = [
413 "src/",
414 ],
415 linkopts = LINK_OPTS,
416 deps = [
417 ":protobuf",
418 ":protoc_lib",
419 "//external:gtest_main",
420 ],
421)
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700422