blob: ee81c7595a6e6c84b78caa94deb87bf74551d06e [file] [log] [blame]
Jisi Liud19604f2015-06-17 17:37:58 -07001# Bazel (http://bazel.io/) BUILD file for Protobuf.
2
3licenses(["notice"])
4
Piotr Sikorafaea19c2016-08-04 15:32:14 -07005exports_files(["LICENSE"])
6
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -07007################################################################################
David Ostrovsky85b488f2018-01-31 09:01:27 +01008# Java 9 configuration
9################################################################################
10
11config_setting(
12 name = "jdk9",
13 values = {
14 "java_toolchain": "@bazel_tools//tools/jdk:toolchain_jdk9",
15 },
16)
17
18################################################################################
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -070019# Protobuf Runtime Library
20################################################################################
21
Yun Peng0b059a32017-05-31 14:01:23 +020022WIN_COPTS = [
23 "/DHAVE_PTHREAD",
24 "/wd4018", # -Wno-sign-compare
25 "/wd4514", # -Wno-unused-function
Jisi Liud19604f2015-06-17 17:37:58 -070026]
27
Yun Peng0b059a32017-05-31 14:01:23 +020028COPTS = select({
29 ":windows" : WIN_COPTS,
30 ":windows_msvc" : WIN_COPTS,
31 "//conditions:default": [
32 "-DHAVE_PTHREAD",
33 "-Wall",
34 "-Wwrite-strings",
35 "-Woverloaded-virtual",
36 "-Wno-sign-compare",
37 "-Wno-unused-function",
Justine Tunneyac5371d2017-11-17 18:27:39 -080038 # Prevents ISO C++ const string assignment warnings for pyext sources.
39 "-Wno-writable-strings",
Yun Peng0b059a32017-05-31 14:01:23 +020040 ],
41})
42
43config_setting(
44 name = "windows",
45 values = { "cpu": "x64_windows" },
46)
47
48config_setting(
49 name = "windows_msvc",
50 values = { "cpu": "x64_windows_msvc" },
51)
52
Andrew Harpb56b4612016-04-04 15:13:30 -040053config_setting(
54 name = "android",
55 values = {
56 "crosstool_top": "//external:android/crosstool",
57 },
58)
59
Seth Greenstein68ee9162017-10-10 11:08:27 -070060# Android and Windows builds do not need to link in a separate pthread library.
Andrew Harpb56b4612016-04-04 15:13:30 -040061LINK_OPTS = select({
Andrew Harp3b4e7dc2016-04-04 16:13:31 -040062 ":android": [],
Seth Greenstein68ee9162017-10-10 11:08:27 -070063 ":windows": [],
64 ":windows_msvc": [],
Daniel Ylitalo32fa55e2017-01-25 22:04:11 +010065 "//conditions:default": ["-lpthread", "-lm"],
Andrew Harpb56b4612016-04-04 15:13:30 -040066})
Jisi Liud19604f2015-06-17 17:37:58 -070067
Jisi Liu04658a32015-10-20 15:00:13 -070068load(
cgrushko65a4d202017-02-08 15:23:57 -050069 ":protobuf.bzl",
Jisi Liu04658a32015-10-20 15:00:13 -070070 "cc_proto_library",
71 "py_proto_library",
David Z. Chen02cd45c2016-05-20 16:49:04 -070072 "internal_copied_filegroup",
Steven Parkesea188662016-02-25 07:53:19 -080073 "internal_gen_well_known_protos_java",
Jisi Liu04658a32015-10-20 15:00:13 -070074 "internal_protobuf_py_tests",
75)
Jisi Liu39362b32015-10-14 17:12:11 -070076
Jisi Liud19604f2015-06-17 17:37:58 -070077cc_library(
78 name = "protobuf_lite",
79 srcs = [
80 # AUTOGEN(protobuf_lite_srcs)
81 "src/google/protobuf/arena.cc",
82 "src/google/protobuf/arenastring.cc",
83 "src/google/protobuf/extension_set.cc",
Jisi Liu12c186f2017-07-25 14:38:00 -070084 "src/google/protobuf/generated_message_table_driven_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070085 "src/google/protobuf/generated_message_util.cc",
Adam Cozzette609d7522017-12-07 14:16:50 -080086 "src/google/protobuf/implicit_weak_message.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070087 "src/google/protobuf/io/coded_stream.cc",
88 "src/google/protobuf/io/zero_copy_stream.cc",
89 "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
90 "src/google/protobuf/message_lite.cc",
91 "src/google/protobuf/repeated_field.cc",
92 "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
93 "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070094 "src/google/protobuf/stubs/bytestream.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070095 "src/google/protobuf/stubs/common.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -070096 "src/google/protobuf/stubs/int128.cc",
Jisi Liu759245a2017-07-25 11:52:33 -070097 "src/google/protobuf/stubs/io_win32.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070098 "src/google/protobuf/stubs/once.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070099 "src/google/protobuf/stubs/status.cc",
100 "src/google/protobuf/stubs/statusor.cc",
101 "src/google/protobuf/stubs/stringpiece.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700102 "src/google/protobuf/stubs/stringprintf.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700103 "src/google/protobuf/stubs/structurally_valid.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700104 "src/google/protobuf/stubs/strutil.cc",
105 "src/google/protobuf/stubs/time.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700106 "src/google/protobuf/wire_format_lite.cc",
107 ],
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800108 hdrs = glob(["src/google/protobuf/**/*.h"]),
Param Reddy16792c62017-10-15 13:06:58 -0700109 copts = COPTS,
Jisi Liud19604f2015-06-17 17:37:58 -0700110 includes = ["src/"],
111 linkopts = LINK_OPTS,
112 visibility = ["//visibility:public"],
113)
114
115cc_library(
116 name = "protobuf",
117 srcs = [
118 # AUTOGEN(protobuf_srcs)
119 "src/google/protobuf/any.cc",
120 "src/google/protobuf/any.pb.cc",
121 "src/google/protobuf/api.pb.cc",
122 "src/google/protobuf/compiler/importer.cc",
123 "src/google/protobuf/compiler/parser.cc",
John Millikin724f0be2018-02-24 11:34:40 -0800124 "src/google/protobuf/compiler/plugin.pb.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700125 "src/google/protobuf/descriptor.cc",
126 "src/google/protobuf/descriptor.pb.cc",
127 "src/google/protobuf/descriptor_database.cc",
128 "src/google/protobuf/duration.pb.cc",
129 "src/google/protobuf/dynamic_message.cc",
130 "src/google/protobuf/empty.pb.cc",
131 "src/google/protobuf/extension_set_heavy.cc",
132 "src/google/protobuf/field_mask.pb.cc",
133 "src/google/protobuf/generated_message_reflection.cc",
Jisi Liu759245a2017-07-25 11:52:33 -0700134 "src/google/protobuf/generated_message_table_driven.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700135 "src/google/protobuf/io/gzip_stream.cc",
136 "src/google/protobuf/io/printer.cc",
137 "src/google/protobuf/io/strtod.cc",
138 "src/google/protobuf/io/tokenizer.cc",
139 "src/google/protobuf/io/zero_copy_stream_impl.cc",
140 "src/google/protobuf/map_field.cc",
141 "src/google/protobuf/message.cc",
142 "src/google/protobuf/reflection_ops.cc",
143 "src/google/protobuf/service.cc",
144 "src/google/protobuf/source_context.pb.cc",
145 "src/google/protobuf/struct.pb.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700146 "src/google/protobuf/stubs/mathlimits.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700147 "src/google/protobuf/stubs/substitute.cc",
148 "src/google/protobuf/text_format.cc",
149 "src/google/protobuf/timestamp.pb.cc",
150 "src/google/protobuf/type.pb.cc",
151 "src/google/protobuf/unknown_field_set.cc",
Bairen Yi312e2db2017-03-21 03:52:37 +0800152 "src/google/protobuf/util/delimited_message_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700153 "src/google/protobuf/util/field_comparator.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700154 "src/google/protobuf/util/field_mask_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700155 "src/google/protobuf/util/internal/datapiece.cc",
156 "src/google/protobuf/util/internal/default_value_objectwriter.cc",
157 "src/google/protobuf/util/internal/error_listener.cc",
158 "src/google/protobuf/util/internal/field_mask_utility.cc",
159 "src/google/protobuf/util/internal/json_escaping.cc",
160 "src/google/protobuf/util/internal/json_objectwriter.cc",
161 "src/google/protobuf/util/internal/json_stream_parser.cc",
162 "src/google/protobuf/util/internal/object_writer.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800163 "src/google/protobuf/util/internal/proto_writer.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700164 "src/google/protobuf/util/internal/protostream_objectsource.cc",
165 "src/google/protobuf/util/internal/protostream_objectwriter.cc",
166 "src/google/protobuf/util/internal/type_info.cc",
167 "src/google/protobuf/util/internal/type_info_test_helper.cc",
168 "src/google/protobuf/util/internal/utility.cc",
169 "src/google/protobuf/util/json_util.cc",
170 "src/google/protobuf/util/message_differencer.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700171 "src/google/protobuf/util/time_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700172 "src/google/protobuf/util/type_resolver_util.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700173 "src/google/protobuf/wire_format.cc",
174 "src/google/protobuf/wrappers.pb.cc",
175 ],
Lukacs T. Berki915d9cd2015-11-16 09:36:32 +0100176 hdrs = glob(["src/**/*.h"]),
Param Reddy16792c62017-10-15 13:06:58 -0700177 copts = COPTS,
Jisi Liud19604f2015-06-17 17:37:58 -0700178 includes = ["src/"],
179 linkopts = LINK_OPTS,
180 visibility = ["//visibility:public"],
181 deps = [":protobuf_lite"],
182)
183
Manjunath Kudlur6837b2d2017-03-02 18:02:05 -0800184# This provides just the header files for use in projects that need to build
185# shared libraries for dynamic loading. This target is available until Bazel
186# adds native support for such use cases.
187# TODO(keveman): Remove this target once the support gets added to Bazel.
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800188cc_library(
189 name = "protobuf_headers",
190 hdrs = glob(["src/**/*.h"]),
191 includes = ["src/"],
192 visibility = ["//visibility:public"],
193)
194
Jisi Liu14c8f8a2015-10-20 15:36:22 -0700195objc_library(
196 name = "protobuf_objc",
197 hdrs = ["objectivec/GPBProtocolBuffers.h"],
198 includes = ["objectivec"],
199 non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
200 visibility = ["//visibility:public"],
201)
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700202
Jakob Buchgraber699c0eb2017-09-05 17:15:10 +0200203# Map of all well known protos.
204# name => (include path, imports)
205WELL_KNOWN_PROTO_MAP = {
206 "any" : ("google/protobuf/any.proto", []),
207 "api" : ("google/protobuf/api.proto", ["source_context", "type"]),
208 "compiler_plugin" : ("google/protobuf/compiler/plugin.proto", ["descriptor"]),
209 "descriptor" : ("google/protobuf/descriptor.proto", []),
210 "duration" : ("google/protobuf/duration.proto", []),
211 "empty" : ("google/protobuf/empty.proto", []),
212 "field_mask" : ("google/protobuf/field_mask.proto", []),
213 "source_context" : ("google/protobuf/source_context.proto", []),
214 "struct" : ("google/protobuf/struct.proto", []),
215 "timestamp" : ("google/protobuf/timestamp.proto", []),
216 "type" : ("google/protobuf/type.proto", ["any", "source_context"]),
217 "wrappers" : ("google/protobuf/wrappers.proto", []),
218}
219
220RELATIVE_WELL_KNOWN_PROTOS = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()]
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700221
Jisi Liu993fb702015-10-19 17:19:49 -0700222WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
223
Steven Parkesd5a57322016-03-22 17:56:07 -0700224filegroup(
225 name = "well_known_protos",
226 srcs = WELL_KNOWN_PROTOS,
227 visibility = ["//visibility:public"],
228)
229
Jisi Liu39362b32015-10-14 17:12:11 -0700230cc_proto_library(
231 name = "cc_wkt_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700232 srcs = WELL_KNOWN_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700233 include = "src",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800234 default_runtime = ":protobuf",
Jisi Liu993fb702015-10-19 17:19:49 -0700235 internal_bootstrap_hack = 1,
Jisi Liu04658a32015-10-20 15:00:13 -0700236 protoc = ":protoc",
Jisi Liu6a40bf82015-11-17 12:36:21 -0800237 visibility = ["//visibility:public"],
Jisi Liu39362b32015-10-14 17:12:11 -0700238)
239
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700240################################################################################
Jakob Buchgraber699c0eb2017-09-05 17:15:10 +0200241# Well Known Types Proto Library Rules
242#
243# These proto_library rules can be used with one of the language specific proto
244# library rules i.e. java_proto_library:
245#
246# java_proto_library(
247# name = "any_java_proto",
248# deps = ["@com_google_protobuf//:any_proto],
249# )
250################################################################################
251
252internal_copied_filegroup(
253 name = "_internal_wkt_protos",
254 srcs = WELL_KNOWN_PROTOS,
255 dest = "",
256 strip_prefix = "src",
257 visibility = ["//visibility:hidden"],
258)
259
260[proto_library(
261 name = proto[0] + "_proto",
262 srcs = [proto[1][0]],
263 deps = [dep + "_proto" for dep in proto[1][1]],
264 visibility = ["//visibility:public"],
265 ) for proto in WELL_KNOWN_PROTO_MAP.items()]
266
267################################################################################
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700268# Protocol Buffers Compiler
269################################################################################
270
Adam Cozzetted1e7bd92016-12-20 09:08:19 -0800271cc_binary(
272 name = "js_embed",
273 srcs = ["src/google/protobuf/compiler/js/embed.cc"],
274 visibility = ["//visibility:public"],
275)
276
277genrule(
278 name = "generate_js_well_known_types_embed",
279 srcs = [
280 "src/google/protobuf/compiler/js/well_known_types/any.js",
281 "src/google/protobuf/compiler/js/well_known_types/struct.js",
282 "src/google/protobuf/compiler/js/well_known_types/timestamp.js",
283 ],
284 outs = ["src/google/protobuf/compiler/js/well_known_types_embed.cc"],
285 cmd = "$(location :js_embed) $(SRCS) > $@",
286 tools = [":js_embed"],
287)
288
Jisi Liud19604f2015-06-17 17:37:58 -0700289cc_library(
290 name = "protoc_lib",
291 srcs = [
292 # AUTOGEN(protoc_lib_srcs)
293 "src/google/protobuf/compiler/code_generator.cc",
294 "src/google/protobuf/compiler/command_line_interface.cc",
295 "src/google/protobuf/compiler/cpp/cpp_enum.cc",
296 "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
297 "src/google/protobuf/compiler/cpp/cpp_extension.cc",
298 "src/google/protobuf/compiler/cpp/cpp_field.cc",
299 "src/google/protobuf/compiler/cpp/cpp_file.cc",
300 "src/google/protobuf/compiler/cpp/cpp_generator.cc",
301 "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
302 "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
303 "src/google/protobuf/compiler/cpp/cpp_message.cc",
304 "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
Adam Cozzette13fd0452017-09-12 10:32:01 -0700305 "src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700306 "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
307 "src/google/protobuf/compiler/cpp/cpp_service.cc",
308 "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
Ming Zhao5cdd9362015-10-05 14:37:21 -0700309 "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700310 "src/google/protobuf/compiler/csharp/csharp_enum.cc",
311 "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700312 "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
313 "src/google/protobuf/compiler/csharp/csharp_generator.cc",
314 "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100315 "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700316 "src/google/protobuf/compiler/csharp/csharp_message.cc",
317 "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
318 "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
Jon Skeeta6361a12015-11-19 13:05:17 +0000319 "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700320 "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
321 "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
322 "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
323 "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100324 "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700325 "src/google/protobuf/compiler/java/java_context.cc",
326 "src/google/protobuf/compiler/java/java_doc_comment.cc",
327 "src/google/protobuf/compiler/java/java_enum.cc",
328 "src/google/protobuf/compiler/java/java_enum_field.cc",
329 "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700330 "src/google/protobuf/compiler/java/java_enum_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700331 "src/google/protobuf/compiler/java/java_extension.cc",
Jisi Liu1f4f3e22016-04-18 14:12:08 -0700332 "src/google/protobuf/compiler/java/java_extension_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700333 "src/google/protobuf/compiler/java/java_field.cc",
334 "src/google/protobuf/compiler/java/java_file.cc",
335 "src/google/protobuf/compiler/java/java_generator.cc",
336 "src/google/protobuf/compiler/java/java_generator_factory.cc",
337 "src/google/protobuf/compiler/java/java_helpers.cc",
338 "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
339 "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
340 "src/google/protobuf/compiler/java/java_map_field.cc",
341 "src/google/protobuf/compiler/java/java_map_field_lite.cc",
342 "src/google/protobuf/compiler/java/java_message.cc",
343 "src/google/protobuf/compiler/java/java_message_builder.cc",
344 "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
345 "src/google/protobuf/compiler/java/java_message_field.cc",
346 "src/google/protobuf/compiler/java/java_message_field_lite.cc",
347 "src/google/protobuf/compiler/java/java_message_lite.cc",
348 "src/google/protobuf/compiler/java/java_name_resolver.cc",
349 "src/google/protobuf/compiler/java/java_primitive_field.cc",
350 "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
351 "src/google/protobuf/compiler/java/java_service.cc",
352 "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
353 "src/google/protobuf/compiler/java/java_string_field.cc",
354 "src/google/protobuf/compiler/java/java_string_field_lite.cc",
355 "src/google/protobuf/compiler/javanano/javanano_enum.cc",
356 "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
357 "src/google/protobuf/compiler/javanano/javanano_extension.cc",
358 "src/google/protobuf/compiler/javanano/javanano_field.cc",
359 "src/google/protobuf/compiler/javanano/javanano_file.cc",
360 "src/google/protobuf/compiler/javanano/javanano_generator.cc",
361 "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
362 "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
363 "src/google/protobuf/compiler/javanano/javanano_message.cc",
364 "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
365 "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800366 "src/google/protobuf/compiler/js/js_generator.cc",
Jisi Liuf92b4552016-12-05 10:16:47 -0800367 "src/google/protobuf/compiler/js/well_known_types_embed.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700368 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
369 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
370 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
371 "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
372 "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
373 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
374 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
375 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
376 "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
377 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
378 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
379 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
Jisi Liud9473082016-09-22 15:14:58 -0700380 "src/google/protobuf/compiler/php/php_generator.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700381 "src/google/protobuf/compiler/plugin.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700382 "src/google/protobuf/compiler/python/python_generator.cc",
383 "src/google/protobuf/compiler/ruby/ruby_generator.cc",
384 "src/google/protobuf/compiler/subprocess.cc",
385 "src/google/protobuf/compiler/zip_writer.cc",
386 ],
387 copts = COPTS,
388 includes = ["src/"],
389 linkopts = LINK_OPTS,
390 visibility = ["//visibility:public"],
391 deps = [":protobuf"],
392)
393
394cc_binary(
395 name = "protoc",
396 srcs = ["src/google/protobuf/compiler/main.cc"],
Jisi Liud19604f2015-06-17 17:37:58 -0700397 linkopts = LINK_OPTS,
398 visibility = ["//visibility:public"],
399 deps = [":protoc_lib"],
400)
401
Jisi Liud19604f2015-06-17 17:37:58 -0700402################################################################################
403# Tests
404################################################################################
405
Jisi Liu993fb702015-10-19 17:19:49 -0700406RELATIVE_LITE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700407 # AUTOGEN(lite_test_protos)
408 "google/protobuf/map_lite_unittest.proto",
409 "google/protobuf/unittest_import_lite.proto",
410 "google/protobuf/unittest_import_public_lite.proto",
411 "google/protobuf/unittest_lite.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700412 "google/protobuf/unittest_no_arena_lite.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700413]
414
Jisi Liu993fb702015-10-19 17:19:49 -0700415LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
416
417RELATIVE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700418 # AUTOGEN(test_protos)
419 "google/protobuf/any_test.proto",
420 "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
421 "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
422 "google/protobuf/map_proto2_unittest.proto",
423 "google/protobuf/map_unittest.proto",
424 "google/protobuf/unittest.proto",
425 "google/protobuf/unittest_arena.proto",
426 "google/protobuf/unittest_custom_options.proto",
427 "google/protobuf/unittest_drop_unknown_fields.proto",
428 "google/protobuf/unittest_embed_optimize_for.proto",
429 "google/protobuf/unittest_empty.proto",
430 "google/protobuf/unittest_enormous_descriptor.proto",
431 "google/protobuf/unittest_import.proto",
432 "google/protobuf/unittest_import_public.proto",
Feng Xiao32d78302017-03-29 14:01:40 -0700433 "google/protobuf/unittest_lazy_dependencies.proto",
434 "google/protobuf/unittest_lazy_dependencies_custom_option.proto",
435 "google/protobuf/unittest_lazy_dependencies_enum.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700436 "google/protobuf/unittest_lite_imports_nonlite.proto",
437 "google/protobuf/unittest_mset.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700438 "google/protobuf/unittest_mset_wire_format.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700439 "google/protobuf/unittest_no_arena.proto",
440 "google/protobuf/unittest_no_arena_import.proto",
441 "google/protobuf/unittest_no_field_presence.proto",
442 "google/protobuf/unittest_no_generic_services.proto",
443 "google/protobuf/unittest_optimize_for.proto",
444 "google/protobuf/unittest_preserve_unknown_enum.proto",
445 "google/protobuf/unittest_preserve_unknown_enum2.proto",
446 "google/protobuf/unittest_proto3_arena.proto",
Chad Whipkeybaf52bd2016-04-15 09:23:50 -0700447 "google/protobuf/unittest_proto3_arena_lite.proto",
448 "google/protobuf/unittest_proto3_lite.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700449 "google/protobuf/unittest_well_known_types.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700450 "google/protobuf/util/internal/testdata/anys.proto",
451 "google/protobuf/util/internal/testdata/books.proto",
452 "google/protobuf/util/internal/testdata/default_value.proto",
453 "google/protobuf/util/internal/testdata/default_value_test.proto",
454 "google/protobuf/util/internal/testdata/field_mask.proto",
455 "google/protobuf/util/internal/testdata/maps.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700456 "google/protobuf/util/internal/testdata/oneofs.proto",
Jisi Liu9d4657a2016-09-22 15:11:17 -0700457 "google/protobuf/util/internal/testdata/proto3.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700458 "google/protobuf/util/internal/testdata/struct.proto",
459 "google/protobuf/util/internal/testdata/timestamp_duration.proto",
Jisi Liu9d4657a2016-09-22 15:11:17 -0700460 "google/protobuf/util/internal/testdata/wrappers.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700461 "google/protobuf/util/json_format_proto3.proto",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800462 "google/protobuf/util/message_differencer_unittest.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700463]
464
Jisi Liu993fb702015-10-19 17:19:49 -0700465TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
466
Jisi Liu39362b32015-10-14 17:12:11 -0700467cc_proto_library(
468 name = "cc_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700469 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700470 include = "src",
Jisi Liube92ffb2015-10-27 15:11:38 -0700471 default_runtime = ":protobuf",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800472 protoc = ":protoc",
Jisi Liud8701b52015-10-16 11:44:21 -0700473 deps = [":cc_wkt_protos"],
Jisi Liud19604f2015-06-17 17:37:58 -0700474)
475
476COMMON_TEST_SRCS = [
477 # AUTOGEN(common_test_srcs)
478 "src/google/protobuf/arena_test_util.cc",
479 "src/google/protobuf/map_test_util.cc",
480 "src/google/protobuf/test_util.cc",
481 "src/google/protobuf/testing/file.cc",
482 "src/google/protobuf/testing/googletest.cc",
483]
484
Jisi Liu7a0c4312015-06-18 16:45:27 -0700485cc_binary(
486 name = "test_plugin",
487 srcs = [
488 # AUTOGEN(test_plugin_srcs)
489 "src/google/protobuf/compiler/mock_code_generator.cc",
490 "src/google/protobuf/compiler/test_plugin.cc",
491 "src/google/protobuf/testing/file.cc",
492 ],
493 deps = [
494 ":protobuf",
495 ":protoc_lib",
496 "//external:gtest",
497 ],
498)
499
500cc_test(
Jisi Liu759245a2017-07-25 11:52:33 -0700501 name = "win32_test",
502 srcs = ["src/google/protobuf/stubs/io_win32_unittest.cc"],
503 deps = [
504 ":protobuf_lite",
505 "//external:gtest_main",
506 ],
507 tags = ["manual", "windows"],
508)
509
510cc_test(
Jisi Liu7a0c4312015-06-18 16:45:27 -0700511 name = "protobuf_test",
Jisi Liu39362b32015-10-14 17:12:11 -0700512 srcs = COMMON_TEST_SRCS + [
Jisi Liu7a0c4312015-06-18 16:45:27 -0700513 # AUTOGEN(test_srcs)
514 "src/google/protobuf/any_test.cc",
515 "src/google/protobuf/arena_unittest.cc",
516 "src/google/protobuf/arenastring_unittest.cc",
Jisi Liu1c682e02017-10-18 14:31:23 -0700517 "src/google/protobuf/compiler/annotation_test_util.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700518 "src/google/protobuf/compiler/command_line_interface_unittest.cc",
519 "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
Jisi Liu11b66612017-07-19 12:10:43 -0700520 "src/google/protobuf/compiler/cpp/cpp_move_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700521 "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
522 "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
Jisi Liu1f4f3e22016-04-18 14:12:08 -0700523 "src/google/protobuf/compiler/cpp/metadata_test.cc",
Feng Xiao32d78302017-03-29 14:01:40 -0700524 "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700525 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
526 "src/google/protobuf/compiler/importer_unittest.cc",
527 "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
528 "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
529 "src/google/protobuf/compiler/mock_code_generator.cc",
530 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
531 "src/google/protobuf/compiler/parser_unittest.cc",
532 "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
533 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
534 "src/google/protobuf/descriptor_database_unittest.cc",
535 "src/google/protobuf/descriptor_unittest.cc",
536 "src/google/protobuf/drop_unknown_fields_test.cc",
537 "src/google/protobuf/dynamic_message_unittest.cc",
538 "src/google/protobuf/extension_set_unittest.cc",
539 "src/google/protobuf/generated_message_reflection_unittest.cc",
540 "src/google/protobuf/io/coded_stream_unittest.cc",
541 "src/google/protobuf/io/printer_unittest.cc",
542 "src/google/protobuf/io/tokenizer_unittest.cc",
543 "src/google/protobuf/io/zero_copy_stream_unittest.cc",
544 "src/google/protobuf/map_field_test.cc",
545 "src/google/protobuf/map_test.cc",
546 "src/google/protobuf/message_unittest.cc",
547 "src/google/protobuf/no_field_presence_test.cc",
548 "src/google/protobuf/preserve_unknown_enum_test.cc",
Chad Whipkeybaf52bd2016-04-15 09:23:50 -0700549 "src/google/protobuf/proto3_arena_lite_unittest.cc",
Jisi Liuf86d39c2016-04-28 14:43:22 -0700550 "src/google/protobuf/proto3_arena_unittest.cc",
Chad Whipkeybaf52bd2016-04-15 09:23:50 -0700551 "src/google/protobuf/proto3_lite_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700552 "src/google/protobuf/reflection_ops_unittest.cc",
553 "src/google/protobuf/repeated_field_reflection_unittest.cc",
554 "src/google/protobuf/repeated_field_unittest.cc",
555 "src/google/protobuf/stubs/bytestream_unittest.cc",
556 "src/google/protobuf/stubs/common_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700557 "src/google/protobuf/stubs/int128_unittest.cc",
Jisi Liu759245a2017-07-25 11:52:33 -0700558 "src/google/protobuf/stubs/io_win32_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700559 "src/google/protobuf/stubs/once_unittest.cc",
560 "src/google/protobuf/stubs/status_test.cc",
561 "src/google/protobuf/stubs/statusor_test.cc",
562 "src/google/protobuf/stubs/stringpiece_unittest.cc",
563 "src/google/protobuf/stubs/stringprintf_unittest.cc",
564 "src/google/protobuf/stubs/structurally_valid_unittest.cc",
565 "src/google/protobuf/stubs/strutil_unittest.cc",
566 "src/google/protobuf/stubs/template_util_unittest.cc",
567 "src/google/protobuf/stubs/time_test.cc",
568 "src/google/protobuf/stubs/type_traits_unittest.cc",
569 "src/google/protobuf/text_format_unittest.cc",
570 "src/google/protobuf/unknown_field_set_unittest.cc",
Byron Yicb3e84b2017-03-16 20:01:22 +0800571 "src/google/protobuf/util/delimited_message_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700572 "src/google/protobuf/util/field_comparator_test.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700573 "src/google/protobuf/util/field_mask_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700574 "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
575 "src/google/protobuf/util/internal/json_objectwriter_test.cc",
576 "src/google/protobuf/util/internal/json_stream_parser_test.cc",
577 "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
578 "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
579 "src/google/protobuf/util/internal/type_info_test_helper.cc",
580 "src/google/protobuf/util/json_util_test.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800581 "src/google/protobuf/util/message_differencer_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700582 "src/google/protobuf/util/time_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700583 "src/google/protobuf/util/type_resolver_util_test.cc",
584 "src/google/protobuf/well_known_types_unittest.cc",
585 "src/google/protobuf/wire_format_unittest.cc",
586 ],
587 copts = COPTS,
588 data = [
589 ":test_plugin",
Jisi Liu598480d2015-10-21 11:19:16 -0700590 ] + glob([
591 "src/google/protobuf/**/*",
Feng Xiaoacde1652017-03-29 15:14:18 -0700592 # Files for csharp_bootstrap_unittest.cc.
593 "conformance/**/*",
594 "csharp/src/**/*",
Jisi Liu598480d2015-10-21 11:19:16 -0700595 ]),
Jisi Liu7a0c4312015-06-18 16:45:27 -0700596 includes = [
597 "src/",
598 ],
599 linkopts = LINK_OPTS,
600 deps = [
Jisi Liu993fb702015-10-19 17:19:49 -0700601 ":cc_test_protos",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700602 ":protobuf",
603 ":protoc_lib",
604 "//external:gtest_main",
605 ],
606)
Jisi Liu993fb702015-10-19 17:19:49 -0700607
608################################################################################
609# Java support
610################################################################################
Steven Parkesea188662016-02-25 07:53:19 -0800611internal_gen_well_known_protos_java(
Ming Zhao4fe03812016-01-21 23:03:28 -0800612 srcs = WELL_KNOWN_PROTOS,
Jisi Liu993fb702015-10-19 17:19:49 -0700613)
614
615java_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700616 name = "protobuf_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700617 srcs = glob([
Ming Zhao4fe03812016-01-21 23:03:28 -0800618 "java/core/src/main/java/com/google/protobuf/*.java",
Jisi Liu993fb702015-10-19 17:19:49 -0700619 ]) + [
Ming Zhao4fe03812016-01-21 23:03:28 -0800620 ":gen_well_known_protos_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700621 ],
David Ostrovsky85b488f2018-01-31 09:01:27 +0100622 javacopts = select({
623 "//:jdk9": ["--add-modules=jdk.unsupported"],
624 "//conditions:default": ["-source 7", "-target 7"],
625 }),
Jisi Liu993fb702015-10-19 17:19:49 -0700626 visibility = ["//visibility:public"],
627)
628
Steven Parkesa9244ca2016-03-10 17:50:25 -0800629java_library(
630 name = "protobuf_java_util",
631 srcs = glob([
632 "java/util/src/main/java/com/google/protobuf/util/*.java",
633 ]),
David Ostrovsky019ceea2018-01-25 06:05:14 +0100634 javacopts = ["-source 7", "-target 7"],
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800635 visibility = ["//visibility:public"],
Steven Parkesa9244ca2016-03-10 17:50:25 -0800636 deps = [
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700637 "protobuf_java",
638 "//external:gson",
639 "//external:guava",
Steven Parkesa9244ca2016-03-10 17:50:25 -0800640 ],
Steven Parkesa9244ca2016-03-10 17:50:25 -0800641)
642
Jisi Liu993fb702015-10-19 17:19:49 -0700643################################################################################
644# Python support
645################################################################################
646
David Z. Chen985c9682016-02-11 18:11:10 -0800647py_library(
Jisi Liu993fb702015-10-19 17:19:49 -0700648 name = "python_srcs",
649 srcs = glob(
650 [
651 "python/google/protobuf/*.py",
652 "python/google/protobuf/**/*.py",
653 ],
654 exclude = [
David Z. Chen02cd45c2016-05-20 16:49:04 -0700655 "python/google/protobuf/__init__.py",
656 "python/google/protobuf/**/__init__.py",
Jisi Liu993fb702015-10-19 17:19:49 -0700657 "python/google/protobuf/internal/*_test.py",
658 "python/google/protobuf/internal/test_util.py",
659 ],
660 ),
David Z. Chen985c9682016-02-11 18:11:10 -0800661 imports = ["python"],
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800662 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700663)
664
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800665cc_binary(
Richard Shindf5841f2016-10-18 13:16:44 -0700666 name = "python/google/protobuf/internal/_api_implementation.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800667 srcs = ["python/google/protobuf/internal/api_implementation.cc"],
668 copts = COPTS + [
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800669 "-DPYTHON_PROTO2_CPP_IMPL_V2",
670 ],
671 linkshared = 1,
672 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800673 deps = select({
674 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800675 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800676 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800677)
678
679cc_binary(
Richard Shindf5841f2016-10-18 13:16:44 -0700680 name = "python/google/protobuf/pyext/_message.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800681 srcs = glob([
682 "python/google/protobuf/pyext/*.cc",
683 "python/google/protobuf/pyext/*.h",
684 ]),
685 copts = COPTS + [
686 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800687 ] + select({
688 "//conditions:default": [],
689 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
690 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800691 includes = [
692 "python/",
693 "src/",
694 ],
695 linkshared = 1,
696 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800697 deps = [
698 ":protobuf",
699 ] + select({
700 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800701 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800702 }),
703)
704
705config_setting(
706 name = "use_fast_cpp_protos",
707 values = {
708 "define": "use_fast_cpp_protos=true",
709 },
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800710)
711
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800712config_setting(
713 name = "allow_oversize_protos",
714 values = {
715 "define": "allow_oversize_protos=true",
716 },
717)
718
David Z. Chen02cd45c2016-05-20 16:49:04 -0700719# Copy the builtin proto files from src/google/protobuf to
720# python/google/protobuf. This way, the generated Python sources will be in the
721# same directory as the Python runtime sources. This is necessary for the
722# modules to be imported correctly since they are all part of the same Python
723# package.
724internal_copied_filegroup(
725 name = "protos_python",
726 srcs = WELL_KNOWN_PROTOS,
David Z. Chen02cd45c2016-05-20 16:49:04 -0700727 dest = "python",
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800728 strip_prefix = "src",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700729)
730
731# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
732# which case we can simply add :protos_python in srcs.
733COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
734
Jisi Liu993fb702015-10-19 17:19:49 -0700735py_proto_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700736 name = "protobuf_python",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700737 srcs = COPIED_WELL_KNOWN_PROTOS,
738 include = "python",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800739 data = select({
740 "//conditions:default": [],
741 ":use_fast_cpp_protos": [
Richard Shindf5841f2016-10-18 13:16:44 -0700742 ":python/google/protobuf/internal/_api_implementation.so",
743 ":python/google/protobuf/pyext/_message.so",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800744 ],
745 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800746 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700747 protoc = ":protoc",
David Z. Chen985c9682016-02-11 18:11:10 -0800748 py_libs = [
749 ":python_srcs",
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800750 "//external:six",
David Z. Chen985c9682016-02-11 18:11:10 -0800751 ],
Adam Michael6044b242017-03-10 18:06:34 -0500752 py_extra_srcs = glob(["python/**/__init__.py"]),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800753 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700754 visibility = ["//visibility:public"],
755)
756
David Z. Chen02cd45c2016-05-20 16:49:04 -0700757# Copy the test proto files from src/google/protobuf to
758# python/google/protobuf. This way, the generated Python sources will be in the
759# same directory as the Python runtime sources. This is necessary for the
760# modules to be imported correctly by the tests since they are all part of the
761# same Python package.
762internal_copied_filegroup(
763 name = "protos_python_test",
764 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
David Z. Chen02cd45c2016-05-20 16:49:04 -0700765 dest = "python",
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800766 strip_prefix = "src",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700767)
768
769# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
770# which case we can simply add :protos_python_test in srcs.
771COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800772
David Z. Chen02cd45c2016-05-20 16:49:04 -0700773COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
774
Jisi Liu993fb702015-10-19 17:19:49 -0700775py_proto_library(
776 name = "python_common_test_protos",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700777 srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
778 include = "python",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800779 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700780 protoc = ":protoc",
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700781 srcs_version = "PY2AND3",
Jisi Liu166e9bb2015-10-21 10:56:38 -0700782 deps = [":protobuf_python"],
Jisi Liu993fb702015-10-19 17:19:49 -0700783)
784
785py_proto_library(
786 name = "python_specific_test_protos",
Jisi Liu68e13f42015-10-22 11:13:14 -0700787 srcs = glob([
788 "python/google/protobuf/internal/*.proto",
789 "python/google/protobuf/internal/import_test_package/*.proto",
790 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700791 include = "python",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800792 default_runtime = ":protobuf_python",
Jisi Liu04658a32015-10-20 15:00:13 -0700793 protoc = ":protoc",
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700794 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700795 deps = [":python_common_test_protos"],
796)
797
798py_library(
799 name = "python_tests",
David Z. Chen985c9682016-02-11 18:11:10 -0800800 srcs = glob(
801 [
802 "python/google/protobuf/internal/*_test.py",
803 "python/google/protobuf/internal/test_util.py",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700804 "python/google/protobuf/internal/import_test_package/__init__.py",
David Z. Chen985c9682016-02-11 18:11:10 -0800805 ],
806 ),
807 imports = ["python"],
Geoffrey Irving29799232015-12-03 13:11:19 -0800808 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700809 deps = [
Jisi Liu166e9bb2015-10-21 10:56:38 -0700810 ":protobuf_python",
Jisi Liu598480d2015-10-21 11:19:16 -0700811 ":python_common_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700812 ":python_specific_test_protos",
813 ],
814)
815
816internal_protobuf_py_tests(
Jisi Liu8f540262015-10-20 16:21:41 -0700817 name = "python_tests_batch",
Jisi Liu68e13f42015-10-22 11:13:14 -0700818 data = glob([
819 "src/google/protobuf/**/*",
820 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700821 modules = [
822 "descriptor_database_test",
823 "descriptor_pool_test",
824 "descriptor_test",
825 "generator_test",
826 "json_format_test",
827 "message_factory_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700828 "message_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700829 "proto_builder_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700830 "reflection_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700831 "service_reflection_test",
832 "symbol_database_test",
833 "text_encoding_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700834 "text_format_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700835 "unknown_fields_test",
836 "wire_format_test",
837 ],
838 deps = [":python_tests"],
839)
cgrushko45d92ae2016-12-02 19:40:50 -0500840
841proto_lang_toolchain(
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800842 name = "cc_toolchain",
843 command_line = "--cpp_out=$(OUT)",
844 runtime = ":protobuf",
845 visibility = ["//visibility:public"],
John Millikin350b1352018-02-24 11:36:49 -0800846 blacklisted_protos = [":_internal_wkt_protos_genrule"],
cgrushko45d92ae2016-12-02 19:40:50 -0500847)
cgrushkoe4baf3f2017-01-12 12:51:04 -0500848
849proto_lang_toolchain(
850 name = "java_toolchain",
851 command_line = "--java_out=$(OUT)",
852 runtime = ":protobuf_java",
853 visibility = ["//visibility:public"],
854)
makdharma286f0592017-05-01 09:49:26 -0700855
856OBJC_HDRS = [
857 "objectivec/GPBArray.h",
858 "objectivec/GPBBootstrap.h",
859 "objectivec/GPBCodedInputStream.h",
860 "objectivec/GPBCodedOutputStream.h",
861 "objectivec/GPBDescriptor.h",
862 "objectivec/GPBDictionary.h",
863 "objectivec/GPBExtensionInternals.h",
864 "objectivec/GPBExtensionRegistry.h",
865 "objectivec/GPBMessage.h",
866 "objectivec/GPBProtocolBuffers.h",
867 "objectivec/GPBProtocolBuffers_RuntimeSupport.h",
868 "objectivec/GPBRootObject.h",
869 "objectivec/GPBRuntimeTypes.h",
870 "objectivec/GPBUnknownField.h",
871 "objectivec/GPBUnknownFieldSet.h",
872 "objectivec/GPBUtilities.h",
873 "objectivec/GPBWellKnownTypes.h",
874 "objectivec/GPBWireFormat.h",
875 "objectivec/google/protobuf/Any.pbobjc.h",
876 "objectivec/google/protobuf/Api.pbobjc.h",
877 "objectivec/google/protobuf/Duration.pbobjc.h",
878 "objectivec/google/protobuf/Empty.pbobjc.h",
879 "objectivec/google/protobuf/FieldMask.pbobjc.h",
880 "objectivec/google/protobuf/SourceContext.pbobjc.h",
881 "objectivec/google/protobuf/Struct.pbobjc.h",
882 "objectivec/google/protobuf/Timestamp.pbobjc.h",
883 "objectivec/google/protobuf/Type.pbobjc.h",
884 "objectivec/google/protobuf/Wrappers.pbobjc.h",
885]
886
887OBJC_PRIVATE_HDRS = [
888 "objectivec/GPBArray_PackagePrivate.h",
889 "objectivec/GPBCodedInputStream_PackagePrivate.h",
890 "objectivec/GPBCodedOutputStream_PackagePrivate.h",
891 "objectivec/GPBDescriptor_PackagePrivate.h",
892 "objectivec/GPBDictionary_PackagePrivate.h",
893 "objectivec/GPBMessage_PackagePrivate.h",
894 "objectivec/GPBRootObject_PackagePrivate.h",
895 "objectivec/GPBUnknownFieldSet_PackagePrivate.h",
896 "objectivec/GPBUnknownField_PackagePrivate.h",
897 "objectivec/GPBUtilities_PackagePrivate.h",
898]
899
900OBJC_SRCS = [
901 "objectivec/GPBArray.m",
902 "objectivec/GPBCodedInputStream.m",
903 "objectivec/GPBCodedOutputStream.m",
904 "objectivec/GPBDescriptor.m",
905 "objectivec/GPBDictionary.m",
906 "objectivec/GPBExtensionInternals.m",
907 "objectivec/GPBExtensionRegistry.m",
908 "objectivec/GPBMessage.m",
909 "objectivec/GPBRootObject.m",
910 "objectivec/GPBUnknownField.m",
911 "objectivec/GPBUnknownFieldSet.m",
912 "objectivec/GPBUtilities.m",
913 "objectivec/GPBWellKnownTypes.m",
914 "objectivec/GPBWireFormat.m",
915 "objectivec/google/protobuf/Any.pbobjc.m",
916 "objectivec/google/protobuf/Api.pbobjc.m",
917 "objectivec/google/protobuf/Duration.pbobjc.m",
918 "objectivec/google/protobuf/Empty.pbobjc.m",
919 "objectivec/google/protobuf/FieldMask.pbobjc.m",
920 "objectivec/google/protobuf/SourceContext.pbobjc.m",
921 "objectivec/google/protobuf/Struct.pbobjc.m",
922 "objectivec/google/protobuf/Timestamp.pbobjc.m",
923 "objectivec/google/protobuf/Type.pbobjc.m",
924 "objectivec/google/protobuf/Wrappers.pbobjc.m",
925]
926
927objc_library(
928 name = "objectivec",
929 hdrs = OBJC_HDRS + OBJC_PRIVATE_HDRS,
930 includes = [
931 "objectivec",
932 ],
933 non_arc_srcs = OBJC_SRCS,
934 visibility = ["//visibility:public"],
935)