blob: d6fb85d81cbc3960b7e0efce96f0b5f12815e463 [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
Pascal Muetscharda6957f22018-03-22 13:14:10 -070022MSVC_COPTS = [
Yun Peng0b059a32017-05-31 14:01:23 +020023 "/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({
Pascal Muetscharda6957f22018-03-22 13:14:10 -070029 ":msvc" : MSVC_COPTS,
Yun Peng0b059a32017-05-31 14:01:23 +020030 "//conditions:default": [
31 "-DHAVE_PTHREAD",
32 "-Wall",
33 "-Wwrite-strings",
34 "-Woverloaded-virtual",
35 "-Wno-sign-compare",
36 "-Wno-unused-function",
Justine Tunneyac5371d2017-11-17 18:27:39 -080037 # Prevents ISO C++ const string assignment warnings for pyext sources.
38 "-Wno-writable-strings",
Yun Peng0b059a32017-05-31 14:01:23 +020039 ],
40})
41
42config_setting(
Pascal Muetscharda6957f22018-03-22 13:14:10 -070043 name = "msvc",
44 values = { "compiler": "msvc-cl" },
Yun Peng0b059a32017-05-31 14:01:23 +020045)
46
Andrew Harpb56b4612016-04-04 15:13:30 -040047config_setting(
48 name = "android",
49 values = {
50 "crosstool_top": "//external:android/crosstool",
51 },
52)
53
Pascal Muetscharda6957f22018-03-22 13:14:10 -070054# Android and MSVC builds do not need to link in a separate pthread library.
Andrew Harpb56b4612016-04-04 15:13:30 -040055LINK_OPTS = select({
Andrew Harp3b4e7dc2016-04-04 16:13:31 -040056 ":android": [],
Pascal Muetscharda6957f22018-03-22 13:14:10 -070057 ":msvc": [],
Daniel Ylitalo32fa55e2017-01-25 22:04:11 +010058 "//conditions:default": ["-lpthread", "-lm"],
Andrew Harpb56b4612016-04-04 15:13:30 -040059})
Jisi Liud19604f2015-06-17 17:37:58 -070060
Jisi Liu04658a32015-10-20 15:00:13 -070061load(
cgrushko65a4d202017-02-08 15:23:57 -050062 ":protobuf.bzl",
Jisi Liu04658a32015-10-20 15:00:13 -070063 "cc_proto_library",
64 "py_proto_library",
David Z. Chen02cd45c2016-05-20 16:49:04 -070065 "internal_copied_filegroup",
Steven Parkesea188662016-02-25 07:53:19 -080066 "internal_gen_well_known_protos_java",
Jisi Liu04658a32015-10-20 15:00:13 -070067 "internal_protobuf_py_tests",
68)
Jisi Liu39362b32015-10-14 17:12:11 -070069
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",
Jisi Liu12c186f2017-07-25 14:38:00 -070077 "src/google/protobuf/generated_message_table_driven_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070078 "src/google/protobuf/generated_message_util.cc",
Adam Cozzette609d7522017-12-07 14:16:50 -080079 "src/google/protobuf/implicit_weak_message.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070080 "src/google/protobuf/io/coded_stream.cc",
81 "src/google/protobuf/io/zero_copy_stream.cc",
82 "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
83 "src/google/protobuf/message_lite.cc",
84 "src/google/protobuf/repeated_field.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 Liu759245a2017-07-25 11:52:33 -070088 "src/google/protobuf/stubs/io_win32.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"]),
Param Reddy16792c62017-10-15 13:06:58 -070099 copts = COPTS,
Jisi Liud19604f2015-06-17 17:37:58 -0700100 includes = ["src/"],
101 linkopts = LINK_OPTS,
102 visibility = ["//visibility:public"],
103)
104
105cc_library(
106 name = "protobuf",
107 srcs = [
108 # AUTOGEN(protobuf_srcs)
109 "src/google/protobuf/any.cc",
110 "src/google/protobuf/any.pb.cc",
111 "src/google/protobuf/api.pb.cc",
112 "src/google/protobuf/compiler/importer.cc",
113 "src/google/protobuf/compiler/parser.cc",
114 "src/google/protobuf/descriptor.cc",
115 "src/google/protobuf/descriptor.pb.cc",
116 "src/google/protobuf/descriptor_database.cc",
117 "src/google/protobuf/duration.pb.cc",
118 "src/google/protobuf/dynamic_message.cc",
119 "src/google/protobuf/empty.pb.cc",
120 "src/google/protobuf/extension_set_heavy.cc",
121 "src/google/protobuf/field_mask.pb.cc",
122 "src/google/protobuf/generated_message_reflection.cc",
Jisi Liu759245a2017-07-25 11:52:33 -0700123 "src/google/protobuf/generated_message_table_driven.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700124 "src/google/protobuf/io/gzip_stream.cc",
125 "src/google/protobuf/io/printer.cc",
126 "src/google/protobuf/io/strtod.cc",
127 "src/google/protobuf/io/tokenizer.cc",
128 "src/google/protobuf/io/zero_copy_stream_impl.cc",
129 "src/google/protobuf/map_field.cc",
130 "src/google/protobuf/message.cc",
131 "src/google/protobuf/reflection_ops.cc",
132 "src/google/protobuf/service.cc",
133 "src/google/protobuf/source_context.pb.cc",
134 "src/google/protobuf/struct.pb.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700135 "src/google/protobuf/stubs/mathlimits.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700136 "src/google/protobuf/stubs/substitute.cc",
137 "src/google/protobuf/text_format.cc",
138 "src/google/protobuf/timestamp.pb.cc",
139 "src/google/protobuf/type.pb.cc",
140 "src/google/protobuf/unknown_field_set.cc",
Bairen Yi312e2db2017-03-21 03:52:37 +0800141 "src/google/protobuf/util/delimited_message_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700142 "src/google/protobuf/util/field_comparator.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700143 "src/google/protobuf/util/field_mask_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700144 "src/google/protobuf/util/internal/datapiece.cc",
145 "src/google/protobuf/util/internal/default_value_objectwriter.cc",
146 "src/google/protobuf/util/internal/error_listener.cc",
147 "src/google/protobuf/util/internal/field_mask_utility.cc",
148 "src/google/protobuf/util/internal/json_escaping.cc",
149 "src/google/protobuf/util/internal/json_objectwriter.cc",
150 "src/google/protobuf/util/internal/json_stream_parser.cc",
151 "src/google/protobuf/util/internal/object_writer.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800152 "src/google/protobuf/util/internal/proto_writer.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700153 "src/google/protobuf/util/internal/protostream_objectsource.cc",
154 "src/google/protobuf/util/internal/protostream_objectwriter.cc",
155 "src/google/protobuf/util/internal/type_info.cc",
156 "src/google/protobuf/util/internal/type_info_test_helper.cc",
157 "src/google/protobuf/util/internal/utility.cc",
158 "src/google/protobuf/util/json_util.cc",
159 "src/google/protobuf/util/message_differencer.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700160 "src/google/protobuf/util/time_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700161 "src/google/protobuf/util/type_resolver_util.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700162 "src/google/protobuf/wire_format.cc",
163 "src/google/protobuf/wrappers.pb.cc",
164 ],
Lukacs T. Berki915d9cd2015-11-16 09:36:32 +0100165 hdrs = glob(["src/**/*.h"]),
Param Reddy16792c62017-10-15 13:06:58 -0700166 copts = COPTS,
Jisi Liud19604f2015-06-17 17:37:58 -0700167 includes = ["src/"],
168 linkopts = LINK_OPTS,
169 visibility = ["//visibility:public"],
170 deps = [":protobuf_lite"],
171)
172
Manjunath Kudlur6837b2d2017-03-02 18:02:05 -0800173# This provides just the header files for use in projects that need to build
174# shared libraries for dynamic loading. This target is available until Bazel
175# adds native support for such use cases.
176# TODO(keveman): Remove this target once the support gets added to Bazel.
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800177cc_library(
178 name = "protobuf_headers",
179 hdrs = glob(["src/**/*.h"]),
180 includes = ["src/"],
181 visibility = ["//visibility:public"],
182)
183
Jisi Liu14c8f8a2015-10-20 15:36:22 -0700184objc_library(
185 name = "protobuf_objc",
186 hdrs = ["objectivec/GPBProtocolBuffers.h"],
187 includes = ["objectivec"],
188 non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
189 visibility = ["//visibility:public"],
190)
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700191
Jakob Buchgraber699c0eb2017-09-05 17:15:10 +0200192# Map of all well known protos.
193# name => (include path, imports)
194WELL_KNOWN_PROTO_MAP = {
195 "any" : ("google/protobuf/any.proto", []),
196 "api" : ("google/protobuf/api.proto", ["source_context", "type"]),
197 "compiler_plugin" : ("google/protobuf/compiler/plugin.proto", ["descriptor"]),
198 "descriptor" : ("google/protobuf/descriptor.proto", []),
199 "duration" : ("google/protobuf/duration.proto", []),
200 "empty" : ("google/protobuf/empty.proto", []),
201 "field_mask" : ("google/protobuf/field_mask.proto", []),
202 "source_context" : ("google/protobuf/source_context.proto", []),
203 "struct" : ("google/protobuf/struct.proto", []),
204 "timestamp" : ("google/protobuf/timestamp.proto", []),
205 "type" : ("google/protobuf/type.proto", ["any", "source_context"]),
206 "wrappers" : ("google/protobuf/wrappers.proto", []),
207}
208
209RELATIVE_WELL_KNOWN_PROTOS = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()]
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700210
Jisi Liu993fb702015-10-19 17:19:49 -0700211WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
212
Steven Parkesd5a57322016-03-22 17:56:07 -0700213filegroup(
214 name = "well_known_protos",
215 srcs = WELL_KNOWN_PROTOS,
216 visibility = ["//visibility:public"],
217)
218
Jisi Liu39362b32015-10-14 17:12:11 -0700219cc_proto_library(
220 name = "cc_wkt_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700221 srcs = WELL_KNOWN_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700222 include = "src",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800223 default_runtime = ":protobuf",
Jisi Liu993fb702015-10-19 17:19:49 -0700224 internal_bootstrap_hack = 1,
Jisi Liu04658a32015-10-20 15:00:13 -0700225 protoc = ":protoc",
Jisi Liu6a40bf82015-11-17 12:36:21 -0800226 visibility = ["//visibility:public"],
Jisi Liu39362b32015-10-14 17:12:11 -0700227)
228
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700229################################################################################
Jakob Buchgraber699c0eb2017-09-05 17:15:10 +0200230# Well Known Types Proto Library Rules
231#
232# These proto_library rules can be used with one of the language specific proto
233# library rules i.e. java_proto_library:
234#
235# java_proto_library(
236# name = "any_java_proto",
237# deps = ["@com_google_protobuf//:any_proto],
238# )
239################################################################################
240
241internal_copied_filegroup(
242 name = "_internal_wkt_protos",
243 srcs = WELL_KNOWN_PROTOS,
244 dest = "",
245 strip_prefix = "src",
James O'Kane950f5e42018-03-08 22:30:44 -0800246 visibility = ["//visibility:private"],
Jakob Buchgraber699c0eb2017-09-05 17:15:10 +0200247)
248
249[proto_library(
250 name = proto[0] + "_proto",
251 srcs = [proto[1][0]],
252 deps = [dep + "_proto" for dep in proto[1][1]],
253 visibility = ["//visibility:public"],
254 ) for proto in WELL_KNOWN_PROTO_MAP.items()]
255
256################################################################################
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700257# Protocol Buffers Compiler
258################################################################################
259
Adam Cozzetted1e7bd92016-12-20 09:08:19 -0800260cc_binary(
261 name = "js_embed",
262 srcs = ["src/google/protobuf/compiler/js/embed.cc"],
263 visibility = ["//visibility:public"],
264)
265
266genrule(
267 name = "generate_js_well_known_types_embed",
268 srcs = [
269 "src/google/protobuf/compiler/js/well_known_types/any.js",
270 "src/google/protobuf/compiler/js/well_known_types/struct.js",
271 "src/google/protobuf/compiler/js/well_known_types/timestamp.js",
272 ],
273 outs = ["src/google/protobuf/compiler/js/well_known_types_embed.cc"],
274 cmd = "$(location :js_embed) $(SRCS) > $@",
275 tools = [":js_embed"],
276)
277
Jisi Liud19604f2015-06-17 17:37:58 -0700278cc_library(
279 name = "protoc_lib",
280 srcs = [
281 # AUTOGEN(protoc_lib_srcs)
282 "src/google/protobuf/compiler/code_generator.cc",
283 "src/google/protobuf/compiler/command_line_interface.cc",
284 "src/google/protobuf/compiler/cpp/cpp_enum.cc",
285 "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
286 "src/google/protobuf/compiler/cpp/cpp_extension.cc",
287 "src/google/protobuf/compiler/cpp/cpp_field.cc",
288 "src/google/protobuf/compiler/cpp/cpp_file.cc",
289 "src/google/protobuf/compiler/cpp/cpp_generator.cc",
290 "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
291 "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
292 "src/google/protobuf/compiler/cpp/cpp_message.cc",
293 "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
Adam Cozzette13fd0452017-09-12 10:32:01 -0700294 "src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700295 "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
296 "src/google/protobuf/compiler/cpp/cpp_service.cc",
297 "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
Ming Zhao5cdd9362015-10-05 14:37:21 -0700298 "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700299 "src/google/protobuf/compiler/csharp/csharp_enum.cc",
300 "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700301 "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
302 "src/google/protobuf/compiler/csharp/csharp_generator.cc",
303 "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100304 "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700305 "src/google/protobuf/compiler/csharp/csharp_message.cc",
306 "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
307 "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
Jon Skeeta6361a12015-11-19 13:05:17 +0000308 "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700309 "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
310 "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
311 "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
312 "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100313 "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700314 "src/google/protobuf/compiler/java/java_context.cc",
315 "src/google/protobuf/compiler/java/java_doc_comment.cc",
316 "src/google/protobuf/compiler/java/java_enum.cc",
317 "src/google/protobuf/compiler/java/java_enum_field.cc",
318 "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700319 "src/google/protobuf/compiler/java/java_enum_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700320 "src/google/protobuf/compiler/java/java_extension.cc",
Jisi Liu1f4f3e22016-04-18 14:12:08 -0700321 "src/google/protobuf/compiler/java/java_extension_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700322 "src/google/protobuf/compiler/java/java_field.cc",
323 "src/google/protobuf/compiler/java/java_file.cc",
324 "src/google/protobuf/compiler/java/java_generator.cc",
325 "src/google/protobuf/compiler/java/java_generator_factory.cc",
326 "src/google/protobuf/compiler/java/java_helpers.cc",
327 "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
328 "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
329 "src/google/protobuf/compiler/java/java_map_field.cc",
330 "src/google/protobuf/compiler/java/java_map_field_lite.cc",
331 "src/google/protobuf/compiler/java/java_message.cc",
332 "src/google/protobuf/compiler/java/java_message_builder.cc",
333 "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
334 "src/google/protobuf/compiler/java/java_message_field.cc",
335 "src/google/protobuf/compiler/java/java_message_field_lite.cc",
336 "src/google/protobuf/compiler/java/java_message_lite.cc",
337 "src/google/protobuf/compiler/java/java_name_resolver.cc",
338 "src/google/protobuf/compiler/java/java_primitive_field.cc",
339 "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
340 "src/google/protobuf/compiler/java/java_service.cc",
341 "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
342 "src/google/protobuf/compiler/java/java_string_field.cc",
343 "src/google/protobuf/compiler/java/java_string_field_lite.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800344 "src/google/protobuf/compiler/js/js_generator.cc",
Jisi Liuf92b4552016-12-05 10:16:47 -0800345 "src/google/protobuf/compiler/js/well_known_types_embed.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700346 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
347 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
348 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
349 "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
350 "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
351 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
352 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
353 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
354 "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
355 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
356 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
357 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
Jisi Liud9473082016-09-22 15:14:58 -0700358 "src/google/protobuf/compiler/php/php_generator.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700359 "src/google/protobuf/compiler/plugin.cc",
Feng Xiaofd595fc2018-03-01 16:36:05 -0800360 "src/google/protobuf/compiler/plugin.pb.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700361 "src/google/protobuf/compiler/python/python_generator.cc",
362 "src/google/protobuf/compiler/ruby/ruby_generator.cc",
363 "src/google/protobuf/compiler/subprocess.cc",
364 "src/google/protobuf/compiler/zip_writer.cc",
365 ],
366 copts = COPTS,
367 includes = ["src/"],
368 linkopts = LINK_OPTS,
369 visibility = ["//visibility:public"],
370 deps = [":protobuf"],
371)
372
373cc_binary(
374 name = "protoc",
375 srcs = ["src/google/protobuf/compiler/main.cc"],
Jisi Liud19604f2015-06-17 17:37:58 -0700376 linkopts = LINK_OPTS,
377 visibility = ["//visibility:public"],
378 deps = [":protoc_lib"],
379)
380
Jisi Liud19604f2015-06-17 17:37:58 -0700381################################################################################
382# Tests
383################################################################################
384
Jisi Liu993fb702015-10-19 17:19:49 -0700385RELATIVE_LITE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700386 # AUTOGEN(lite_test_protos)
387 "google/protobuf/map_lite_unittest.proto",
388 "google/protobuf/unittest_import_lite.proto",
389 "google/protobuf/unittest_import_public_lite.proto",
390 "google/protobuf/unittest_lite.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700391 "google/protobuf/unittest_no_arena_lite.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700392]
393
Jisi Liu993fb702015-10-19 17:19:49 -0700394LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
395
396RELATIVE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700397 # AUTOGEN(test_protos)
398 "google/protobuf/any_test.proto",
399 "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
400 "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
401 "google/protobuf/map_proto2_unittest.proto",
402 "google/protobuf/map_unittest.proto",
403 "google/protobuf/unittest.proto",
404 "google/protobuf/unittest_arena.proto",
405 "google/protobuf/unittest_custom_options.proto",
406 "google/protobuf/unittest_drop_unknown_fields.proto",
407 "google/protobuf/unittest_embed_optimize_for.proto",
408 "google/protobuf/unittest_empty.proto",
409 "google/protobuf/unittest_enormous_descriptor.proto",
410 "google/protobuf/unittest_import.proto",
411 "google/protobuf/unittest_import_public.proto",
Feng Xiao32d78302017-03-29 14:01:40 -0700412 "google/protobuf/unittest_lazy_dependencies.proto",
413 "google/protobuf/unittest_lazy_dependencies_custom_option.proto",
414 "google/protobuf/unittest_lazy_dependencies_enum.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700415 "google/protobuf/unittest_lite_imports_nonlite.proto",
416 "google/protobuf/unittest_mset.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700417 "google/protobuf/unittest_mset_wire_format.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700418 "google/protobuf/unittest_no_arena.proto",
419 "google/protobuf/unittest_no_arena_import.proto",
420 "google/protobuf/unittest_no_field_presence.proto",
421 "google/protobuf/unittest_no_generic_services.proto",
422 "google/protobuf/unittest_optimize_for.proto",
423 "google/protobuf/unittest_preserve_unknown_enum.proto",
424 "google/protobuf/unittest_preserve_unknown_enum2.proto",
425 "google/protobuf/unittest_proto3_arena.proto",
Chad Whipkeybaf52bd2016-04-15 09:23:50 -0700426 "google/protobuf/unittest_proto3_arena_lite.proto",
427 "google/protobuf/unittest_proto3_lite.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700428 "google/protobuf/unittest_well_known_types.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700429 "google/protobuf/util/internal/testdata/anys.proto",
430 "google/protobuf/util/internal/testdata/books.proto",
431 "google/protobuf/util/internal/testdata/default_value.proto",
432 "google/protobuf/util/internal/testdata/default_value_test.proto",
433 "google/protobuf/util/internal/testdata/field_mask.proto",
434 "google/protobuf/util/internal/testdata/maps.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700435 "google/protobuf/util/internal/testdata/oneofs.proto",
Jisi Liu9d4657a2016-09-22 15:11:17 -0700436 "google/protobuf/util/internal/testdata/proto3.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700437 "google/protobuf/util/internal/testdata/struct.proto",
438 "google/protobuf/util/internal/testdata/timestamp_duration.proto",
Jisi Liu9d4657a2016-09-22 15:11:17 -0700439 "google/protobuf/util/internal/testdata/wrappers.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700440 "google/protobuf/util/json_format_proto3.proto",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800441 "google/protobuf/util/message_differencer_unittest.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700442]
443
Jisi Liu993fb702015-10-19 17:19:49 -0700444TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
445
Jisi Liu39362b32015-10-14 17:12:11 -0700446cc_proto_library(
447 name = "cc_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700448 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700449 include = "src",
Jisi Liube92ffb2015-10-27 15:11:38 -0700450 default_runtime = ":protobuf",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800451 protoc = ":protoc",
Jisi Liud8701b52015-10-16 11:44:21 -0700452 deps = [":cc_wkt_protos"],
Jisi Liud19604f2015-06-17 17:37:58 -0700453)
454
455COMMON_TEST_SRCS = [
456 # AUTOGEN(common_test_srcs)
457 "src/google/protobuf/arena_test_util.cc",
458 "src/google/protobuf/map_test_util.cc",
459 "src/google/protobuf/test_util.cc",
Adam Cozzette5bed3682018-03-23 10:19:04 -0700460 "src/google/protobuf/test_util.inc",
Jisi Liud19604f2015-06-17 17:37:58 -0700461 "src/google/protobuf/testing/file.cc",
462 "src/google/protobuf/testing/googletest.cc",
463]
464
Jisi Liu7a0c4312015-06-18 16:45:27 -0700465cc_binary(
466 name = "test_plugin",
467 srcs = [
468 # AUTOGEN(test_plugin_srcs)
469 "src/google/protobuf/compiler/mock_code_generator.cc",
470 "src/google/protobuf/compiler/test_plugin.cc",
471 "src/google/protobuf/testing/file.cc",
472 ],
473 deps = [
474 ":protobuf",
475 ":protoc_lib",
476 "//external:gtest",
477 ],
478)
479
480cc_test(
Jisi Liu759245a2017-07-25 11:52:33 -0700481 name = "win32_test",
482 srcs = ["src/google/protobuf/stubs/io_win32_unittest.cc"],
483 deps = [
484 ":protobuf_lite",
485 "//external:gtest_main",
486 ],
487 tags = ["manual", "windows"],
488)
489
490cc_test(
Jisi Liu7a0c4312015-06-18 16:45:27 -0700491 name = "protobuf_test",
Jisi Liu39362b32015-10-14 17:12:11 -0700492 srcs = COMMON_TEST_SRCS + [
Jisi Liu7a0c4312015-06-18 16:45:27 -0700493 # AUTOGEN(test_srcs)
494 "src/google/protobuf/any_test.cc",
495 "src/google/protobuf/arena_unittest.cc",
496 "src/google/protobuf/arenastring_unittest.cc",
Jisi Liu1c682e02017-10-18 14:31:23 -0700497 "src/google/protobuf/compiler/annotation_test_util.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700498 "src/google/protobuf/compiler/command_line_interface_unittest.cc",
499 "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
Jisi Liu11b66612017-07-19 12:10:43 -0700500 "src/google/protobuf/compiler/cpp/cpp_move_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700501 "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
502 "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
Adam Cozzette5bed3682018-03-23 10:19:04 -0700503 "src/google/protobuf/compiler/cpp/cpp_unittest.inc",
Jisi Liu1f4f3e22016-04-18 14:12:08 -0700504 "src/google/protobuf/compiler/cpp/metadata_test.cc",
Feng Xiao32d78302017-03-29 14:01:40 -0700505 "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700506 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
507 "src/google/protobuf/compiler/importer_unittest.cc",
508 "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
509 "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
510 "src/google/protobuf/compiler/mock_code_generator.cc",
511 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
512 "src/google/protobuf/compiler/parser_unittest.cc",
513 "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
514 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
515 "src/google/protobuf/descriptor_database_unittest.cc",
516 "src/google/protobuf/descriptor_unittest.cc",
517 "src/google/protobuf/drop_unknown_fields_test.cc",
518 "src/google/protobuf/dynamic_message_unittest.cc",
519 "src/google/protobuf/extension_set_unittest.cc",
520 "src/google/protobuf/generated_message_reflection_unittest.cc",
521 "src/google/protobuf/io/coded_stream_unittest.cc",
522 "src/google/protobuf/io/printer_unittest.cc",
523 "src/google/protobuf/io/tokenizer_unittest.cc",
524 "src/google/protobuf/io/zero_copy_stream_unittest.cc",
525 "src/google/protobuf/map_field_test.cc",
526 "src/google/protobuf/map_test.cc",
527 "src/google/protobuf/message_unittest.cc",
Adam Cozzette5bed3682018-03-23 10:19:04 -0700528 "src/google/protobuf/message_unittest.inc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700529 "src/google/protobuf/no_field_presence_test.cc",
530 "src/google/protobuf/preserve_unknown_enum_test.cc",
Chad Whipkeybaf52bd2016-04-15 09:23:50 -0700531 "src/google/protobuf/proto3_arena_lite_unittest.cc",
Jisi Liuf86d39c2016-04-28 14:43:22 -0700532 "src/google/protobuf/proto3_arena_unittest.cc",
Chad Whipkeybaf52bd2016-04-15 09:23:50 -0700533 "src/google/protobuf/proto3_lite_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700534 "src/google/protobuf/reflection_ops_unittest.cc",
535 "src/google/protobuf/repeated_field_reflection_unittest.cc",
536 "src/google/protobuf/repeated_field_unittest.cc",
537 "src/google/protobuf/stubs/bytestream_unittest.cc",
538 "src/google/protobuf/stubs/common_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700539 "src/google/protobuf/stubs/int128_unittest.cc",
Jisi Liu759245a2017-07-25 11:52:33 -0700540 "src/google/protobuf/stubs/io_win32_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700541 "src/google/protobuf/stubs/status_test.cc",
542 "src/google/protobuf/stubs/statusor_test.cc",
543 "src/google/protobuf/stubs/stringpiece_unittest.cc",
544 "src/google/protobuf/stubs/stringprintf_unittest.cc",
545 "src/google/protobuf/stubs/structurally_valid_unittest.cc",
546 "src/google/protobuf/stubs/strutil_unittest.cc",
547 "src/google/protobuf/stubs/template_util_unittest.cc",
548 "src/google/protobuf/stubs/time_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700549 "src/google/protobuf/text_format_unittest.cc",
550 "src/google/protobuf/unknown_field_set_unittest.cc",
Byron Yicb3e84b2017-03-16 20:01:22 +0800551 "src/google/protobuf/util/delimited_message_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700552 "src/google/protobuf/util/field_comparator_test.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700553 "src/google/protobuf/util/field_mask_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700554 "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
555 "src/google/protobuf/util/internal/json_objectwriter_test.cc",
556 "src/google/protobuf/util/internal/json_stream_parser_test.cc",
557 "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
558 "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
559 "src/google/protobuf/util/internal/type_info_test_helper.cc",
560 "src/google/protobuf/util/json_util_test.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800561 "src/google/protobuf/util/message_differencer_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700562 "src/google/protobuf/util/time_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700563 "src/google/protobuf/util/type_resolver_util_test.cc",
564 "src/google/protobuf/well_known_types_unittest.cc",
565 "src/google/protobuf/wire_format_unittest.cc",
566 ],
567 copts = COPTS,
568 data = [
569 ":test_plugin",
Jisi Liu598480d2015-10-21 11:19:16 -0700570 ] + glob([
571 "src/google/protobuf/**/*",
Feng Xiaoacde1652017-03-29 15:14:18 -0700572 # Files for csharp_bootstrap_unittest.cc.
573 "conformance/**/*",
574 "csharp/src/**/*",
Jisi Liu598480d2015-10-21 11:19:16 -0700575 ]),
Jisi Liu7a0c4312015-06-18 16:45:27 -0700576 includes = [
577 "src/",
578 ],
579 linkopts = LINK_OPTS,
580 deps = [
Jisi Liu993fb702015-10-19 17:19:49 -0700581 ":cc_test_protos",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700582 ":protobuf",
583 ":protoc_lib",
584 "//external:gtest_main",
585 ],
586)
Jisi Liu993fb702015-10-19 17:19:49 -0700587
588################################################################################
589# Java support
590################################################################################
Steven Parkesea188662016-02-25 07:53:19 -0800591internal_gen_well_known_protos_java(
Ming Zhao4fe03812016-01-21 23:03:28 -0800592 srcs = WELL_KNOWN_PROTOS,
Jisi Liu993fb702015-10-19 17:19:49 -0700593)
594
595java_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700596 name = "protobuf_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700597 srcs = glob([
Ming Zhao4fe03812016-01-21 23:03:28 -0800598 "java/core/src/main/java/com/google/protobuf/*.java",
Jisi Liu993fb702015-10-19 17:19:49 -0700599 ]) + [
Ming Zhao4fe03812016-01-21 23:03:28 -0800600 ":gen_well_known_protos_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700601 ],
David Ostrovsky85b488f2018-01-31 09:01:27 +0100602 javacopts = select({
603 "//:jdk9": ["--add-modules=jdk.unsupported"],
604 "//conditions:default": ["-source 7", "-target 7"],
605 }),
Jisi Liu993fb702015-10-19 17:19:49 -0700606 visibility = ["//visibility:public"],
607)
608
Steven Parkesa9244ca2016-03-10 17:50:25 -0800609java_library(
610 name = "protobuf_java_util",
611 srcs = glob([
612 "java/util/src/main/java/com/google/protobuf/util/*.java",
613 ]),
David Ostrovsky019ceea2018-01-25 06:05:14 +0100614 javacopts = ["-source 7", "-target 7"],
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800615 visibility = ["//visibility:public"],
Steven Parkesa9244ca2016-03-10 17:50:25 -0800616 deps = [
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700617 "protobuf_java",
618 "//external:gson",
619 "//external:guava",
Steven Parkesa9244ca2016-03-10 17:50:25 -0800620 ],
Steven Parkesa9244ca2016-03-10 17:50:25 -0800621)
622
Jisi Liu993fb702015-10-19 17:19:49 -0700623################################################################################
624# Python support
625################################################################################
626
David Z. Chen985c9682016-02-11 18:11:10 -0800627py_library(
Jisi Liu993fb702015-10-19 17:19:49 -0700628 name = "python_srcs",
629 srcs = glob(
630 [
631 "python/google/protobuf/*.py",
632 "python/google/protobuf/**/*.py",
633 ],
634 exclude = [
David Z. Chen02cd45c2016-05-20 16:49:04 -0700635 "python/google/protobuf/__init__.py",
636 "python/google/protobuf/**/__init__.py",
Jisi Liu993fb702015-10-19 17:19:49 -0700637 "python/google/protobuf/internal/*_test.py",
638 "python/google/protobuf/internal/test_util.py",
639 ],
640 ),
David Z. Chen985c9682016-02-11 18:11:10 -0800641 imports = ["python"],
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800642 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700643)
644
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800645cc_binary(
Richard Shindf5841f2016-10-18 13:16:44 -0700646 name = "python/google/protobuf/internal/_api_implementation.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800647 srcs = ["python/google/protobuf/internal/api_implementation.cc"],
648 copts = COPTS + [
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800649 "-DPYTHON_PROTO2_CPP_IMPL_V2",
650 ],
651 linkshared = 1,
652 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800653 deps = select({
654 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800655 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800656 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800657)
658
659cc_binary(
Richard Shindf5841f2016-10-18 13:16:44 -0700660 name = "python/google/protobuf/pyext/_message.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800661 srcs = glob([
662 "python/google/protobuf/pyext/*.cc",
663 "python/google/protobuf/pyext/*.h",
664 ]),
665 copts = COPTS + [
666 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800667 ] + select({
668 "//conditions:default": [],
669 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
670 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800671 includes = [
672 "python/",
673 "src/",
674 ],
675 linkshared = 1,
676 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800677 deps = [
678 ":protobuf",
679 ] + select({
680 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800681 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800682 }),
683)
684
685config_setting(
686 name = "use_fast_cpp_protos",
687 values = {
688 "define": "use_fast_cpp_protos=true",
689 },
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800690)
691
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800692config_setting(
693 name = "allow_oversize_protos",
694 values = {
695 "define": "allow_oversize_protos=true",
696 },
697)
698
David Z. Chen02cd45c2016-05-20 16:49:04 -0700699# Copy the builtin proto files from src/google/protobuf to
700# python/google/protobuf. This way, the generated Python sources will be in the
701# same directory as the Python runtime sources. This is necessary for the
702# modules to be imported correctly since they are all part of the same Python
703# package.
704internal_copied_filegroup(
705 name = "protos_python",
706 srcs = WELL_KNOWN_PROTOS,
David Z. Chen02cd45c2016-05-20 16:49:04 -0700707 dest = "python",
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800708 strip_prefix = "src",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700709)
710
711# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
712# which case we can simply add :protos_python in srcs.
713COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
714
Jisi Liu993fb702015-10-19 17:19:49 -0700715py_proto_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700716 name = "protobuf_python",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700717 srcs = COPIED_WELL_KNOWN_PROTOS,
718 include = "python",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800719 data = select({
720 "//conditions:default": [],
721 ":use_fast_cpp_protos": [
Richard Shindf5841f2016-10-18 13:16:44 -0700722 ":python/google/protobuf/internal/_api_implementation.so",
723 ":python/google/protobuf/pyext/_message.so",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800724 ],
725 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800726 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700727 protoc = ":protoc",
David Z. Chen985c9682016-02-11 18:11:10 -0800728 py_libs = [
729 ":python_srcs",
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800730 "//external:six",
David Z. Chen985c9682016-02-11 18:11:10 -0800731 ],
Adam Michael6044b242017-03-10 18:06:34 -0500732 py_extra_srcs = glob(["python/**/__init__.py"]),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800733 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700734 visibility = ["//visibility:public"],
735)
736
David Z. Chen02cd45c2016-05-20 16:49:04 -0700737# Copy the test proto files from src/google/protobuf to
738# python/google/protobuf. This way, the generated Python sources will be in the
739# same directory as the Python runtime sources. This is necessary for the
740# modules to be imported correctly by the tests since they are all part of the
741# same Python package.
742internal_copied_filegroup(
743 name = "protos_python_test",
744 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
David Z. Chen02cd45c2016-05-20 16:49:04 -0700745 dest = "python",
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800746 strip_prefix = "src",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700747)
748
749# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
750# which case we can simply add :protos_python_test in srcs.
751COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800752
David Z. Chen02cd45c2016-05-20 16:49:04 -0700753COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
754
Jisi Liu993fb702015-10-19 17:19:49 -0700755py_proto_library(
756 name = "python_common_test_protos",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700757 srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
758 include = "python",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800759 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700760 protoc = ":protoc",
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700761 srcs_version = "PY2AND3",
Jisi Liu166e9bb2015-10-21 10:56:38 -0700762 deps = [":protobuf_python"],
Jisi Liu993fb702015-10-19 17:19:49 -0700763)
764
765py_proto_library(
766 name = "python_specific_test_protos",
Jisi Liu68e13f42015-10-22 11:13:14 -0700767 srcs = glob([
768 "python/google/protobuf/internal/*.proto",
769 "python/google/protobuf/internal/import_test_package/*.proto",
770 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700771 include = "python",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800772 default_runtime = ":protobuf_python",
Jisi Liu04658a32015-10-20 15:00:13 -0700773 protoc = ":protoc",
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700774 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700775 deps = [":python_common_test_protos"],
776)
777
778py_library(
779 name = "python_tests",
David Z. Chen985c9682016-02-11 18:11:10 -0800780 srcs = glob(
781 [
782 "python/google/protobuf/internal/*_test.py",
783 "python/google/protobuf/internal/test_util.py",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700784 "python/google/protobuf/internal/import_test_package/__init__.py",
David Z. Chen985c9682016-02-11 18:11:10 -0800785 ],
786 ),
787 imports = ["python"],
Geoffrey Irving29799232015-12-03 13:11:19 -0800788 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700789 deps = [
Jisi Liu166e9bb2015-10-21 10:56:38 -0700790 ":protobuf_python",
Jisi Liu598480d2015-10-21 11:19:16 -0700791 ":python_common_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700792 ":python_specific_test_protos",
793 ],
794)
795
796internal_protobuf_py_tests(
Jisi Liu8f540262015-10-20 16:21:41 -0700797 name = "python_tests_batch",
Jisi Liu68e13f42015-10-22 11:13:14 -0700798 data = glob([
799 "src/google/protobuf/**/*",
800 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700801 modules = [
802 "descriptor_database_test",
803 "descriptor_pool_test",
804 "descriptor_test",
805 "generator_test",
806 "json_format_test",
807 "message_factory_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700808 "message_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700809 "proto_builder_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700810 "reflection_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700811 "service_reflection_test",
812 "symbol_database_test",
813 "text_encoding_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700814 "text_format_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700815 "unknown_fields_test",
816 "wire_format_test",
817 ],
818 deps = [":python_tests"],
819)
cgrushko45d92ae2016-12-02 19:40:50 -0500820
821proto_lang_toolchain(
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800822 name = "cc_toolchain",
823 command_line = "--cpp_out=$(OUT)",
824 runtime = ":protobuf",
825 visibility = ["//visibility:public"],
John Millikin350b1352018-02-24 11:36:49 -0800826 blacklisted_protos = [":_internal_wkt_protos_genrule"],
cgrushko45d92ae2016-12-02 19:40:50 -0500827)
cgrushkoe4baf3f2017-01-12 12:51:04 -0500828
829proto_lang_toolchain(
830 name = "java_toolchain",
831 command_line = "--java_out=$(OUT)",
832 runtime = ":protobuf_java",
833 visibility = ["//visibility:public"],
834)
makdharma286f0592017-05-01 09:49:26 -0700835
836OBJC_HDRS = [
837 "objectivec/GPBArray.h",
838 "objectivec/GPBBootstrap.h",
839 "objectivec/GPBCodedInputStream.h",
840 "objectivec/GPBCodedOutputStream.h",
841 "objectivec/GPBDescriptor.h",
842 "objectivec/GPBDictionary.h",
843 "objectivec/GPBExtensionInternals.h",
844 "objectivec/GPBExtensionRegistry.h",
845 "objectivec/GPBMessage.h",
846 "objectivec/GPBProtocolBuffers.h",
847 "objectivec/GPBProtocolBuffers_RuntimeSupport.h",
848 "objectivec/GPBRootObject.h",
849 "objectivec/GPBRuntimeTypes.h",
850 "objectivec/GPBUnknownField.h",
851 "objectivec/GPBUnknownFieldSet.h",
852 "objectivec/GPBUtilities.h",
853 "objectivec/GPBWellKnownTypes.h",
854 "objectivec/GPBWireFormat.h",
855 "objectivec/google/protobuf/Any.pbobjc.h",
856 "objectivec/google/protobuf/Api.pbobjc.h",
857 "objectivec/google/protobuf/Duration.pbobjc.h",
858 "objectivec/google/protobuf/Empty.pbobjc.h",
859 "objectivec/google/protobuf/FieldMask.pbobjc.h",
860 "objectivec/google/protobuf/SourceContext.pbobjc.h",
861 "objectivec/google/protobuf/Struct.pbobjc.h",
862 "objectivec/google/protobuf/Timestamp.pbobjc.h",
863 "objectivec/google/protobuf/Type.pbobjc.h",
864 "objectivec/google/protobuf/Wrappers.pbobjc.h",
865]
866
867OBJC_PRIVATE_HDRS = [
868 "objectivec/GPBArray_PackagePrivate.h",
869 "objectivec/GPBCodedInputStream_PackagePrivate.h",
870 "objectivec/GPBCodedOutputStream_PackagePrivate.h",
871 "objectivec/GPBDescriptor_PackagePrivate.h",
872 "objectivec/GPBDictionary_PackagePrivate.h",
873 "objectivec/GPBMessage_PackagePrivate.h",
874 "objectivec/GPBRootObject_PackagePrivate.h",
875 "objectivec/GPBUnknownFieldSet_PackagePrivate.h",
876 "objectivec/GPBUnknownField_PackagePrivate.h",
877 "objectivec/GPBUtilities_PackagePrivate.h",
878]
879
880OBJC_SRCS = [
881 "objectivec/GPBArray.m",
882 "objectivec/GPBCodedInputStream.m",
883 "objectivec/GPBCodedOutputStream.m",
884 "objectivec/GPBDescriptor.m",
885 "objectivec/GPBDictionary.m",
886 "objectivec/GPBExtensionInternals.m",
887 "objectivec/GPBExtensionRegistry.m",
888 "objectivec/GPBMessage.m",
889 "objectivec/GPBRootObject.m",
890 "objectivec/GPBUnknownField.m",
891 "objectivec/GPBUnknownFieldSet.m",
892 "objectivec/GPBUtilities.m",
893 "objectivec/GPBWellKnownTypes.m",
894 "objectivec/GPBWireFormat.m",
895 "objectivec/google/protobuf/Any.pbobjc.m",
896 "objectivec/google/protobuf/Api.pbobjc.m",
897 "objectivec/google/protobuf/Duration.pbobjc.m",
898 "objectivec/google/protobuf/Empty.pbobjc.m",
899 "objectivec/google/protobuf/FieldMask.pbobjc.m",
900 "objectivec/google/protobuf/SourceContext.pbobjc.m",
901 "objectivec/google/protobuf/Struct.pbobjc.m",
902 "objectivec/google/protobuf/Timestamp.pbobjc.m",
903 "objectivec/google/protobuf/Type.pbobjc.m",
904 "objectivec/google/protobuf/Wrappers.pbobjc.m",
905]
906
907objc_library(
908 name = "objectivec",
909 hdrs = OBJC_HDRS + OBJC_PRIVATE_HDRS,
910 includes = [
911 "objectivec",
912 ],
913 non_arc_srcs = OBJC_SRCS,
914 visibility = ["//visibility:public"],
915)