1# Bazel (http://bazel.io/) BUILD file for Protobuf.
2
3licenses(["notice"])
4
5################################################################################
6# Protobuf Runtime Library
7################################################################################
8
9COPTS = [
10    "-DHAVE_PTHREAD",
11    "-Wall",
12    "-Wwrite-strings",
13    "-Woverloaded-virtual",
14    "-Wno-sign-compare",
15    "-Wno-error=unused-function",
16]
17
18config_setting(
19    name = "android",
20    values = {
21        "crosstool_top": "//external:android/crosstool",
22    },
23)
24
25# Android builds do not need to link in a separate pthread library.
26LINK_OPTS = select({
27    ":android": [],
28    "//conditions:default": ["-lpthread"],
29})
30
31load(
32    "protobuf",
33    "cc_proto_library",
34    "py_proto_library",
35    "internal_gen_well_known_protos_java",
36    "internal_protobuf_py_tests",
37)
38
39config_setting(
40    name = "ios_armv7",
41    values = {
42        "ios_cpu": "armv7",
43    },
44)
45
46config_setting(
47    name = "ios_armv7s",
48    values = {
49        "ios_cpu": "armv7s",
50    },
51)
52
53config_setting(
54    name = "ios_arm64",
55    values = {
56        "ios_cpu": "arm64",
57    },
58)
59
60IOS_ARM_COPTS = COPTS + [
61    "-DOS_IOS",
62    "-miphoneos-version-min=7.0",
63    "-arch armv7",
64    "-arch armv7s",
65    "-arch arm64",
66    "-D__thread=",
67    "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/",
68]
69
70cc_library(
71    name = "protobuf_lite",
72    srcs = [
73        # AUTOGEN(protobuf_lite_srcs)
74        "src/google/protobuf/arena.cc",
75        "src/google/protobuf/arenastring.cc",
76        "src/google/protobuf/extension_set.cc",
77        "src/google/protobuf/generated_message_util.cc",
78        "src/google/protobuf/io/coded_stream.cc",
79        "src/google/protobuf/io/zero_copy_stream.cc",
80        "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
81        "src/google/protobuf/message_lite.cc",
82        "src/google/protobuf/repeated_field.cc",
83        "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
84        "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
85        "src/google/protobuf/stubs/bytestream.cc",
86        "src/google/protobuf/stubs/common.cc",
87        "src/google/protobuf/stubs/int128.cc",
88        "src/google/protobuf/stubs/once.cc",
89        "src/google/protobuf/stubs/status.cc",
90        "src/google/protobuf/stubs/statusor.cc",
91        "src/google/protobuf/stubs/stringpiece.cc",
92        "src/google/protobuf/stubs/stringprintf.cc",
93        "src/google/protobuf/stubs/structurally_valid.cc",
94        "src/google/protobuf/stubs/strutil.cc",
95        "src/google/protobuf/stubs/time.cc",
96        "src/google/protobuf/wire_format_lite.cc",
97    ],
98    hdrs = glob(["src/google/protobuf/**/*.h"]),
99    copts = select({
100        ":ios_armv7": IOS_ARM_COPTS,
101        ":ios_armv7s": IOS_ARM_COPTS,
102        ":ios_arm64": IOS_ARM_COPTS,
103        "//conditions:default": COPTS,
104    }),
105    includes = ["src/"],
106    linkopts = LINK_OPTS,
107    visibility = ["//visibility:public"],
108)
109
110cc_library(
111    name = "protobuf",
112    srcs = [
113        # AUTOGEN(protobuf_srcs)
114        "src/google/protobuf/any.cc",
115        "src/google/protobuf/any.pb.cc",
116        "src/google/protobuf/api.pb.cc",
117        "src/google/protobuf/compiler/importer.cc",
118        "src/google/protobuf/compiler/parser.cc",
119        "src/google/protobuf/descriptor.cc",
120        "src/google/protobuf/descriptor.pb.cc",
121        "src/google/protobuf/descriptor_database.cc",
122        "src/google/protobuf/duration.pb.cc",
123        "src/google/protobuf/dynamic_message.cc",
124        "src/google/protobuf/empty.pb.cc",
125        "src/google/protobuf/extension_set_heavy.cc",
126        "src/google/protobuf/field_mask.pb.cc",
127        "src/google/protobuf/generated_message_reflection.cc",
128        "src/google/protobuf/io/gzip_stream.cc",
129        "src/google/protobuf/io/printer.cc",
130        "src/google/protobuf/io/strtod.cc",
131        "src/google/protobuf/io/tokenizer.cc",
132        "src/google/protobuf/io/zero_copy_stream_impl.cc",
133        "src/google/protobuf/map_field.cc",
134        "src/google/protobuf/message.cc",
135        "src/google/protobuf/reflection_ops.cc",
136        "src/google/protobuf/service.cc",
137        "src/google/protobuf/source_context.pb.cc",
138        "src/google/protobuf/struct.pb.cc",
139        "src/google/protobuf/stubs/mathlimits.cc",
140        "src/google/protobuf/stubs/substitute.cc",
141        "src/google/protobuf/text_format.cc",
142        "src/google/protobuf/timestamp.pb.cc",
143        "src/google/protobuf/type.pb.cc",
144        "src/google/protobuf/unknown_field_set.cc",
145        "src/google/protobuf/util/field_comparator.cc",
146        "src/google/protobuf/util/field_mask_util.cc",
147        "src/google/protobuf/util/internal/datapiece.cc",
148        "src/google/protobuf/util/internal/default_value_objectwriter.cc",
149        "src/google/protobuf/util/internal/error_listener.cc",
150        "src/google/protobuf/util/internal/field_mask_utility.cc",
151        "src/google/protobuf/util/internal/json_escaping.cc",
152        "src/google/protobuf/util/internal/json_objectwriter.cc",
153        "src/google/protobuf/util/internal/json_stream_parser.cc",
154        "src/google/protobuf/util/internal/object_writer.cc",
155        "src/google/protobuf/util/internal/proto_writer.cc",
156        "src/google/protobuf/util/internal/protostream_objectsource.cc",
157        "src/google/protobuf/util/internal/protostream_objectwriter.cc",
158        "src/google/protobuf/util/internal/type_info.cc",
159        "src/google/protobuf/util/internal/type_info_test_helper.cc",
160        "src/google/protobuf/util/internal/utility.cc",
161        "src/google/protobuf/util/json_util.cc",
162        "src/google/protobuf/util/message_differencer.cc",
163        "src/google/protobuf/util/time_util.cc",
164        "src/google/protobuf/util/type_resolver_util.cc",
165        "src/google/protobuf/wire_format.cc",
166        "src/google/protobuf/wrappers.pb.cc",
167    ],
168    hdrs = glob(["src/**/*.h"]),
169    copts = select({
170        ":ios_armv7": IOS_ARM_COPTS,
171        ":ios_armv7s": IOS_ARM_COPTS,
172        ":ios_arm64": IOS_ARM_COPTS,
173        "//conditions:default": COPTS,
174    }),
175    includes = ["src/"],
176    linkopts = LINK_OPTS,
177    visibility = ["//visibility:public"],
178    deps = [":protobuf_lite"],
179)
180
181objc_library(
182    name = "protobuf_objc",
183    hdrs = ["objectivec/GPBProtocolBuffers.h"],
184    includes = ["objectivec"],
185    non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
186    visibility = ["//visibility:public"],
187)
188
189RELATIVE_WELL_KNOWN_PROTOS = [
190    # AUTOGEN(well_known_protos)
191    "google/protobuf/any.proto",
192    "google/protobuf/api.proto",
193    "google/protobuf/compiler/plugin.proto",
194    "google/protobuf/descriptor.proto",
195    "google/protobuf/duration.proto",
196    "google/protobuf/empty.proto",
197    "google/protobuf/field_mask.proto",
198    "google/protobuf/source_context.proto",
199    "google/protobuf/struct.proto",
200    "google/protobuf/timestamp.proto",
201    "google/protobuf/type.proto",
202    "google/protobuf/wrappers.proto",
203]
204
205WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
206
207filegroup(
208    name = "well_known_protos",
209    srcs = WELL_KNOWN_PROTOS,
210    visibility = ["//visibility:public"],
211)
212
213cc_proto_library(
214    name = "cc_wkt_protos",
215    srcs = WELL_KNOWN_PROTOS,
216    include = "src",
217    default_runtime = ":protobuf",
218    internal_bootstrap_hack = 1,
219    protoc = ":protoc",
220    visibility = ["//visibility:public"],
221)
222
223################################################################################
224# Protocol Buffers Compiler
225################################################################################
226
227cc_library(
228    name = "protoc_lib",
229    srcs = [
230        # AUTOGEN(protoc_lib_srcs)
231        "src/google/protobuf/compiler/code_generator.cc",
232        "src/google/protobuf/compiler/command_line_interface.cc",
233        "src/google/protobuf/compiler/cpp/cpp_enum.cc",
234        "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
235        "src/google/protobuf/compiler/cpp/cpp_extension.cc",
236        "src/google/protobuf/compiler/cpp/cpp_field.cc",
237        "src/google/protobuf/compiler/cpp/cpp_file.cc",
238        "src/google/protobuf/compiler/cpp/cpp_generator.cc",
239        "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
240        "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
241        "src/google/protobuf/compiler/cpp/cpp_message.cc",
242        "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
243        "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
244        "src/google/protobuf/compiler/cpp/cpp_service.cc",
245        "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
246        "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
247        "src/google/protobuf/compiler/csharp/csharp_enum.cc",
248        "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
249        "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
250        "src/google/protobuf/compiler/csharp/csharp_generator.cc",
251        "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
252        "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
253        "src/google/protobuf/compiler/csharp/csharp_message.cc",
254        "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
255        "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
256        "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
257        "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
258        "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
259        "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
260        "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
261        "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
262        "src/google/protobuf/compiler/java/java_context.cc",
263        "src/google/protobuf/compiler/java/java_doc_comment.cc",
264        "src/google/protobuf/compiler/java/java_enum.cc",
265        "src/google/protobuf/compiler/java/java_enum_field.cc",
266        "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
267        "src/google/protobuf/compiler/java/java_enum_lite.cc",
268        "src/google/protobuf/compiler/java/java_extension.cc",
269        "src/google/protobuf/compiler/java/java_extension_lite.cc",
270        "src/google/protobuf/compiler/java/java_field.cc",
271        "src/google/protobuf/compiler/java/java_file.cc",
272        "src/google/protobuf/compiler/java/java_generator.cc",
273        "src/google/protobuf/compiler/java/java_generator_factory.cc",
274        "src/google/protobuf/compiler/java/java_helpers.cc",
275        "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
276        "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
277        "src/google/protobuf/compiler/java/java_map_field.cc",
278        "src/google/protobuf/compiler/java/java_map_field_lite.cc",
279        "src/google/protobuf/compiler/java/java_message.cc",
280        "src/google/protobuf/compiler/java/java_message_builder.cc",
281        "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
282        "src/google/protobuf/compiler/java/java_message_field.cc",
283        "src/google/protobuf/compiler/java/java_message_field_lite.cc",
284        "src/google/protobuf/compiler/java/java_message_lite.cc",
285        "src/google/protobuf/compiler/java/java_name_resolver.cc",
286        "src/google/protobuf/compiler/java/java_primitive_field.cc",
287        "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
288        "src/google/protobuf/compiler/java/java_service.cc",
289        "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
290        "src/google/protobuf/compiler/java/java_string_field.cc",
291        "src/google/protobuf/compiler/java/java_string_field_lite.cc",
292        "src/google/protobuf/compiler/javanano/javanano_enum.cc",
293        "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
294        "src/google/protobuf/compiler/javanano/javanano_extension.cc",
295        "src/google/protobuf/compiler/javanano/javanano_field.cc",
296        "src/google/protobuf/compiler/javanano/javanano_file.cc",
297        "src/google/protobuf/compiler/javanano/javanano_generator.cc",
298        "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
299        "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
300        "src/google/protobuf/compiler/javanano/javanano_message.cc",
301        "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
302        "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
303        "src/google/protobuf/compiler/js/js_generator.cc",
304        "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
305        "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
306        "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
307        "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
308        "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
309        "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
310        "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
311        "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
312        "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
313        "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
314        "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
315        "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
316        "src/google/protobuf/compiler/plugin.cc",
317        "src/google/protobuf/compiler/plugin.pb.cc",
318        "src/google/protobuf/compiler/python/python_generator.cc",
319        "src/google/protobuf/compiler/ruby/ruby_generator.cc",
320        "src/google/protobuf/compiler/subprocess.cc",
321        "src/google/protobuf/compiler/zip_writer.cc",
322    ],
323    copts = COPTS,
324    includes = ["src/"],
325    linkopts = LINK_OPTS,
326    visibility = ["//visibility:public"],
327    deps = [":protobuf"],
328)
329
330cc_binary(
331    name = "protoc",
332    srcs = ["src/google/protobuf/compiler/main.cc"],
333    linkopts = LINK_OPTS,
334    visibility = ["//visibility:public"],
335    deps = [":protoc_lib"],
336)
337
338################################################################################
339# Tests
340################################################################################
341
342RELATIVE_LITE_TEST_PROTOS = [
343    # AUTOGEN(lite_test_protos)
344    "google/protobuf/map_lite_unittest.proto",
345    "google/protobuf/unittest_import_lite.proto",
346    "google/protobuf/unittest_import_public_lite.proto",
347    "google/protobuf/unittest_lite.proto",
348    "google/protobuf/unittest_no_arena_lite.proto",
349]
350
351LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
352
353RELATIVE_TEST_PROTOS = [
354    # AUTOGEN(test_protos)
355    "google/protobuf/any_test.proto",
356    "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
357    "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
358    "google/protobuf/map_proto2_unittest.proto",
359    "google/protobuf/map_unittest.proto",
360    "google/protobuf/unittest.proto",
361    "google/protobuf/unittest_arena.proto",
362    "google/protobuf/unittest_custom_options.proto",
363    "google/protobuf/unittest_drop_unknown_fields.proto",
364    "google/protobuf/unittest_embed_optimize_for.proto",
365    "google/protobuf/unittest_empty.proto",
366    "google/protobuf/unittest_enormous_descriptor.proto",
367    "google/protobuf/unittest_import.proto",
368    "google/protobuf/unittest_import_public.proto",
369    "google/protobuf/unittest_lite_imports_nonlite.proto",
370    "google/protobuf/unittest_mset.proto",
371    "google/protobuf/unittest_mset_wire_format.proto",
372    "google/protobuf/unittest_no_arena.proto",
373    "google/protobuf/unittest_no_arena_import.proto",
374    "google/protobuf/unittest_no_field_presence.proto",
375    "google/protobuf/unittest_no_generic_services.proto",
376    "google/protobuf/unittest_optimize_for.proto",
377    "google/protobuf/unittest_preserve_unknown_enum.proto",
378    "google/protobuf/unittest_preserve_unknown_enum2.proto",
379    "google/protobuf/unittest_proto3_arena.proto",
380    "google/protobuf/unittest_proto3_arena_lite.proto",
381    "google/protobuf/unittest_proto3_lite.proto",
382    "google/protobuf/unittest_well_known_types.proto",
383    "google/protobuf/util/internal/testdata/anys.proto",
384    "google/protobuf/util/internal/testdata/books.proto",
385    "google/protobuf/util/internal/testdata/default_value.proto",
386    "google/protobuf/util/internal/testdata/default_value_test.proto",
387    "google/protobuf/util/internal/testdata/field_mask.proto",
388    "google/protobuf/util/internal/testdata/maps.proto",
389    "google/protobuf/util/internal/testdata/oneofs.proto",
390    "google/protobuf/util/internal/testdata/struct.proto",
391    "google/protobuf/util/internal/testdata/timestamp_duration.proto",
392    "google/protobuf/util/json_format_proto3.proto",
393    "google/protobuf/util/message_differencer_unittest.proto",
394]
395
396TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
397
398cc_proto_library(
399    name = "cc_test_protos",
400    srcs = LITE_TEST_PROTOS + TEST_PROTOS,
401    include = "src",
402    default_runtime = ":protobuf",
403    protoc = ":protoc",
404    deps = [":cc_wkt_protos"],
405)
406
407COMMON_TEST_SRCS = [
408    # AUTOGEN(common_test_srcs)
409    "src/google/protobuf/arena_test_util.cc",
410    "src/google/protobuf/map_test_util.cc",
411    "src/google/protobuf/test_util.cc",
412    "src/google/protobuf/testing/file.cc",
413    "src/google/protobuf/testing/googletest.cc",
414]
415
416cc_binary(
417    name = "test_plugin",
418    srcs = [
419        # AUTOGEN(test_plugin_srcs)
420        "src/google/protobuf/compiler/mock_code_generator.cc",
421        "src/google/protobuf/compiler/test_plugin.cc",
422        "src/google/protobuf/testing/file.cc",
423    ],
424    deps = [
425        ":protobuf",
426        ":protoc_lib",
427        "//external:gtest",
428    ],
429)
430
431cc_test(
432    name = "protobuf_test",
433    srcs = COMMON_TEST_SRCS + [
434        # AUTOGEN(test_srcs)
435        "src/google/protobuf/any_test.cc",
436        "src/google/protobuf/arena_unittest.cc",
437        "src/google/protobuf/arenastring_unittest.cc",
438        "src/google/protobuf/compiler/command_line_interface_unittest.cc",
439        "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
440        "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
441        "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
442        "src/google/protobuf/compiler/cpp/metadata_test.cc",
443        "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
444        "src/google/protobuf/compiler/importer_unittest.cc",
445        "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
446        "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
447        "src/google/protobuf/compiler/mock_code_generator.cc",
448        "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
449        "src/google/protobuf/compiler/parser_unittest.cc",
450        "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
451        "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
452        "src/google/protobuf/descriptor_database_unittest.cc",
453        "src/google/protobuf/descriptor_unittest.cc",
454        "src/google/protobuf/drop_unknown_fields_test.cc",
455        "src/google/protobuf/dynamic_message_unittest.cc",
456        "src/google/protobuf/extension_set_unittest.cc",
457        "src/google/protobuf/generated_message_reflection_unittest.cc",
458        "src/google/protobuf/io/coded_stream_unittest.cc",
459        "src/google/protobuf/io/printer_unittest.cc",
460        "src/google/protobuf/io/tokenizer_unittest.cc",
461        "src/google/protobuf/io/zero_copy_stream_unittest.cc",
462        "src/google/protobuf/map_field_test.cc",
463        "src/google/protobuf/map_test.cc",
464        "src/google/protobuf/message_unittest.cc",
465        "src/google/protobuf/no_field_presence_test.cc",
466        "src/google/protobuf/preserve_unknown_enum_test.cc",
467        "src/google/protobuf/proto3_arena_lite_unittest.cc",
468        "src/google/protobuf/proto3_arena_unittest.cc",
469        "src/google/protobuf/proto3_lite_unittest.cc",
470        "src/google/protobuf/reflection_ops_unittest.cc",
471        "src/google/protobuf/repeated_field_reflection_unittest.cc",
472        "src/google/protobuf/repeated_field_unittest.cc",
473        "src/google/protobuf/stubs/bytestream_unittest.cc",
474        "src/google/protobuf/stubs/common_unittest.cc",
475        "src/google/protobuf/stubs/int128_unittest.cc",
476        "src/google/protobuf/stubs/once_unittest.cc",
477        "src/google/protobuf/stubs/status_test.cc",
478        "src/google/protobuf/stubs/statusor_test.cc",
479        "src/google/protobuf/stubs/stringpiece_unittest.cc",
480        "src/google/protobuf/stubs/stringprintf_unittest.cc",
481        "src/google/protobuf/stubs/structurally_valid_unittest.cc",
482        "src/google/protobuf/stubs/strutil_unittest.cc",
483        "src/google/protobuf/stubs/template_util_unittest.cc",
484        "src/google/protobuf/stubs/time_test.cc",
485        "src/google/protobuf/stubs/type_traits_unittest.cc",
486        "src/google/protobuf/text_format_unittest.cc",
487        "src/google/protobuf/unknown_field_set_unittest.cc",
488        "src/google/protobuf/util/field_comparator_test.cc",
489        "src/google/protobuf/util/field_mask_util_test.cc",
490        "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
491        "src/google/protobuf/util/internal/json_objectwriter_test.cc",
492        "src/google/protobuf/util/internal/json_stream_parser_test.cc",
493        "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
494        "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
495        "src/google/protobuf/util/internal/type_info_test_helper.cc",
496        "src/google/protobuf/util/json_util_test.cc",
497        "src/google/protobuf/util/message_differencer_unittest.cc",
498        "src/google/protobuf/util/time_util_test.cc",
499        "src/google/protobuf/util/type_resolver_util_test.cc",
500        "src/google/protobuf/well_known_types_unittest.cc",
501        "src/google/protobuf/wire_format_unittest.cc",
502    ],
503    copts = COPTS,
504    data = [
505        ":test_plugin",
506    ] + glob([
507        "src/google/protobuf/**/*",
508    ]),
509    includes = [
510        "src/",
511    ],
512    linkopts = LINK_OPTS,
513    deps = [
514        ":cc_test_protos",
515        ":protobuf",
516        ":protoc_lib",
517        "//external:gtest_main",
518    ],
519)
520
521################################################################################
522# Java support
523################################################################################
524internal_gen_well_known_protos_java(
525    srcs = WELL_KNOWN_PROTOS,
526)
527
528java_library(
529    name = "protobuf_java",
530    srcs = glob([
531        "java/core/src/main/java/com/google/protobuf/*.java",
532    ]) + [
533        ":gen_well_known_protos_java",
534    ],
535    visibility = ["//visibility:public"],
536)
537
538java_library(
539    name = "protobuf_java_util",
540    srcs = glob([
541        "java/util/src/main/java/com/google/protobuf/util/*.java",
542    ]),
543    deps = [
544        "protobuf_java",
545        "//external:gson",
546        "//external:guava",
547    ],
548    visibility = ["//visibility:public"],
549)
550
551################################################################################
552# Python support
553################################################################################
554
555py_library(
556    name = "python_srcs",
557    srcs = glob(
558        [
559            "python/google/protobuf/*.py",
560            "python/google/protobuf/**/*.py",
561        ],
562        exclude = [
563            "python/google/protobuf/internal/*_test.py",
564            "python/google/protobuf/internal/test_util.py",
565        ],
566    ),
567    srcs_version = "PY2AND3",
568    imports = ["python"],
569)
570
571cc_binary(
572    name = "internal/_api_implementation.so",
573    srcs = ["python/google/protobuf/internal/api_implementation.cc"],
574    copts = COPTS + [
575        "-DPYTHON_PROTO2_CPP_IMPL_V2",
576    ],
577    linkshared = 1,
578    linkstatic = 1,
579    deps = select({
580        "//conditions:default": [],
581        ":use_fast_cpp_protos": ["//external:python_headers"],
582    }),
583)
584
585cc_binary(
586    name = "pyext/_message.so",
587    srcs = glob([
588        "python/google/protobuf/pyext/*.cc",
589        "python/google/protobuf/pyext/*.h",
590    ]),
591    copts = COPTS + [
592        "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
593    ] + select({
594        "//conditions:default": [],
595        ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
596    }),
597    includes = [
598        "python/",
599        "src/",
600    ],
601    linkshared = 1,
602    linkstatic = 1,
603    deps = [
604        ":protobuf",
605    ] + select({
606        "//conditions:default": [],
607        ":use_fast_cpp_protos": ["//external:python_headers"],
608    }),
609)
610
611config_setting(
612    name = "use_fast_cpp_protos",
613    values = {
614        "define": "use_fast_cpp_protos=true",
615    },
616)
617
618config_setting(
619    name = "allow_oversize_protos",
620    values = {
621        "define": "allow_oversize_protos=true",
622    },
623)
624
625py_proto_library(
626    name = "protobuf_python",
627    srcs = WELL_KNOWN_PROTOS,
628    include = "src",
629    data = select({
630        "//conditions:default": [],
631        ":use_fast_cpp_protos": [
632            ":internal/_api_implementation.so",
633            ":pyext/_message.so",
634        ],
635    }),
636    default_runtime = "",
637    protoc = ":protoc",
638    py_libs = [
639        ":python_srcs",
640        "//external:six"
641    ],
642    srcs_version = "PY2AND3",
643    visibility = ["//visibility:public"],
644)
645
646py_proto_library(
647    name = "python_common_test_protos",
648    srcs = LITE_TEST_PROTOS + TEST_PROTOS,
649    include = "src",
650    default_runtime = "",
651    protoc = ":protoc",
652    srcs_version = "PY2AND3",
653    deps = [":protobuf_python"],
654)
655
656py_proto_library(
657    name = "python_specific_test_protos",
658    srcs = glob([
659        "python/google/protobuf/internal/*.proto",
660        "python/google/protobuf/internal/import_test_package/*.proto",
661    ]),
662    include = "python",
663    default_runtime = ":protobuf_python",
664    protoc = ":protoc",
665    srcs_version = "PY2AND3",
666    deps = [":python_common_test_protos"],
667)
668
669py_library(
670    name = "python_tests",
671    srcs = glob(
672        [
673            "python/google/protobuf/internal/*_test.py",
674            "python/google/protobuf/internal/test_util.py",
675        ],
676    ),
677    imports = ["python"],
678    srcs_version = "PY2AND3",
679    deps = [
680        ":protobuf_python",
681        ":python_common_test_protos",
682        ":python_specific_test_protos",
683    ],
684)
685
686internal_protobuf_py_tests(
687    name = "python_tests_batch",
688    data = glob([
689        "src/google/protobuf/**/*",
690    ]),
691    modules = [
692        "descriptor_database_test",
693        "descriptor_pool_test",
694        "descriptor_test",
695        "generator_test",
696        "json_format_test",
697        "message_factory_test",
698        "message_test",
699        "proto_builder_test",
700        "reflection_test",
701        "service_reflection_test",
702        "symbol_database_test",
703        "text_encoding_test",
704        "text_format_test",
705        "unknown_fields_test",
706        "wire_format_test",
707    ],
708    deps = [":python_tests"],
709)
710