blob: 2e084c500d67989cce5350690686a92677de67a4 [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
Andrew Harpb56b4612016-04-04 15:13:30 -040018config_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({
Andrew Harp3b4e7dc2016-04-04 16:13:31 -040027 ":android": [],
Andrew Harpb56b4612016-04-04 15:13:30 -040028 "//conditions:default": ["-lpthread"],
29})
Jisi Liud19604f2015-06-17 17:37:58 -070030
Jisi Liu04658a32015-10-20 15:00:13 -070031load(
32 "protobuf",
33 "cc_proto_library",
34 "py_proto_library",
Steven Parkesea188662016-02-25 07:53:19 -080035 "internal_gen_well_known_protos_java",
Jisi Liu04658a32015-10-20 15:00:13 -070036 "internal_protobuf_py_tests",
37)
Jisi Liu39362b32015-10-14 17:12:11 -070038
Pete Wardencb392042016-02-23 10:18:32 -080039config_setting(
Pete Wardenf0c1a862016-03-09 13:03:52 -080040 name = "ios_armv7",
Pete Wardencb392042016-02-23 10:18:32 -080041 values = {
42 "ios_cpu": "armv7",
Pete Wardenf0c1a862016-03-09 13:03:52 -080043 },
44)
45
46config_setting(
47 name = "ios_armv7s",
48 values = {
Pete Wardencb392042016-02-23 10:18:32 -080049 "ios_cpu": "armv7s",
Pete Wardenf0c1a862016-03-09 13:03:52 -080050 },
51)
52
53config_setting(
54 name = "ios_arm64",
55 values = {
Pete Wardencb392042016-02-23 10:18:32 -080056 "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
Jisi Liud19604f2015-06-17 17:37:58 -070070cc_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",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070085 "src/google/protobuf/stubs/bytestream.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070086 "src/google/protobuf/stubs/common.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -070087 "src/google/protobuf/stubs/int128.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070088 "src/google/protobuf/stubs/once.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070089 "src/google/protobuf/stubs/status.cc",
90 "src/google/protobuf/stubs/statusor.cc",
91 "src/google/protobuf/stubs/stringpiece.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070092 "src/google/protobuf/stubs/stringprintf.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -070093 "src/google/protobuf/stubs/structurally_valid.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070094 "src/google/protobuf/stubs/strutil.cc",
95 "src/google/protobuf/stubs/time.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070096 "src/google/protobuf/wire_format_lite.cc",
97 ],
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -080098 hdrs = glob(["src/google/protobuf/**/*.h"]),
Pete Wardencb392042016-02-23 10:18:32 -080099 copts = select({
Pete Wardenf0c1a862016-03-09 13:03:52 -0800100 ":ios_armv7": IOS_ARM_COPTS,
101 ":ios_armv7s": IOS_ARM_COPTS,
102 ":ios_arm64": IOS_ARM_COPTS,
Pete Wardencb392042016-02-23 10:18:32 -0800103 "//conditions:default": COPTS,
104 }),
Jisi Liud19604f2015-06-17 17:37:58 -0700105 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",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700139 "src/google/protobuf/stubs/mathlimits.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700140 "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",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700145 "src/google/protobuf/util/field_comparator.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700146 "src/google/protobuf/util/field_mask_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700147 "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",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800155 "src/google/protobuf/util/internal/proto_writer.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700156 "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",
Jisi Liub90f9f82015-08-25 17:06:33 -0700163 "src/google/protobuf/util/time_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700164 "src/google/protobuf/util/type_resolver_util.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700165 "src/google/protobuf/wire_format.cc",
166 "src/google/protobuf/wrappers.pb.cc",
167 ],
Lukacs T. Berki915d9cd2015-11-16 09:36:32 +0100168 hdrs = glob(["src/**/*.h"]),
Pete Wardencb392042016-02-23 10:18:32 -0800169 copts = select({
Pete Wardenf0c1a862016-03-09 13:03:52 -0800170 ":ios_armv7": IOS_ARM_COPTS,
171 ":ios_armv7s": IOS_ARM_COPTS,
172 ":ios_arm64": IOS_ARM_COPTS,
Pete Wardencb392042016-02-23 10:18:32 -0800173 "//conditions:default": COPTS,
174 }),
Jisi Liud19604f2015-06-17 17:37:58 -0700175 includes = ["src/"],
176 linkopts = LINK_OPTS,
177 visibility = ["//visibility:public"],
178 deps = [":protobuf_lite"],
179)
180
Jisi Liu14c8f8a2015-10-20 15:36:22 -0700181objc_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)
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700188
Jisi Liu993fb702015-10-19 17:19:49 -0700189RELATIVE_WELL_KNOWN_PROTOS = [
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700190 # 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
Jisi Liu993fb702015-10-19 17:19:49 -0700205WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
206
Steven Parkesd5a57322016-03-22 17:56:07 -0700207filegroup(
208 name = "well_known_protos",
209 srcs = WELL_KNOWN_PROTOS,
210 visibility = ["//visibility:public"],
211)
212
Jisi Liu39362b32015-10-14 17:12:11 -0700213cc_proto_library(
214 name = "cc_wkt_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700215 srcs = WELL_KNOWN_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700216 include = "src",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800217 default_runtime = ":protobuf",
Jisi Liu993fb702015-10-19 17:19:49 -0700218 internal_bootstrap_hack = 1,
Jisi Liu04658a32015-10-20 15:00:13 -0700219 protoc = ":protoc",
Jisi Liu6a40bf82015-11-17 12:36:21 -0800220 visibility = ["//visibility:public"],
Jisi Liu39362b32015-10-14 17:12:11 -0700221)
222
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700223################################################################################
224# Protocol Buffers Compiler
225################################################################################
226
Jisi Liud19604f2015-06-17 17:37:58 -0700227cc_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",
Ming Zhao5cdd9362015-10-05 14:37:21 -0700246 "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700247 "src/google/protobuf/compiler/csharp/csharp_enum.cc",
248 "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700249 "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",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100252 "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700253 "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",
Jon Skeeta6361a12015-11-19 13:05:17 +0000256 "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700257 "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",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100261 "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700262 "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",
Jisi Liub90f9f82015-08-25 17:06:33 -0700267 "src/google/protobuf/compiler/java/java_enum_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700268 "src/google/protobuf/compiler/java/java_extension.cc",
Jisi Liu1f4f3e22016-04-18 14:12:08 -0700269 "src/google/protobuf/compiler/java/java_extension_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700270 "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",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800303 "src/google/protobuf/compiler/js/js_generator.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700304 "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"],
Jisi Liud19604f2015-06-17 17:37:58 -0700333 linkopts = LINK_OPTS,
334 visibility = ["//visibility:public"],
335 deps = [":protoc_lib"],
336)
337
Jisi Liud19604f2015-06-17 17:37:58 -0700338################################################################################
339# Tests
340################################################################################
341
Jisi Liu993fb702015-10-19 17:19:49 -0700342RELATIVE_LITE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700343 # 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",
Jisi Liub90f9f82015-08-25 17:06:33 -0700348 "google/protobuf/unittest_no_arena_lite.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700349]
350
Jisi Liu993fb702015-10-19 17:19:49 -0700351LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
352
353RELATIVE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700354 # 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",
Jisi Liub90f9f82015-08-25 17:06:33 -0700371 "google/protobuf/unittest_mset_wire_format.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700372 "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_well_known_types.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700381 "google/protobuf/util/internal/testdata/anys.proto",
382 "google/protobuf/util/internal/testdata/books.proto",
383 "google/protobuf/util/internal/testdata/default_value.proto",
384 "google/protobuf/util/internal/testdata/default_value_test.proto",
385 "google/protobuf/util/internal/testdata/field_mask.proto",
386 "google/protobuf/util/internal/testdata/maps.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700387 "google/protobuf/util/internal/testdata/oneofs.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700388 "google/protobuf/util/internal/testdata/struct.proto",
389 "google/protobuf/util/internal/testdata/timestamp_duration.proto",
390 "google/protobuf/util/json_format_proto3.proto",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800391 "google/protobuf/util/message_differencer_unittest.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700392]
393
Jisi Liu993fb702015-10-19 17:19:49 -0700394TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
395
Jisi Liu39362b32015-10-14 17:12:11 -0700396cc_proto_library(
397 name = "cc_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700398 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700399 include = "src",
Jisi Liube92ffb2015-10-27 15:11:38 -0700400 default_runtime = ":protobuf",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800401 protoc = ":protoc",
Jisi Liud8701b52015-10-16 11:44:21 -0700402 deps = [":cc_wkt_protos"],
Jisi Liud19604f2015-06-17 17:37:58 -0700403)
404
405COMMON_TEST_SRCS = [
406 # AUTOGEN(common_test_srcs)
407 "src/google/protobuf/arena_test_util.cc",
408 "src/google/protobuf/map_test_util.cc",
409 "src/google/protobuf/test_util.cc",
410 "src/google/protobuf/testing/file.cc",
411 "src/google/protobuf/testing/googletest.cc",
412]
413
Jisi Liu7a0c4312015-06-18 16:45:27 -0700414cc_binary(
415 name = "test_plugin",
416 srcs = [
417 # AUTOGEN(test_plugin_srcs)
418 "src/google/protobuf/compiler/mock_code_generator.cc",
419 "src/google/protobuf/compiler/test_plugin.cc",
420 "src/google/protobuf/testing/file.cc",
421 ],
422 deps = [
423 ":protobuf",
424 ":protoc_lib",
425 "//external:gtest",
426 ],
427)
428
429cc_test(
430 name = "protobuf_test",
Jisi Liu39362b32015-10-14 17:12:11 -0700431 srcs = COMMON_TEST_SRCS + [
Jisi Liu7a0c4312015-06-18 16:45:27 -0700432 # AUTOGEN(test_srcs)
433 "src/google/protobuf/any_test.cc",
434 "src/google/protobuf/arena_unittest.cc",
435 "src/google/protobuf/arenastring_unittest.cc",
436 "src/google/protobuf/compiler/command_line_interface_unittest.cc",
437 "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
438 "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
439 "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
Jisi Liu1f4f3e22016-04-18 14:12:08 -0700440 "src/google/protobuf/compiler/cpp/metadata_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700441 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
442 "src/google/protobuf/compiler/importer_unittest.cc",
443 "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
444 "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
445 "src/google/protobuf/compiler/mock_code_generator.cc",
446 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
447 "src/google/protobuf/compiler/parser_unittest.cc",
448 "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
449 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
450 "src/google/protobuf/descriptor_database_unittest.cc",
451 "src/google/protobuf/descriptor_unittest.cc",
452 "src/google/protobuf/drop_unknown_fields_test.cc",
453 "src/google/protobuf/dynamic_message_unittest.cc",
454 "src/google/protobuf/extension_set_unittest.cc",
455 "src/google/protobuf/generated_message_reflection_unittest.cc",
456 "src/google/protobuf/io/coded_stream_unittest.cc",
457 "src/google/protobuf/io/printer_unittest.cc",
458 "src/google/protobuf/io/tokenizer_unittest.cc",
459 "src/google/protobuf/io/zero_copy_stream_unittest.cc",
460 "src/google/protobuf/map_field_test.cc",
461 "src/google/protobuf/map_test.cc",
462 "src/google/protobuf/message_unittest.cc",
463 "src/google/protobuf/no_field_presence_test.cc",
464 "src/google/protobuf/preserve_unknown_enum_test.cc",
465 "src/google/protobuf/proto3_arena_unittest.cc",
466 "src/google/protobuf/reflection_ops_unittest.cc",
467 "src/google/protobuf/repeated_field_reflection_unittest.cc",
468 "src/google/protobuf/repeated_field_unittest.cc",
469 "src/google/protobuf/stubs/bytestream_unittest.cc",
470 "src/google/protobuf/stubs/common_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700471 "src/google/protobuf/stubs/int128_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700472 "src/google/protobuf/stubs/once_unittest.cc",
473 "src/google/protobuf/stubs/status_test.cc",
474 "src/google/protobuf/stubs/statusor_test.cc",
475 "src/google/protobuf/stubs/stringpiece_unittest.cc",
476 "src/google/protobuf/stubs/stringprintf_unittest.cc",
477 "src/google/protobuf/stubs/structurally_valid_unittest.cc",
478 "src/google/protobuf/stubs/strutil_unittest.cc",
479 "src/google/protobuf/stubs/template_util_unittest.cc",
480 "src/google/protobuf/stubs/time_test.cc",
481 "src/google/protobuf/stubs/type_traits_unittest.cc",
482 "src/google/protobuf/text_format_unittest.cc",
483 "src/google/protobuf/unknown_field_set_unittest.cc",
484 "src/google/protobuf/util/field_comparator_test.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700485 "src/google/protobuf/util/field_mask_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700486 "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
487 "src/google/protobuf/util/internal/json_objectwriter_test.cc",
488 "src/google/protobuf/util/internal/json_stream_parser_test.cc",
489 "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
490 "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
491 "src/google/protobuf/util/internal/type_info_test_helper.cc",
492 "src/google/protobuf/util/json_util_test.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800493 "src/google/protobuf/util/message_differencer_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700494 "src/google/protobuf/util/time_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700495 "src/google/protobuf/util/type_resolver_util_test.cc",
496 "src/google/protobuf/well_known_types_unittest.cc",
497 "src/google/protobuf/wire_format_unittest.cc",
498 ],
499 copts = COPTS,
500 data = [
501 ":test_plugin",
Jisi Liu598480d2015-10-21 11:19:16 -0700502 ] + glob([
503 "src/google/protobuf/**/*",
504 ]),
Jisi Liu7a0c4312015-06-18 16:45:27 -0700505 includes = [
506 "src/",
507 ],
508 linkopts = LINK_OPTS,
509 deps = [
Jisi Liu993fb702015-10-19 17:19:49 -0700510 ":cc_test_protos",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700511 ":protobuf",
512 ":protoc_lib",
513 "//external:gtest_main",
514 ],
515)
Jisi Liu993fb702015-10-19 17:19:49 -0700516
517################################################################################
518# Java support
519################################################################################
Steven Parkesea188662016-02-25 07:53:19 -0800520internal_gen_well_known_protos_java(
Ming Zhao4fe03812016-01-21 23:03:28 -0800521 srcs = WELL_KNOWN_PROTOS,
Jisi Liu993fb702015-10-19 17:19:49 -0700522)
523
524java_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700525 name = "protobuf_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700526 srcs = glob([
Ming Zhao4fe03812016-01-21 23:03:28 -0800527 "java/core/src/main/java/com/google/protobuf/*.java",
Jisi Liu993fb702015-10-19 17:19:49 -0700528 ]) + [
Ming Zhao4fe03812016-01-21 23:03:28 -0800529 ":gen_well_known_protos_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700530 ],
531 visibility = ["//visibility:public"],
532)
533
Steven Parkesa9244ca2016-03-10 17:50:25 -0800534java_library(
535 name = "protobuf_java_util",
536 srcs = glob([
537 "java/util/src/main/java/com/google/protobuf/util/*.java",
538 ]),
539 deps = [
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700540 "protobuf_java",
541 "//external:gson",
542 "//external:guava",
Steven Parkesa9244ca2016-03-10 17:50:25 -0800543 ],
544 visibility = ["//visibility:public"],
545)
546
Jisi Liu993fb702015-10-19 17:19:49 -0700547################################################################################
548# Python support
549################################################################################
550
David Z. Chen985c9682016-02-11 18:11:10 -0800551py_library(
Jisi Liu993fb702015-10-19 17:19:49 -0700552 name = "python_srcs",
553 srcs = glob(
554 [
555 "python/google/protobuf/*.py",
556 "python/google/protobuf/**/*.py",
557 ],
558 exclude = [
559 "python/google/protobuf/internal/*_test.py",
560 "python/google/protobuf/internal/test_util.py",
561 ],
562 ),
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700563 srcs_version = "PY2AND3",
David Z. Chen985c9682016-02-11 18:11:10 -0800564 imports = ["python"],
Jisi Liu993fb702015-10-19 17:19:49 -0700565)
566
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800567cc_binary(
Manjunath Kudlurd03ef202015-12-08 10:46:17 -0800568 name = "internal/_api_implementation.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800569 srcs = ["python/google/protobuf/internal/api_implementation.cc"],
570 copts = COPTS + [
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800571 "-DPYTHON_PROTO2_CPP_IMPL_V2",
572 ],
573 linkshared = 1,
574 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800575 deps = select({
576 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800577 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800578 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800579)
580
581cc_binary(
Manjunath Kudlurd03ef202015-12-08 10:46:17 -0800582 name = "pyext/_message.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800583 srcs = glob([
584 "python/google/protobuf/pyext/*.cc",
585 "python/google/protobuf/pyext/*.h",
586 ]),
587 copts = COPTS + [
588 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800589 ] + select({
590 "//conditions:default": [],
591 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
592 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800593 includes = [
594 "python/",
595 "src/",
596 ],
597 linkshared = 1,
598 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800599 deps = [
600 ":protobuf",
601 ] + select({
602 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800603 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800604 }),
605)
606
607config_setting(
608 name = "use_fast_cpp_protos",
609 values = {
610 "define": "use_fast_cpp_protos=true",
611 },
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800612)
613
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800614config_setting(
615 name = "allow_oversize_protos",
616 values = {
617 "define": "allow_oversize_protos=true",
618 },
619)
620
Jisi Liu993fb702015-10-19 17:19:49 -0700621py_proto_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700622 name = "protobuf_python",
Jisi Liu993fb702015-10-19 17:19:49 -0700623 srcs = WELL_KNOWN_PROTOS,
624 include = "src",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800625 data = select({
626 "//conditions:default": [],
627 ":use_fast_cpp_protos": [
Manjunath Kudlurd03ef202015-12-08 10:46:17 -0800628 ":internal/_api_implementation.so",
629 ":pyext/_message.so",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800630 ],
631 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800632 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700633 protoc = ":protoc",
David Z. Chen985c9682016-02-11 18:11:10 -0800634 py_libs = [
635 ":python_srcs",
636 "//external:six"
637 ],
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800638 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700639 visibility = ["//visibility:public"],
640)
641
Jisi Liu993fb702015-10-19 17:19:49 -0700642py_proto_library(
643 name = "python_common_test_protos",
644 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
645 include = "src",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800646 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700647 protoc = ":protoc",
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700648 srcs_version = "PY2AND3",
Jisi Liu166e9bb2015-10-21 10:56:38 -0700649 deps = [":protobuf_python"],
Jisi Liu993fb702015-10-19 17:19:49 -0700650)
651
652py_proto_library(
653 name = "python_specific_test_protos",
Jisi Liu68e13f42015-10-22 11:13:14 -0700654 srcs = glob([
655 "python/google/protobuf/internal/*.proto",
656 "python/google/protobuf/internal/import_test_package/*.proto",
657 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700658 include = "python",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800659 default_runtime = ":protobuf_python",
Jisi Liu04658a32015-10-20 15:00:13 -0700660 protoc = ":protoc",
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700661 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700662 deps = [":python_common_test_protos"],
663)
664
665py_library(
666 name = "python_tests",
David Z. Chen985c9682016-02-11 18:11:10 -0800667 srcs = glob(
668 [
669 "python/google/protobuf/internal/*_test.py",
670 "python/google/protobuf/internal/test_util.py",
671 ],
672 ),
673 imports = ["python"],
Geoffrey Irving29799232015-12-03 13:11:19 -0800674 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700675 deps = [
Jisi Liu166e9bb2015-10-21 10:56:38 -0700676 ":protobuf_python",
Jisi Liu598480d2015-10-21 11:19:16 -0700677 ":python_common_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700678 ":python_specific_test_protos",
679 ],
680)
681
682internal_protobuf_py_tests(
Jisi Liu8f540262015-10-20 16:21:41 -0700683 name = "python_tests_batch",
Jisi Liu68e13f42015-10-22 11:13:14 -0700684 data = glob([
685 "src/google/protobuf/**/*",
686 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700687 modules = [
688 "descriptor_database_test",
689 "descriptor_pool_test",
690 "descriptor_test",
691 "generator_test",
692 "json_format_test",
693 "message_factory_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700694 "message_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700695 "proto_builder_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700696 "reflection_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700697 "service_reflection_test",
698 "symbol_database_test",
699 "text_encoding_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700700 "text_format_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700701 "unknown_fields_test",
702 "wire_format_test",
703 ],
704 deps = [":python_tests"],
705)