blob: 9cbddd5bf69a94e9689236d64bfff70af5c7c520 [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
Jisi Liu04658a32015-10-20 15:00:13 -070021load(
22 "protobuf",
23 "cc_proto_library",
24 "py_proto_library",
Jisi Liu04658a32015-10-20 15:00:13 -070025 "internal_protobuf_py_tests",
26)
Jisi Liu39362b32015-10-14 17:12:11 -070027
Jisi Liud19604f2015-06-17 17:37:58 -070028cc_library(
29 name = "protobuf_lite",
30 srcs = [
31 # AUTOGEN(protobuf_lite_srcs)
32 "src/google/protobuf/arena.cc",
33 "src/google/protobuf/arenastring.cc",
34 "src/google/protobuf/extension_set.cc",
35 "src/google/protobuf/generated_message_util.cc",
36 "src/google/protobuf/io/coded_stream.cc",
37 "src/google/protobuf/io/zero_copy_stream.cc",
38 "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
39 "src/google/protobuf/message_lite.cc",
40 "src/google/protobuf/repeated_field.cc",
41 "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
42 "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070043 "src/google/protobuf/stubs/bytestream.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070044 "src/google/protobuf/stubs/common.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -070045 "src/google/protobuf/stubs/int128.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070046 "src/google/protobuf/stubs/once.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070047 "src/google/protobuf/stubs/status.cc",
48 "src/google/protobuf/stubs/statusor.cc",
49 "src/google/protobuf/stubs/stringpiece.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070050 "src/google/protobuf/stubs/stringprintf.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -070051 "src/google/protobuf/stubs/structurally_valid.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070052 "src/google/protobuf/stubs/strutil.cc",
53 "src/google/protobuf/stubs/time.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070054 "src/google/protobuf/wire_format_lite.cc",
55 ],
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -080056 hdrs = glob(["src/google/protobuf/**/*.h"]),
Jisi Liud19604f2015-06-17 17:37:58 -070057 copts = COPTS,
58 includes = ["src/"],
59 linkopts = LINK_OPTS,
60 visibility = ["//visibility:public"],
61)
62
63cc_library(
64 name = "protobuf",
65 srcs = [
66 # AUTOGEN(protobuf_srcs)
67 "src/google/protobuf/any.cc",
68 "src/google/protobuf/any.pb.cc",
69 "src/google/protobuf/api.pb.cc",
70 "src/google/protobuf/compiler/importer.cc",
71 "src/google/protobuf/compiler/parser.cc",
72 "src/google/protobuf/descriptor.cc",
73 "src/google/protobuf/descriptor.pb.cc",
74 "src/google/protobuf/descriptor_database.cc",
75 "src/google/protobuf/duration.pb.cc",
76 "src/google/protobuf/dynamic_message.cc",
77 "src/google/protobuf/empty.pb.cc",
78 "src/google/protobuf/extension_set_heavy.cc",
79 "src/google/protobuf/field_mask.pb.cc",
80 "src/google/protobuf/generated_message_reflection.cc",
81 "src/google/protobuf/io/gzip_stream.cc",
82 "src/google/protobuf/io/printer.cc",
83 "src/google/protobuf/io/strtod.cc",
84 "src/google/protobuf/io/tokenizer.cc",
85 "src/google/protobuf/io/zero_copy_stream_impl.cc",
86 "src/google/protobuf/map_field.cc",
87 "src/google/protobuf/message.cc",
88 "src/google/protobuf/reflection_ops.cc",
89 "src/google/protobuf/service.cc",
90 "src/google/protobuf/source_context.pb.cc",
91 "src/google/protobuf/struct.pb.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070092 "src/google/protobuf/stubs/mathlimits.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070093 "src/google/protobuf/stubs/substitute.cc",
94 "src/google/protobuf/text_format.cc",
95 "src/google/protobuf/timestamp.pb.cc",
96 "src/google/protobuf/type.pb.cc",
97 "src/google/protobuf/unknown_field_set.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070098 "src/google/protobuf/util/field_comparator.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -070099 "src/google/protobuf/util/field_mask_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700100 "src/google/protobuf/util/internal/datapiece.cc",
101 "src/google/protobuf/util/internal/default_value_objectwriter.cc",
102 "src/google/protobuf/util/internal/error_listener.cc",
103 "src/google/protobuf/util/internal/field_mask_utility.cc",
104 "src/google/protobuf/util/internal/json_escaping.cc",
105 "src/google/protobuf/util/internal/json_objectwriter.cc",
106 "src/google/protobuf/util/internal/json_stream_parser.cc",
107 "src/google/protobuf/util/internal/object_writer.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800108 "src/google/protobuf/util/internal/proto_writer.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700109 "src/google/protobuf/util/internal/protostream_objectsource.cc",
110 "src/google/protobuf/util/internal/protostream_objectwriter.cc",
111 "src/google/protobuf/util/internal/type_info.cc",
112 "src/google/protobuf/util/internal/type_info_test_helper.cc",
113 "src/google/protobuf/util/internal/utility.cc",
114 "src/google/protobuf/util/json_util.cc",
115 "src/google/protobuf/util/message_differencer.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700116 "src/google/protobuf/util/time_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700117 "src/google/protobuf/util/type_resolver_util.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700118 "src/google/protobuf/wire_format.cc",
119 "src/google/protobuf/wrappers.pb.cc",
120 ],
Lukacs T. Berki915d9cd2015-11-16 09:36:32 +0100121 hdrs = glob(["src/**/*.h"]),
Jisi Liud19604f2015-06-17 17:37:58 -0700122 copts = COPTS,
123 includes = ["src/"],
124 linkopts = LINK_OPTS,
125 visibility = ["//visibility:public"],
126 deps = [":protobuf_lite"],
127)
128
Jisi Liu14c8f8a2015-10-20 15:36:22 -0700129objc_library(
130 name = "protobuf_objc",
131 hdrs = ["objectivec/GPBProtocolBuffers.h"],
132 includes = ["objectivec"],
133 non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
134 visibility = ["//visibility:public"],
135)
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700136
Jisi Liu993fb702015-10-19 17:19:49 -0700137RELATIVE_WELL_KNOWN_PROTOS = [
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700138 # AUTOGEN(well_known_protos)
139 "google/protobuf/any.proto",
140 "google/protobuf/api.proto",
141 "google/protobuf/compiler/plugin.proto",
142 "google/protobuf/descriptor.proto",
143 "google/protobuf/duration.proto",
144 "google/protobuf/empty.proto",
145 "google/protobuf/field_mask.proto",
146 "google/protobuf/source_context.proto",
147 "google/protobuf/struct.proto",
148 "google/protobuf/timestamp.proto",
149 "google/protobuf/type.proto",
150 "google/protobuf/wrappers.proto",
151]
152
Jisi Liu993fb702015-10-19 17:19:49 -0700153WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
154
Jisi Liu39362b32015-10-14 17:12:11 -0700155cc_proto_library(
156 name = "cc_wkt_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700157 srcs = WELL_KNOWN_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700158 include = "src",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800159 default_runtime = ":protobuf",
Jisi Liu993fb702015-10-19 17:19:49 -0700160 internal_bootstrap_hack = 1,
Jisi Liu04658a32015-10-20 15:00:13 -0700161 protoc = ":protoc",
Jisi Liu6a40bf82015-11-17 12:36:21 -0800162 visibility = ["//visibility:public"],
Jisi Liu39362b32015-10-14 17:12:11 -0700163)
164
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700165################################################################################
166# Protocol Buffers Compiler
167################################################################################
168
Jisi Liud19604f2015-06-17 17:37:58 -0700169cc_library(
170 name = "protoc_lib",
171 srcs = [
172 # AUTOGEN(protoc_lib_srcs)
173 "src/google/protobuf/compiler/code_generator.cc",
174 "src/google/protobuf/compiler/command_line_interface.cc",
175 "src/google/protobuf/compiler/cpp/cpp_enum.cc",
176 "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
177 "src/google/protobuf/compiler/cpp/cpp_extension.cc",
178 "src/google/protobuf/compiler/cpp/cpp_field.cc",
179 "src/google/protobuf/compiler/cpp/cpp_file.cc",
180 "src/google/protobuf/compiler/cpp/cpp_generator.cc",
181 "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
182 "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
183 "src/google/protobuf/compiler/cpp/cpp_message.cc",
184 "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
185 "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
186 "src/google/protobuf/compiler/cpp/cpp_service.cc",
187 "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
Ming Zhao5cdd9362015-10-05 14:37:21 -0700188 "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700189 "src/google/protobuf/compiler/csharp/csharp_enum.cc",
190 "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700191 "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
192 "src/google/protobuf/compiler/csharp/csharp_generator.cc",
193 "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100194 "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700195 "src/google/protobuf/compiler/csharp/csharp_message.cc",
196 "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
197 "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
Jon Skeeta6361a12015-11-19 13:05:17 +0000198 "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700199 "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
200 "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
201 "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
202 "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100203 "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700204 "src/google/protobuf/compiler/java/java_context.cc",
205 "src/google/protobuf/compiler/java/java_doc_comment.cc",
206 "src/google/protobuf/compiler/java/java_enum.cc",
207 "src/google/protobuf/compiler/java/java_enum_field.cc",
208 "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700209 "src/google/protobuf/compiler/java/java_enum_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700210 "src/google/protobuf/compiler/java/java_extension.cc",
211 "src/google/protobuf/compiler/java/java_field.cc",
212 "src/google/protobuf/compiler/java/java_file.cc",
213 "src/google/protobuf/compiler/java/java_generator.cc",
214 "src/google/protobuf/compiler/java/java_generator_factory.cc",
215 "src/google/protobuf/compiler/java/java_helpers.cc",
216 "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
217 "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
218 "src/google/protobuf/compiler/java/java_map_field.cc",
219 "src/google/protobuf/compiler/java/java_map_field_lite.cc",
220 "src/google/protobuf/compiler/java/java_message.cc",
221 "src/google/protobuf/compiler/java/java_message_builder.cc",
222 "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
223 "src/google/protobuf/compiler/java/java_message_field.cc",
224 "src/google/protobuf/compiler/java/java_message_field_lite.cc",
225 "src/google/protobuf/compiler/java/java_message_lite.cc",
226 "src/google/protobuf/compiler/java/java_name_resolver.cc",
227 "src/google/protobuf/compiler/java/java_primitive_field.cc",
228 "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
229 "src/google/protobuf/compiler/java/java_service.cc",
230 "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
231 "src/google/protobuf/compiler/java/java_string_field.cc",
232 "src/google/protobuf/compiler/java/java_string_field_lite.cc",
233 "src/google/protobuf/compiler/javanano/javanano_enum.cc",
234 "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
235 "src/google/protobuf/compiler/javanano/javanano_extension.cc",
236 "src/google/protobuf/compiler/javanano/javanano_field.cc",
237 "src/google/protobuf/compiler/javanano/javanano_file.cc",
238 "src/google/protobuf/compiler/javanano/javanano_generator.cc",
239 "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
240 "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
241 "src/google/protobuf/compiler/javanano/javanano_message.cc",
242 "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
243 "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800244 "src/google/protobuf/compiler/js/js_generator.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700245 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
246 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
247 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
248 "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
249 "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
250 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
251 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
252 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
253 "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
254 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
255 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
256 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
257 "src/google/protobuf/compiler/plugin.cc",
258 "src/google/protobuf/compiler/plugin.pb.cc",
259 "src/google/protobuf/compiler/python/python_generator.cc",
260 "src/google/protobuf/compiler/ruby/ruby_generator.cc",
261 "src/google/protobuf/compiler/subprocess.cc",
262 "src/google/protobuf/compiler/zip_writer.cc",
263 ],
264 copts = COPTS,
265 includes = ["src/"],
266 linkopts = LINK_OPTS,
267 visibility = ["//visibility:public"],
268 deps = [":protobuf"],
269)
270
271cc_binary(
272 name = "protoc",
273 srcs = ["src/google/protobuf/compiler/main.cc"],
Jisi Liud19604f2015-06-17 17:37:58 -0700274 linkopts = LINK_OPTS,
275 visibility = ["//visibility:public"],
276 deps = [":protoc_lib"],
277)
278
Jisi Liud19604f2015-06-17 17:37:58 -0700279################################################################################
280# Tests
281################################################################################
282
Jisi Liu993fb702015-10-19 17:19:49 -0700283RELATIVE_LITE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700284 # AUTOGEN(lite_test_protos)
285 "google/protobuf/map_lite_unittest.proto",
286 "google/protobuf/unittest_import_lite.proto",
287 "google/protobuf/unittest_import_public_lite.proto",
288 "google/protobuf/unittest_lite.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700289 "google/protobuf/unittest_no_arena_lite.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700290]
291
Jisi Liu993fb702015-10-19 17:19:49 -0700292LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
293
294RELATIVE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700295 # AUTOGEN(test_protos)
296 "google/protobuf/any_test.proto",
297 "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
298 "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
299 "google/protobuf/map_proto2_unittest.proto",
300 "google/protobuf/map_unittest.proto",
301 "google/protobuf/unittest.proto",
302 "google/protobuf/unittest_arena.proto",
303 "google/protobuf/unittest_custom_options.proto",
304 "google/protobuf/unittest_drop_unknown_fields.proto",
305 "google/protobuf/unittest_embed_optimize_for.proto",
306 "google/protobuf/unittest_empty.proto",
307 "google/protobuf/unittest_enormous_descriptor.proto",
308 "google/protobuf/unittest_import.proto",
309 "google/protobuf/unittest_import_public.proto",
310 "google/protobuf/unittest_lite_imports_nonlite.proto",
311 "google/protobuf/unittest_mset.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700312 "google/protobuf/unittest_mset_wire_format.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700313 "google/protobuf/unittest_no_arena.proto",
314 "google/protobuf/unittest_no_arena_import.proto",
315 "google/protobuf/unittest_no_field_presence.proto",
316 "google/protobuf/unittest_no_generic_services.proto",
317 "google/protobuf/unittest_optimize_for.proto",
318 "google/protobuf/unittest_preserve_unknown_enum.proto",
319 "google/protobuf/unittest_preserve_unknown_enum2.proto",
320 "google/protobuf/unittest_proto3_arena.proto",
321 "google/protobuf/unittest_well_known_types.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700322 "google/protobuf/util/internal/testdata/anys.proto",
323 "google/protobuf/util/internal/testdata/books.proto",
324 "google/protobuf/util/internal/testdata/default_value.proto",
325 "google/protobuf/util/internal/testdata/default_value_test.proto",
326 "google/protobuf/util/internal/testdata/field_mask.proto",
327 "google/protobuf/util/internal/testdata/maps.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700328 "google/protobuf/util/internal/testdata/oneofs.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700329 "google/protobuf/util/internal/testdata/struct.proto",
330 "google/protobuf/util/internal/testdata/timestamp_duration.proto",
331 "google/protobuf/util/json_format_proto3.proto",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800332 "google/protobuf/util/message_differencer_unittest.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700333]
334
Jisi Liu993fb702015-10-19 17:19:49 -0700335TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
336
Jisi Liu39362b32015-10-14 17:12:11 -0700337cc_proto_library(
338 name = "cc_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700339 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700340 include = "src",
Jisi Liube92ffb2015-10-27 15:11:38 -0700341 default_runtime = ":protobuf",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800342 protoc = ":protoc",
Jisi Liud8701b52015-10-16 11:44:21 -0700343 deps = [":cc_wkt_protos"],
Jisi Liud19604f2015-06-17 17:37:58 -0700344)
345
346COMMON_TEST_SRCS = [
347 # AUTOGEN(common_test_srcs)
348 "src/google/protobuf/arena_test_util.cc",
349 "src/google/protobuf/map_test_util.cc",
350 "src/google/protobuf/test_util.cc",
351 "src/google/protobuf/testing/file.cc",
352 "src/google/protobuf/testing/googletest.cc",
353]
354
Jisi Liu7a0c4312015-06-18 16:45:27 -0700355cc_binary(
356 name = "test_plugin",
357 srcs = [
358 # AUTOGEN(test_plugin_srcs)
359 "src/google/protobuf/compiler/mock_code_generator.cc",
360 "src/google/protobuf/compiler/test_plugin.cc",
361 "src/google/protobuf/testing/file.cc",
362 ],
363 deps = [
364 ":protobuf",
365 ":protoc_lib",
366 "//external:gtest",
367 ],
368)
369
370cc_test(
371 name = "protobuf_test",
Jisi Liu39362b32015-10-14 17:12:11 -0700372 srcs = COMMON_TEST_SRCS + [
Jisi Liu7a0c4312015-06-18 16:45:27 -0700373 # AUTOGEN(test_srcs)
374 "src/google/protobuf/any_test.cc",
375 "src/google/protobuf/arena_unittest.cc",
376 "src/google/protobuf/arenastring_unittest.cc",
377 "src/google/protobuf/compiler/command_line_interface_unittest.cc",
378 "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
379 "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
380 "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
381 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
382 "src/google/protobuf/compiler/importer_unittest.cc",
383 "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
384 "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
385 "src/google/protobuf/compiler/mock_code_generator.cc",
386 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
387 "src/google/protobuf/compiler/parser_unittest.cc",
388 "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
389 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
390 "src/google/protobuf/descriptor_database_unittest.cc",
391 "src/google/protobuf/descriptor_unittest.cc",
392 "src/google/protobuf/drop_unknown_fields_test.cc",
393 "src/google/protobuf/dynamic_message_unittest.cc",
394 "src/google/protobuf/extension_set_unittest.cc",
395 "src/google/protobuf/generated_message_reflection_unittest.cc",
396 "src/google/protobuf/io/coded_stream_unittest.cc",
397 "src/google/protobuf/io/printer_unittest.cc",
398 "src/google/protobuf/io/tokenizer_unittest.cc",
399 "src/google/protobuf/io/zero_copy_stream_unittest.cc",
400 "src/google/protobuf/map_field_test.cc",
401 "src/google/protobuf/map_test.cc",
402 "src/google/protobuf/message_unittest.cc",
403 "src/google/protobuf/no_field_presence_test.cc",
404 "src/google/protobuf/preserve_unknown_enum_test.cc",
405 "src/google/protobuf/proto3_arena_unittest.cc",
406 "src/google/protobuf/reflection_ops_unittest.cc",
407 "src/google/protobuf/repeated_field_reflection_unittest.cc",
408 "src/google/protobuf/repeated_field_unittest.cc",
409 "src/google/protobuf/stubs/bytestream_unittest.cc",
410 "src/google/protobuf/stubs/common_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700411 "src/google/protobuf/stubs/int128_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700412 "src/google/protobuf/stubs/once_unittest.cc",
413 "src/google/protobuf/stubs/status_test.cc",
414 "src/google/protobuf/stubs/statusor_test.cc",
415 "src/google/protobuf/stubs/stringpiece_unittest.cc",
416 "src/google/protobuf/stubs/stringprintf_unittest.cc",
417 "src/google/protobuf/stubs/structurally_valid_unittest.cc",
418 "src/google/protobuf/stubs/strutil_unittest.cc",
419 "src/google/protobuf/stubs/template_util_unittest.cc",
420 "src/google/protobuf/stubs/time_test.cc",
421 "src/google/protobuf/stubs/type_traits_unittest.cc",
422 "src/google/protobuf/text_format_unittest.cc",
423 "src/google/protobuf/unknown_field_set_unittest.cc",
424 "src/google/protobuf/util/field_comparator_test.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700425 "src/google/protobuf/util/field_mask_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700426 "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
427 "src/google/protobuf/util/internal/json_objectwriter_test.cc",
428 "src/google/protobuf/util/internal/json_stream_parser_test.cc",
429 "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
430 "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
431 "src/google/protobuf/util/internal/type_info_test_helper.cc",
432 "src/google/protobuf/util/json_util_test.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800433 "src/google/protobuf/util/message_differencer_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700434 "src/google/protobuf/util/time_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700435 "src/google/protobuf/util/type_resolver_util_test.cc",
436 "src/google/protobuf/well_known_types_unittest.cc",
437 "src/google/protobuf/wire_format_unittest.cc",
438 ],
439 copts = COPTS,
440 data = [
441 ":test_plugin",
Jisi Liu598480d2015-10-21 11:19:16 -0700442 ] + glob([
443 "src/google/protobuf/**/*",
444 ]),
Jisi Liu7a0c4312015-06-18 16:45:27 -0700445 includes = [
446 "src/",
447 ],
448 linkopts = LINK_OPTS,
449 deps = [
Jisi Liu993fb702015-10-19 17:19:49 -0700450 ":cc_test_protos",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700451 ":protobuf",
452 ":protoc_lib",
453 "//external:gtest_main",
454 ],
455)
Jisi Liu993fb702015-10-19 17:19:49 -0700456
457################################################################################
458# Java support
459################################################################################
460genrule(
Ming Zhao4fe03812016-01-21 23:03:28 -0800461 name = "gen_well_known_protos_java",
462 srcs = WELL_KNOWN_PROTOS,
463 outs = [
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800464 "wellknown.srcjar",
Ming Zhao4fe03812016-01-21 23:03:28 -0800465 ],
466 cmd = "$(location :protoc) --java_out=$(@D)/wellknown.jar" +
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800467 " -Isrc $(SRCS) " +
468 " && mv $(@D)/wellknown.jar $(@D)/wellknown.srcjar",
Jisi Liu993fb702015-10-19 17:19:49 -0700469 tools = [":protoc"],
470)
471
472java_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700473 name = "protobuf_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700474 srcs = glob([
Ming Zhao4fe03812016-01-21 23:03:28 -0800475 "java/core/src/main/java/com/google/protobuf/*.java",
Jisi Liu993fb702015-10-19 17:19:49 -0700476 ]) + [
Ming Zhao4fe03812016-01-21 23:03:28 -0800477 ":gen_well_known_protos_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700478 ],
479 visibility = ["//visibility:public"],
480)
481
482################################################################################
483# Python support
484################################################################################
485
David Z. Chen985c9682016-02-11 18:11:10 -0800486py_library(
Jisi Liu993fb702015-10-19 17:19:49 -0700487 name = "python_srcs",
488 srcs = glob(
489 [
490 "python/google/protobuf/*.py",
491 "python/google/protobuf/**/*.py",
492 ],
493 exclude = [
494 "python/google/protobuf/internal/*_test.py",
495 "python/google/protobuf/internal/test_util.py",
496 ],
497 ),
David Z. Chen985c9682016-02-11 18:11:10 -0800498 imports = ["python"],
Jisi Liu993fb702015-10-19 17:19:49 -0700499)
500
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800501cc_binary(
Manjunath Kudlurd03ef202015-12-08 10:46:17 -0800502 name = "internal/_api_implementation.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800503 srcs = ["python/google/protobuf/internal/api_implementation.cc"],
504 copts = COPTS + [
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800505 "-DPYTHON_PROTO2_CPP_IMPL_V2",
506 ],
507 linkshared = 1,
508 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800509 deps = select({
510 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800511 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800512 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800513)
514
515cc_binary(
Manjunath Kudlurd03ef202015-12-08 10:46:17 -0800516 name = "pyext/_message.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800517 srcs = glob([
518 "python/google/protobuf/pyext/*.cc",
519 "python/google/protobuf/pyext/*.h",
520 ]),
521 copts = COPTS + [
522 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800523 ] + select({
524 "//conditions:default": [],
525 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
526 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800527 includes = [
528 "python/",
529 "src/",
530 ],
531 linkshared = 1,
532 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800533 deps = [
534 ":protobuf",
535 ] + select({
536 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800537 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800538 }),
539)
540
541config_setting(
542 name = "use_fast_cpp_protos",
543 values = {
544 "define": "use_fast_cpp_protos=true",
545 },
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800546)
547
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800548config_setting(
549 name = "allow_oversize_protos",
550 values = {
551 "define": "allow_oversize_protos=true",
552 },
553)
554
Jisi Liu993fb702015-10-19 17:19:49 -0700555py_proto_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700556 name = "protobuf_python",
Jisi Liu993fb702015-10-19 17:19:49 -0700557 srcs = WELL_KNOWN_PROTOS,
558 include = "src",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800559 data = select({
560 "//conditions:default": [],
561 ":use_fast_cpp_protos": [
Manjunath Kudlurd03ef202015-12-08 10:46:17 -0800562 ":internal/_api_implementation.so",
563 ":pyext/_message.so",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800564 ],
565 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800566 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700567 protoc = ":protoc",
David Z. Chen985c9682016-02-11 18:11:10 -0800568 py_libs = [
569 ":python_srcs",
570 "//external:six"
571 ],
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800572 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700573 visibility = ["//visibility:public"],
574)
575
Jisi Liu993fb702015-10-19 17:19:49 -0700576py_proto_library(
577 name = "python_common_test_protos",
578 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
579 include = "src",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800580 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700581 protoc = ":protoc",
Jisi Liu166e9bb2015-10-21 10:56:38 -0700582 deps = [":protobuf_python"],
Jisi Liu993fb702015-10-19 17:19:49 -0700583)
584
585py_proto_library(
586 name = "python_specific_test_protos",
Jisi Liu68e13f42015-10-22 11:13:14 -0700587 srcs = glob([
588 "python/google/protobuf/internal/*.proto",
589 "python/google/protobuf/internal/import_test_package/*.proto",
590 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700591 include = "python",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800592 default_runtime = ":protobuf_python",
Jisi Liu04658a32015-10-20 15:00:13 -0700593 protoc = ":protoc",
Jisi Liu993fb702015-10-19 17:19:49 -0700594 deps = [":python_common_test_protos"],
595)
596
597py_library(
598 name = "python_tests",
David Z. Chen985c9682016-02-11 18:11:10 -0800599 srcs = glob(
600 [
601 "python/google/protobuf/internal/*_test.py",
602 "python/google/protobuf/internal/test_util.py",
603 ],
604 ),
605 imports = ["python"],
Geoffrey Irving29799232015-12-03 13:11:19 -0800606 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700607 deps = [
Jisi Liu166e9bb2015-10-21 10:56:38 -0700608 ":protobuf_python",
Jisi Liu598480d2015-10-21 11:19:16 -0700609 ":python_common_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700610 ":python_specific_test_protos",
611 ],
612)
613
614internal_protobuf_py_tests(
Jisi Liu8f540262015-10-20 16:21:41 -0700615 name = "python_tests_batch",
Jisi Liu68e13f42015-10-22 11:13:14 -0700616 data = glob([
617 "src/google/protobuf/**/*",
618 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700619 modules = [
620 "descriptor_database_test",
621 "descriptor_pool_test",
622 "descriptor_test",
623 "generator_test",
624 "json_format_test",
625 "message_factory_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700626 "message_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700627 "proto_builder_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700628 "reflection_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700629 "service_reflection_test",
630 "symbol_database_test",
631 "text_encoding_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700632 "text_format_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700633 "unknown_fields_test",
634 "wire_format_test",
635 ],
636 deps = [":python_tests"],
637)