blob: 6c6258321e876a00897c2e51dabda2c4ea9f8d56 [file] [log] [blame]
Laszlo Csomor55171682017-12-01 12:05:32 +01001# Bazel (https://bazel.build/) BUILD file for Protobuf.
Jisi Liud19604f2015-06-17 17:37:58 -07002
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": [],
Laszlo Csomor55171682017-12-01 12:05:32 +010058 # Linking to setargv.obj makes the default command line argument
59 # parser expand wildcards, so the main method's argv will contain the
60 # expanded list instead of the wildcards.
61 # Using -WHOLEARCHIVE, because:
62 # - Microsoft ships this object file next to default libraries
63 # - but this file is not a library, just a precompiled object
64 # - just listing the name here without "-WHOLEARCHIVE:" would make Bazel
65 # believe that "setargv.obj" is a source or rule output in this
66 # package, which it is not.
67 # See https://msdn.microsoft.com/en-us/library/8bch7bkk.aspx
68 "-WHOLEARCHIVE:setargv.obj",
69 ],
Daniel Ylitalo32fa55e2017-01-25 22:04:11 +010070 "//conditions:default": ["-lpthread", "-lm"],
Andrew Harpb56b4612016-04-04 15:13:30 -040071})
Jisi Liud19604f2015-06-17 17:37:58 -070072
Jisi Liu04658a32015-10-20 15:00:13 -070073load(
cgrushko65a4d202017-02-08 15:23:57 -050074 ":protobuf.bzl",
Jisi Liu04658a32015-10-20 15:00:13 -070075 "cc_proto_library",
76 "py_proto_library",
David Z. Chen02cd45c2016-05-20 16:49:04 -070077 "internal_copied_filegroup",
Steven Parkesea188662016-02-25 07:53:19 -080078 "internal_gen_well_known_protos_java",
Jisi Liu04658a32015-10-20 15:00:13 -070079 "internal_protobuf_py_tests",
80)
Jisi Liu39362b32015-10-14 17:12:11 -070081
Jisi Liud19604f2015-06-17 17:37:58 -070082cc_library(
83 name = "protobuf_lite",
84 srcs = [
85 # AUTOGEN(protobuf_lite_srcs)
86 "src/google/protobuf/arena.cc",
87 "src/google/protobuf/arenastring.cc",
88 "src/google/protobuf/extension_set.cc",
Jisi Liu12c186f2017-07-25 14:38:00 -070089 "src/google/protobuf/generated_message_table_driven_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070090 "src/google/protobuf/generated_message_util.cc",
Adam Cozzette609d7522017-12-07 14:16:50 -080091 "src/google/protobuf/implicit_weak_message.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070092 "src/google/protobuf/io/coded_stream.cc",
93 "src/google/protobuf/io/zero_copy_stream.cc",
94 "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
95 "src/google/protobuf/message_lite.cc",
96 "src/google/protobuf/repeated_field.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -070097 "src/google/protobuf/stubs/bytestream.cc",
Jisi Liud19604f2015-06-17 17:37:58 -070098 "src/google/protobuf/stubs/common.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -070099 "src/google/protobuf/stubs/int128.cc",
Jisi Liu759245a2017-07-25 11:52:33 -0700100 "src/google/protobuf/stubs/io_win32.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700101 "src/google/protobuf/stubs/status.cc",
102 "src/google/protobuf/stubs/statusor.cc",
103 "src/google/protobuf/stubs/stringpiece.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700104 "src/google/protobuf/stubs/stringprintf.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700105 "src/google/protobuf/stubs/structurally_valid.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700106 "src/google/protobuf/stubs/strutil.cc",
107 "src/google/protobuf/stubs/time.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700108 "src/google/protobuf/wire_format_lite.cc",
109 ],
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800110 hdrs = glob(["src/google/protobuf/**/*.h"]),
Param Reddy16792c62017-10-15 13:06:58 -0700111 copts = COPTS,
Jisi Liud19604f2015-06-17 17:37:58 -0700112 includes = ["src/"],
113 linkopts = LINK_OPTS,
114 visibility = ["//visibility:public"],
115)
116
117cc_library(
118 name = "protobuf",
119 srcs = [
120 # AUTOGEN(protobuf_srcs)
121 "src/google/protobuf/any.cc",
122 "src/google/protobuf/any.pb.cc",
123 "src/google/protobuf/api.pb.cc",
124 "src/google/protobuf/compiler/importer.cc",
125 "src/google/protobuf/compiler/parser.cc",
126 "src/google/protobuf/descriptor.cc",
127 "src/google/protobuf/descriptor.pb.cc",
128 "src/google/protobuf/descriptor_database.cc",
129 "src/google/protobuf/duration.pb.cc",
130 "src/google/protobuf/dynamic_message.cc",
131 "src/google/protobuf/empty.pb.cc",
132 "src/google/protobuf/extension_set_heavy.cc",
133 "src/google/protobuf/field_mask.pb.cc",
134 "src/google/protobuf/generated_message_reflection.cc",
Jisi Liu759245a2017-07-25 11:52:33 -0700135 "src/google/protobuf/generated_message_table_driven.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700136 "src/google/protobuf/io/gzip_stream.cc",
137 "src/google/protobuf/io/printer.cc",
138 "src/google/protobuf/io/strtod.cc",
139 "src/google/protobuf/io/tokenizer.cc",
140 "src/google/protobuf/io/zero_copy_stream_impl.cc",
141 "src/google/protobuf/map_field.cc",
142 "src/google/protobuf/message.cc",
143 "src/google/protobuf/reflection_ops.cc",
144 "src/google/protobuf/service.cc",
145 "src/google/protobuf/source_context.pb.cc",
146 "src/google/protobuf/struct.pb.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700147 "src/google/protobuf/stubs/mathlimits.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700148 "src/google/protobuf/stubs/substitute.cc",
149 "src/google/protobuf/text_format.cc",
150 "src/google/protobuf/timestamp.pb.cc",
151 "src/google/protobuf/type.pb.cc",
152 "src/google/protobuf/unknown_field_set.cc",
Bairen Yi312e2db2017-03-21 03:52:37 +0800153 "src/google/protobuf/util/delimited_message_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700154 "src/google/protobuf/util/field_comparator.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700155 "src/google/protobuf/util/field_mask_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700156 "src/google/protobuf/util/internal/datapiece.cc",
157 "src/google/protobuf/util/internal/default_value_objectwriter.cc",
158 "src/google/protobuf/util/internal/error_listener.cc",
159 "src/google/protobuf/util/internal/field_mask_utility.cc",
160 "src/google/protobuf/util/internal/json_escaping.cc",
161 "src/google/protobuf/util/internal/json_objectwriter.cc",
162 "src/google/protobuf/util/internal/json_stream_parser.cc",
163 "src/google/protobuf/util/internal/object_writer.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800164 "src/google/protobuf/util/internal/proto_writer.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700165 "src/google/protobuf/util/internal/protostream_objectsource.cc",
166 "src/google/protobuf/util/internal/protostream_objectwriter.cc",
167 "src/google/protobuf/util/internal/type_info.cc",
168 "src/google/protobuf/util/internal/type_info_test_helper.cc",
169 "src/google/protobuf/util/internal/utility.cc",
170 "src/google/protobuf/util/json_util.cc",
171 "src/google/protobuf/util/message_differencer.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700172 "src/google/protobuf/util/time_util.cc",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700173 "src/google/protobuf/util/type_resolver_util.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700174 "src/google/protobuf/wire_format.cc",
175 "src/google/protobuf/wrappers.pb.cc",
176 ],
Lukacs T. Berki915d9cd2015-11-16 09:36:32 +0100177 hdrs = glob(["src/**/*.h"]),
Param Reddy16792c62017-10-15 13:06:58 -0700178 copts = COPTS,
Jisi Liud19604f2015-06-17 17:37:58 -0700179 includes = ["src/"],
180 linkopts = LINK_OPTS,
181 visibility = ["//visibility:public"],
182 deps = [":protobuf_lite"],
183)
184
Manjunath Kudlur6837b2d2017-03-02 18:02:05 -0800185# This provides just the header files for use in projects that need to build
186# shared libraries for dynamic loading. This target is available until Bazel
187# adds native support for such use cases.
188# TODO(keveman): Remove this target once the support gets added to Bazel.
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800189cc_library(
190 name = "protobuf_headers",
191 hdrs = glob(["src/**/*.h"]),
192 includes = ["src/"],
193 visibility = ["//visibility:public"],
194)
195
Jisi Liu14c8f8a2015-10-20 15:36:22 -0700196objc_library(
197 name = "protobuf_objc",
198 hdrs = ["objectivec/GPBProtocolBuffers.h"],
199 includes = ["objectivec"],
200 non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
201 visibility = ["//visibility:public"],
202)
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700203
Jakob Buchgraber699c0eb2017-09-05 17:15:10 +0200204# Map of all well known protos.
205# name => (include path, imports)
206WELL_KNOWN_PROTO_MAP = {
207 "any" : ("google/protobuf/any.proto", []),
208 "api" : ("google/protobuf/api.proto", ["source_context", "type"]),
209 "compiler_plugin" : ("google/protobuf/compiler/plugin.proto", ["descriptor"]),
210 "descriptor" : ("google/protobuf/descriptor.proto", []),
211 "duration" : ("google/protobuf/duration.proto", []),
212 "empty" : ("google/protobuf/empty.proto", []),
213 "field_mask" : ("google/protobuf/field_mask.proto", []),
214 "source_context" : ("google/protobuf/source_context.proto", []),
215 "struct" : ("google/protobuf/struct.proto", []),
216 "timestamp" : ("google/protobuf/timestamp.proto", []),
217 "type" : ("google/protobuf/type.proto", ["any", "source_context"]),
218 "wrappers" : ("google/protobuf/wrappers.proto", []),
219}
220
221RELATIVE_WELL_KNOWN_PROTOS = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()]
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700222
Jisi Liu993fb702015-10-19 17:19:49 -0700223WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
224
Steven Parkesd5a57322016-03-22 17:56:07 -0700225filegroup(
226 name = "well_known_protos",
227 srcs = WELL_KNOWN_PROTOS,
228 visibility = ["//visibility:public"],
229)
230
Jisi Liu39362b32015-10-14 17:12:11 -0700231cc_proto_library(
232 name = "cc_wkt_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700233 srcs = WELL_KNOWN_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700234 include = "src",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800235 default_runtime = ":protobuf",
Jisi Liu993fb702015-10-19 17:19:49 -0700236 internal_bootstrap_hack = 1,
Jisi Liu04658a32015-10-20 15:00:13 -0700237 protoc = ":protoc",
Jisi Liu6a40bf82015-11-17 12:36:21 -0800238 visibility = ["//visibility:public"],
Jisi Liu39362b32015-10-14 17:12:11 -0700239)
240
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700241################################################################################
Jakob Buchgraber699c0eb2017-09-05 17:15:10 +0200242# Well Known Types Proto Library Rules
243#
244# These proto_library rules can be used with one of the language specific proto
245# library rules i.e. java_proto_library:
246#
247# java_proto_library(
248# name = "any_java_proto",
249# deps = ["@com_google_protobuf//:any_proto],
250# )
251################################################################################
252
253internal_copied_filegroup(
254 name = "_internal_wkt_protos",
255 srcs = WELL_KNOWN_PROTOS,
256 dest = "",
257 strip_prefix = "src",
James O'Kane950f5e42018-03-08 22:30:44 -0800258 visibility = ["//visibility:private"],
Jakob Buchgraber699c0eb2017-09-05 17:15:10 +0200259)
260
261[proto_library(
262 name = proto[0] + "_proto",
263 srcs = [proto[1][0]],
264 deps = [dep + "_proto" for dep in proto[1][1]],
265 visibility = ["//visibility:public"],
266 ) for proto in WELL_KNOWN_PROTO_MAP.items()]
267
268################################################################################
Jorge Canizalesd5d7bb32015-06-28 15:23:02 -0700269# Protocol Buffers Compiler
270################################################################################
271
Adam Cozzetted1e7bd92016-12-20 09:08:19 -0800272cc_binary(
273 name = "js_embed",
274 srcs = ["src/google/protobuf/compiler/js/embed.cc"],
275 visibility = ["//visibility:public"],
276)
277
278genrule(
279 name = "generate_js_well_known_types_embed",
280 srcs = [
281 "src/google/protobuf/compiler/js/well_known_types/any.js",
282 "src/google/protobuf/compiler/js/well_known_types/struct.js",
283 "src/google/protobuf/compiler/js/well_known_types/timestamp.js",
284 ],
285 outs = ["src/google/protobuf/compiler/js/well_known_types_embed.cc"],
286 cmd = "$(location :js_embed) $(SRCS) > $@",
287 tools = [":js_embed"],
288)
289
Jisi Liud19604f2015-06-17 17:37:58 -0700290cc_library(
291 name = "protoc_lib",
292 srcs = [
293 # AUTOGEN(protoc_lib_srcs)
294 "src/google/protobuf/compiler/code_generator.cc",
295 "src/google/protobuf/compiler/command_line_interface.cc",
296 "src/google/protobuf/compiler/cpp/cpp_enum.cc",
297 "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
298 "src/google/protobuf/compiler/cpp/cpp_extension.cc",
299 "src/google/protobuf/compiler/cpp/cpp_field.cc",
300 "src/google/protobuf/compiler/cpp/cpp_file.cc",
301 "src/google/protobuf/compiler/cpp/cpp_generator.cc",
302 "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
303 "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
304 "src/google/protobuf/compiler/cpp/cpp_message.cc",
305 "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
Adam Cozzette13fd0452017-09-12 10:32:01 -0700306 "src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700307 "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
308 "src/google/protobuf/compiler/cpp/cpp_service.cc",
309 "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
Ming Zhao5cdd9362015-10-05 14:37:21 -0700310 "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700311 "src/google/protobuf/compiler/csharp/csharp_enum.cc",
312 "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700313 "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
314 "src/google/protobuf/compiler/csharp/csharp_generator.cc",
315 "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100316 "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700317 "src/google/protobuf/compiler/csharp/csharp_message.cc",
318 "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
319 "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
Jon Skeeta6361a12015-11-19 13:05:17 +0000320 "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700321 "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
322 "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
323 "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
324 "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
Jon Skeetb2ac8682015-07-15 13:17:42 +0100325 "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700326 "src/google/protobuf/compiler/java/java_context.cc",
327 "src/google/protobuf/compiler/java/java_doc_comment.cc",
328 "src/google/protobuf/compiler/java/java_enum.cc",
329 "src/google/protobuf/compiler/java/java_enum_field.cc",
330 "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700331 "src/google/protobuf/compiler/java/java_enum_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700332 "src/google/protobuf/compiler/java/java_extension.cc",
Jisi Liu1f4f3e22016-04-18 14:12:08 -0700333 "src/google/protobuf/compiler/java/java_extension_lite.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700334 "src/google/protobuf/compiler/java/java_field.cc",
335 "src/google/protobuf/compiler/java/java_file.cc",
336 "src/google/protobuf/compiler/java/java_generator.cc",
337 "src/google/protobuf/compiler/java/java_generator_factory.cc",
338 "src/google/protobuf/compiler/java/java_helpers.cc",
339 "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
340 "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
341 "src/google/protobuf/compiler/java/java_map_field.cc",
342 "src/google/protobuf/compiler/java/java_map_field_lite.cc",
343 "src/google/protobuf/compiler/java/java_message.cc",
344 "src/google/protobuf/compiler/java/java_message_builder.cc",
345 "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
346 "src/google/protobuf/compiler/java/java_message_field.cc",
347 "src/google/protobuf/compiler/java/java_message_field_lite.cc",
348 "src/google/protobuf/compiler/java/java_message_lite.cc",
349 "src/google/protobuf/compiler/java/java_name_resolver.cc",
350 "src/google/protobuf/compiler/java/java_primitive_field.cc",
351 "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
352 "src/google/protobuf/compiler/java/java_service.cc",
353 "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
354 "src/google/protobuf/compiler/java/java_string_field.cc",
355 "src/google/protobuf/compiler/java/java_string_field_lite.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800356 "src/google/protobuf/compiler/js/js_generator.cc",
Jisi Liuf92b4552016-12-05 10:16:47 -0800357 "src/google/protobuf/compiler/js/well_known_types_embed.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700358 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
359 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
360 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
361 "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
362 "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
363 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
364 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
365 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
366 "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
367 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
368 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
369 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
Jisi Liud9473082016-09-22 15:14:58 -0700370 "src/google/protobuf/compiler/php/php_generator.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700371 "src/google/protobuf/compiler/plugin.cc",
Feng Xiaofd595fc2018-03-01 16:36:05 -0800372 "src/google/protobuf/compiler/plugin.pb.cc",
Jisi Liud19604f2015-06-17 17:37:58 -0700373 "src/google/protobuf/compiler/python/python_generator.cc",
374 "src/google/protobuf/compiler/ruby/ruby_generator.cc",
375 "src/google/protobuf/compiler/subprocess.cc",
376 "src/google/protobuf/compiler/zip_writer.cc",
377 ],
378 copts = COPTS,
379 includes = ["src/"],
380 linkopts = LINK_OPTS,
381 visibility = ["//visibility:public"],
382 deps = [":protobuf"],
383)
384
385cc_binary(
386 name = "protoc",
387 srcs = ["src/google/protobuf/compiler/main.cc"],
Jisi Liud19604f2015-06-17 17:37:58 -0700388 linkopts = LINK_OPTS,
389 visibility = ["//visibility:public"],
390 deps = [":protoc_lib"],
391)
392
Jisi Liud19604f2015-06-17 17:37:58 -0700393################################################################################
394# Tests
395################################################################################
396
Jisi Liu993fb702015-10-19 17:19:49 -0700397RELATIVE_LITE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700398 # AUTOGEN(lite_test_protos)
399 "google/protobuf/map_lite_unittest.proto",
400 "google/protobuf/unittest_import_lite.proto",
401 "google/protobuf/unittest_import_public_lite.proto",
402 "google/protobuf/unittest_lite.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700403 "google/protobuf/unittest_no_arena_lite.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700404]
405
Jisi Liu993fb702015-10-19 17:19:49 -0700406LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
407
408RELATIVE_TEST_PROTOS = [
Jisi Liud19604f2015-06-17 17:37:58 -0700409 # AUTOGEN(test_protos)
410 "google/protobuf/any_test.proto",
411 "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
412 "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
413 "google/protobuf/map_proto2_unittest.proto",
414 "google/protobuf/map_unittest.proto",
415 "google/protobuf/unittest.proto",
416 "google/protobuf/unittest_arena.proto",
417 "google/protobuf/unittest_custom_options.proto",
418 "google/protobuf/unittest_drop_unknown_fields.proto",
419 "google/protobuf/unittest_embed_optimize_for.proto",
420 "google/protobuf/unittest_empty.proto",
421 "google/protobuf/unittest_enormous_descriptor.proto",
422 "google/protobuf/unittest_import.proto",
423 "google/protobuf/unittest_import_public.proto",
Feng Xiao32d78302017-03-29 14:01:40 -0700424 "google/protobuf/unittest_lazy_dependencies.proto",
425 "google/protobuf/unittest_lazy_dependencies_custom_option.proto",
426 "google/protobuf/unittest_lazy_dependencies_enum.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700427 "google/protobuf/unittest_lite_imports_nonlite.proto",
428 "google/protobuf/unittest_mset.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700429 "google/protobuf/unittest_mset_wire_format.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700430 "google/protobuf/unittest_no_arena.proto",
431 "google/protobuf/unittest_no_arena_import.proto",
432 "google/protobuf/unittest_no_field_presence.proto",
433 "google/protobuf/unittest_no_generic_services.proto",
434 "google/protobuf/unittest_optimize_for.proto",
435 "google/protobuf/unittest_preserve_unknown_enum.proto",
436 "google/protobuf/unittest_preserve_unknown_enum2.proto",
437 "google/protobuf/unittest_proto3_arena.proto",
Chad Whipkeybaf52bd2016-04-15 09:23:50 -0700438 "google/protobuf/unittest_proto3_arena_lite.proto",
439 "google/protobuf/unittest_proto3_lite.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700440 "google/protobuf/unittest_well_known_types.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700441 "google/protobuf/util/internal/testdata/anys.proto",
442 "google/protobuf/util/internal/testdata/books.proto",
443 "google/protobuf/util/internal/testdata/default_value.proto",
444 "google/protobuf/util/internal/testdata/default_value_test.proto",
445 "google/protobuf/util/internal/testdata/field_mask.proto",
446 "google/protobuf/util/internal/testdata/maps.proto",
Jisi Liub90f9f82015-08-25 17:06:33 -0700447 "google/protobuf/util/internal/testdata/oneofs.proto",
Jisi Liu9d4657a2016-09-22 15:11:17 -0700448 "google/protobuf/util/internal/testdata/proto3.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700449 "google/protobuf/util/internal/testdata/struct.proto",
450 "google/protobuf/util/internal/testdata/timestamp_duration.proto",
Jisi Liu9d4657a2016-09-22 15:11:17 -0700451 "google/protobuf/util/internal/testdata/wrappers.proto",
Jisi Liuaf3eafd2015-06-18 13:38:36 -0700452 "google/protobuf/util/json_format_proto3.proto",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800453 "google/protobuf/util/message_differencer_unittest.proto",
Jisi Liud19604f2015-06-17 17:37:58 -0700454]
455
Jisi Liu993fb702015-10-19 17:19:49 -0700456TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
457
Jisi Liu39362b32015-10-14 17:12:11 -0700458cc_proto_library(
459 name = "cc_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700460 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
Jisi Liu3101e732015-10-16 12:46:26 -0700461 include = "src",
Jisi Liube92ffb2015-10-27 15:11:38 -0700462 default_runtime = ":protobuf",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800463 protoc = ":protoc",
Jisi Liud8701b52015-10-16 11:44:21 -0700464 deps = [":cc_wkt_protos"],
Jisi Liud19604f2015-06-17 17:37:58 -0700465)
466
467COMMON_TEST_SRCS = [
468 # AUTOGEN(common_test_srcs)
469 "src/google/protobuf/arena_test_util.cc",
470 "src/google/protobuf/map_test_util.cc",
471 "src/google/protobuf/test_util.cc",
Adam Cozzette5bed3682018-03-23 10:19:04 -0700472 "src/google/protobuf/test_util.inc",
Jisi Liud19604f2015-06-17 17:37:58 -0700473 "src/google/protobuf/testing/file.cc",
474 "src/google/protobuf/testing/googletest.cc",
475]
476
Jisi Liu7a0c4312015-06-18 16:45:27 -0700477cc_binary(
478 name = "test_plugin",
479 srcs = [
480 # AUTOGEN(test_plugin_srcs)
481 "src/google/protobuf/compiler/mock_code_generator.cc",
482 "src/google/protobuf/compiler/test_plugin.cc",
483 "src/google/protobuf/testing/file.cc",
484 ],
485 deps = [
486 ":protobuf",
487 ":protoc_lib",
488 "//external:gtest",
489 ],
490)
491
492cc_test(
Jisi Liu759245a2017-07-25 11:52:33 -0700493 name = "win32_test",
494 srcs = ["src/google/protobuf/stubs/io_win32_unittest.cc"],
495 deps = [
496 ":protobuf_lite",
497 "//external:gtest_main",
498 ],
499 tags = ["manual", "windows"],
500)
501
502cc_test(
Jisi Liu7a0c4312015-06-18 16:45:27 -0700503 name = "protobuf_test",
Jisi Liu39362b32015-10-14 17:12:11 -0700504 srcs = COMMON_TEST_SRCS + [
Jisi Liu7a0c4312015-06-18 16:45:27 -0700505 # AUTOGEN(test_srcs)
506 "src/google/protobuf/any_test.cc",
507 "src/google/protobuf/arena_unittest.cc",
508 "src/google/protobuf/arenastring_unittest.cc",
Jisi Liu1c682e02017-10-18 14:31:23 -0700509 "src/google/protobuf/compiler/annotation_test_util.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700510 "src/google/protobuf/compiler/command_line_interface_unittest.cc",
511 "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
Jisi Liu11b66612017-07-19 12:10:43 -0700512 "src/google/protobuf/compiler/cpp/cpp_move_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700513 "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
514 "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
Adam Cozzette5bed3682018-03-23 10:19:04 -0700515 "src/google/protobuf/compiler/cpp/cpp_unittest.inc",
Jisi Liu1f4f3e22016-04-18 14:12:08 -0700516 "src/google/protobuf/compiler/cpp/metadata_test.cc",
Feng Xiao32d78302017-03-29 14:01:40 -0700517 "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700518 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
519 "src/google/protobuf/compiler/importer_unittest.cc",
520 "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
521 "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
522 "src/google/protobuf/compiler/mock_code_generator.cc",
523 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
524 "src/google/protobuf/compiler/parser_unittest.cc",
525 "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
526 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
527 "src/google/protobuf/descriptor_database_unittest.cc",
528 "src/google/protobuf/descriptor_unittest.cc",
529 "src/google/protobuf/drop_unknown_fields_test.cc",
530 "src/google/protobuf/dynamic_message_unittest.cc",
531 "src/google/protobuf/extension_set_unittest.cc",
532 "src/google/protobuf/generated_message_reflection_unittest.cc",
533 "src/google/protobuf/io/coded_stream_unittest.cc",
534 "src/google/protobuf/io/printer_unittest.cc",
535 "src/google/protobuf/io/tokenizer_unittest.cc",
536 "src/google/protobuf/io/zero_copy_stream_unittest.cc",
537 "src/google/protobuf/map_field_test.cc",
538 "src/google/protobuf/map_test.cc",
539 "src/google/protobuf/message_unittest.cc",
Adam Cozzette5bed3682018-03-23 10:19:04 -0700540 "src/google/protobuf/message_unittest.inc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700541 "src/google/protobuf/no_field_presence_test.cc",
542 "src/google/protobuf/preserve_unknown_enum_test.cc",
Chad Whipkeybaf52bd2016-04-15 09:23:50 -0700543 "src/google/protobuf/proto3_arena_lite_unittest.cc",
Jisi Liuf86d39c2016-04-28 14:43:22 -0700544 "src/google/protobuf/proto3_arena_unittest.cc",
Chad Whipkeybaf52bd2016-04-15 09:23:50 -0700545 "src/google/protobuf/proto3_lite_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700546 "src/google/protobuf/reflection_ops_unittest.cc",
547 "src/google/protobuf/repeated_field_reflection_unittest.cc",
548 "src/google/protobuf/repeated_field_unittest.cc",
549 "src/google/protobuf/stubs/bytestream_unittest.cc",
550 "src/google/protobuf/stubs/common_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700551 "src/google/protobuf/stubs/int128_unittest.cc",
Jisi Liu759245a2017-07-25 11:52:33 -0700552 "src/google/protobuf/stubs/io_win32_unittest.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700553 "src/google/protobuf/stubs/status_test.cc",
554 "src/google/protobuf/stubs/statusor_test.cc",
555 "src/google/protobuf/stubs/stringpiece_unittest.cc",
556 "src/google/protobuf/stubs/stringprintf_unittest.cc",
557 "src/google/protobuf/stubs/structurally_valid_unittest.cc",
558 "src/google/protobuf/stubs/strutil_unittest.cc",
559 "src/google/protobuf/stubs/template_util_unittest.cc",
560 "src/google/protobuf/stubs/time_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700561 "src/google/protobuf/text_format_unittest.cc",
562 "src/google/protobuf/unknown_field_set_unittest.cc",
Byron Yicb3e84b2017-03-16 20:01:22 +0800563 "src/google/protobuf/util/delimited_message_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700564 "src/google/protobuf/util/field_comparator_test.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700565 "src/google/protobuf/util/field_mask_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700566 "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
567 "src/google/protobuf/util/internal/json_objectwriter_test.cc",
568 "src/google/protobuf/util/internal/json_stream_parser_test.cc",
569 "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
570 "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
571 "src/google/protobuf/util/internal/type_info_test_helper.cc",
572 "src/google/protobuf/util/json_util_test.cc",
Feng Xiaoef6c72b2015-12-28 17:33:55 -0800573 "src/google/protobuf/util/message_differencer_unittest.cc",
Jisi Liub90f9f82015-08-25 17:06:33 -0700574 "src/google/protobuf/util/time_util_test.cc",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700575 "src/google/protobuf/util/type_resolver_util_test.cc",
576 "src/google/protobuf/well_known_types_unittest.cc",
577 "src/google/protobuf/wire_format_unittest.cc",
578 ],
579 copts = COPTS,
580 data = [
581 ":test_plugin",
Jisi Liu598480d2015-10-21 11:19:16 -0700582 ] + glob([
583 "src/google/protobuf/**/*",
Feng Xiaoacde1652017-03-29 15:14:18 -0700584 # Files for csharp_bootstrap_unittest.cc.
585 "conformance/**/*",
586 "csharp/src/**/*",
Jisi Liu598480d2015-10-21 11:19:16 -0700587 ]),
Jisi Liu7a0c4312015-06-18 16:45:27 -0700588 includes = [
589 "src/",
590 ],
591 linkopts = LINK_OPTS,
592 deps = [
Jisi Liu993fb702015-10-19 17:19:49 -0700593 ":cc_test_protos",
Jisi Liu7a0c4312015-06-18 16:45:27 -0700594 ":protobuf",
595 ":protoc_lib",
596 "//external:gtest_main",
597 ],
598)
Jisi Liu993fb702015-10-19 17:19:49 -0700599
600################################################################################
601# Java support
602################################################################################
Steven Parkesea188662016-02-25 07:53:19 -0800603internal_gen_well_known_protos_java(
Ming Zhao4fe03812016-01-21 23:03:28 -0800604 srcs = WELL_KNOWN_PROTOS,
Jisi Liu993fb702015-10-19 17:19:49 -0700605)
606
607java_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700608 name = "protobuf_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700609 srcs = glob([
Ming Zhao4fe03812016-01-21 23:03:28 -0800610 "java/core/src/main/java/com/google/protobuf/*.java",
Jisi Liu993fb702015-10-19 17:19:49 -0700611 ]) + [
Ming Zhao4fe03812016-01-21 23:03:28 -0800612 ":gen_well_known_protos_java",
Jisi Liu993fb702015-10-19 17:19:49 -0700613 ],
David Ostrovsky85b488f2018-01-31 09:01:27 +0100614 javacopts = select({
615 "//:jdk9": ["--add-modules=jdk.unsupported"],
616 "//conditions:default": ["-source 7", "-target 7"],
617 }),
Jisi Liu993fb702015-10-19 17:19:49 -0700618 visibility = ["//visibility:public"],
619)
620
Steven Parkesa9244ca2016-03-10 17:50:25 -0800621java_library(
622 name = "protobuf_java_util",
623 srcs = glob([
624 "java/util/src/main/java/com/google/protobuf/util/*.java",
625 ]),
David Ostrovsky019ceea2018-01-25 06:05:14 +0100626 javacopts = ["-source 7", "-target 7"],
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800627 visibility = ["//visibility:public"],
Steven Parkesa9244ca2016-03-10 17:50:25 -0800628 deps = [
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700629 "protobuf_java",
630 "//external:gson",
631 "//external:guava",
Steven Parkesa9244ca2016-03-10 17:50:25 -0800632 ],
Steven Parkesa9244ca2016-03-10 17:50:25 -0800633)
634
Jisi Liu993fb702015-10-19 17:19:49 -0700635################################################################################
636# Python support
637################################################################################
638
David Z. Chen985c9682016-02-11 18:11:10 -0800639py_library(
Jisi Liu993fb702015-10-19 17:19:49 -0700640 name = "python_srcs",
641 srcs = glob(
642 [
643 "python/google/protobuf/*.py",
644 "python/google/protobuf/**/*.py",
645 ],
646 exclude = [
David Z. Chen02cd45c2016-05-20 16:49:04 -0700647 "python/google/protobuf/__init__.py",
648 "python/google/protobuf/**/__init__.py",
Jisi Liu993fb702015-10-19 17:19:49 -0700649 "python/google/protobuf/internal/*_test.py",
650 "python/google/protobuf/internal/test_util.py",
651 ],
652 ),
David Z. Chen985c9682016-02-11 18:11:10 -0800653 imports = ["python"],
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800654 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700655)
656
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800657cc_binary(
Richard Shindf5841f2016-10-18 13:16:44 -0700658 name = "python/google/protobuf/internal/_api_implementation.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800659 srcs = ["python/google/protobuf/internal/api_implementation.cc"],
660 copts = COPTS + [
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800661 "-DPYTHON_PROTO2_CPP_IMPL_V2",
662 ],
663 linkshared = 1,
664 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800665 deps = select({
666 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800667 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800668 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800669)
670
671cc_binary(
Richard Shindf5841f2016-10-18 13:16:44 -0700672 name = "python/google/protobuf/pyext/_message.so",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800673 srcs = glob([
674 "python/google/protobuf/pyext/*.cc",
675 "python/google/protobuf/pyext/*.h",
676 ]),
677 copts = COPTS + [
678 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800679 ] + select({
680 "//conditions:default": [],
681 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
682 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800683 includes = [
684 "python/",
685 "src/",
686 ],
687 linkshared = 1,
688 linkstatic = 1,
Manjunath Kudlura1949212015-12-08 08:24:37 -0800689 deps = [
690 ":protobuf",
691 ] + select({
692 "//conditions:default": [],
David Z. Chen985c9682016-02-11 18:11:10 -0800693 ":use_fast_cpp_protos": ["//external:python_headers"],
Manjunath Kudlura1949212015-12-08 08:24:37 -0800694 }),
695)
696
697config_setting(
698 name = "use_fast_cpp_protos",
699 values = {
700 "define": "use_fast_cpp_protos=true",
701 },
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800702)
703
Manjunath Kudlur99a3e302016-02-16 15:17:10 -0800704config_setting(
705 name = "allow_oversize_protos",
706 values = {
707 "define": "allow_oversize_protos=true",
708 },
709)
710
David Z. Chen02cd45c2016-05-20 16:49:04 -0700711# Copy the builtin proto files from src/google/protobuf to
712# python/google/protobuf. This way, the generated Python sources will be in the
713# same directory as the Python runtime sources. This is necessary for the
714# modules to be imported correctly since they are all part of the same Python
715# package.
716internal_copied_filegroup(
717 name = "protos_python",
718 srcs = WELL_KNOWN_PROTOS,
David Z. Chen02cd45c2016-05-20 16:49:04 -0700719 dest = "python",
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800720 strip_prefix = "src",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700721)
722
723# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
724# which case we can simply add :protos_python in srcs.
725COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
726
Jisi Liu993fb702015-10-19 17:19:49 -0700727py_proto_library(
Jisi Liu166e9bb2015-10-21 10:56:38 -0700728 name = "protobuf_python",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700729 srcs = COPIED_WELL_KNOWN_PROTOS,
730 include = "python",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800731 data = select({
732 "//conditions:default": [],
733 ":use_fast_cpp_protos": [
Richard Shindf5841f2016-10-18 13:16:44 -0700734 ":python/google/protobuf/internal/_api_implementation.so",
735 ":python/google/protobuf/pyext/_message.so",
Manjunath Kudlura1949212015-12-08 08:24:37 -0800736 ],
737 }),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800738 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700739 protoc = ":protoc",
David Z. Chen985c9682016-02-11 18:11:10 -0800740 py_libs = [
741 ":python_srcs",
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800742 "//external:six",
David Z. Chen985c9682016-02-11 18:11:10 -0800743 ],
Adam Michael6044b242017-03-10 18:06:34 -0500744 py_extra_srcs = glob(["python/**/__init__.py"]),
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800745 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700746 visibility = ["//visibility:public"],
747)
748
David Z. Chen02cd45c2016-05-20 16:49:04 -0700749# Copy the test proto files from src/google/protobuf to
750# python/google/protobuf. This way, the generated Python sources will be in the
751# same directory as the Python runtime sources. This is necessary for the
752# modules to be imported correctly by the tests since they are all part of the
753# same Python package.
754internal_copied_filegroup(
755 name = "protos_python_test",
756 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
David Z. Chen02cd45c2016-05-20 16:49:04 -0700757 dest = "python",
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800758 strip_prefix = "src",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700759)
760
761# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
762# which case we can simply add :protos_python_test in srcs.
763COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800764
David Z. Chen02cd45c2016-05-20 16:49:04 -0700765COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
766
Jisi Liu993fb702015-10-19 17:19:49 -0700767py_proto_library(
768 name = "python_common_test_protos",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700769 srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
770 include = "python",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800771 default_runtime = "",
Jisi Liu04658a32015-10-20 15:00:13 -0700772 protoc = ":protoc",
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700773 srcs_version = "PY2AND3",
Jisi Liu166e9bb2015-10-21 10:56:38 -0700774 deps = [":protobuf_python"],
Jisi Liu993fb702015-10-19 17:19:49 -0700775)
776
777py_proto_library(
778 name = "python_specific_test_protos",
Jisi Liu68e13f42015-10-22 11:13:14 -0700779 srcs = glob([
780 "python/google/protobuf/internal/*.proto",
781 "python/google/protobuf/internal/import_test_package/*.proto",
782 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700783 include = "python",
Manjunath Kudlur3ff1dca2015-12-07 13:08:21 -0800784 default_runtime = ":protobuf_python",
Jisi Liu04658a32015-10-20 15:00:13 -0700785 protoc = ":protoc",
David Z. Chen5ebeefb2016-04-08 13:30:13 -0700786 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700787 deps = [":python_common_test_protos"],
788)
789
790py_library(
791 name = "python_tests",
David Z. Chen985c9682016-02-11 18:11:10 -0800792 srcs = glob(
793 [
794 "python/google/protobuf/internal/*_test.py",
795 "python/google/protobuf/internal/test_util.py",
David Z. Chen02cd45c2016-05-20 16:49:04 -0700796 "python/google/protobuf/internal/import_test_package/__init__.py",
David Z. Chen985c9682016-02-11 18:11:10 -0800797 ],
798 ),
799 imports = ["python"],
Geoffrey Irving29799232015-12-03 13:11:19 -0800800 srcs_version = "PY2AND3",
Jisi Liu993fb702015-10-19 17:19:49 -0700801 deps = [
Jisi Liu166e9bb2015-10-21 10:56:38 -0700802 ":protobuf_python",
Jisi Liu598480d2015-10-21 11:19:16 -0700803 ":python_common_test_protos",
Jisi Liu993fb702015-10-19 17:19:49 -0700804 ":python_specific_test_protos",
805 ],
806)
807
808internal_protobuf_py_tests(
Jisi Liu8f540262015-10-20 16:21:41 -0700809 name = "python_tests_batch",
Jisi Liu68e13f42015-10-22 11:13:14 -0700810 data = glob([
811 "src/google/protobuf/**/*",
812 ]),
Jisi Liu993fb702015-10-19 17:19:49 -0700813 modules = [
814 "descriptor_database_test",
815 "descriptor_pool_test",
816 "descriptor_test",
817 "generator_test",
818 "json_format_test",
819 "message_factory_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700820 "message_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700821 "proto_builder_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700822 "reflection_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700823 "service_reflection_test",
824 "symbol_database_test",
825 "text_encoding_test",
Jisi Liu68e13f42015-10-22 11:13:14 -0700826 "text_format_test",
Jisi Liu993fb702015-10-19 17:19:49 -0700827 "unknown_fields_test",
828 "wire_format_test",
829 ],
830 deps = [":python_tests"],
831)
cgrushko45d92ae2016-12-02 19:40:50 -0500832
833proto_lang_toolchain(
Manjunath Kudlur2d430f82017-02-23 08:17:24 -0800834 name = "cc_toolchain",
835 command_line = "--cpp_out=$(OUT)",
836 runtime = ":protobuf",
837 visibility = ["//visibility:public"],
John Millikin350b1352018-02-24 11:36:49 -0800838 blacklisted_protos = [":_internal_wkt_protos_genrule"],
cgrushko45d92ae2016-12-02 19:40:50 -0500839)
cgrushkoe4baf3f2017-01-12 12:51:04 -0500840
841proto_lang_toolchain(
842 name = "java_toolchain",
843 command_line = "--java_out=$(OUT)",
844 runtime = ":protobuf_java",
845 visibility = ["//visibility:public"],
846)
makdharma286f0592017-05-01 09:49:26 -0700847
848OBJC_HDRS = [
849 "objectivec/GPBArray.h",
850 "objectivec/GPBBootstrap.h",
851 "objectivec/GPBCodedInputStream.h",
852 "objectivec/GPBCodedOutputStream.h",
853 "objectivec/GPBDescriptor.h",
854 "objectivec/GPBDictionary.h",
855 "objectivec/GPBExtensionInternals.h",
856 "objectivec/GPBExtensionRegistry.h",
857 "objectivec/GPBMessage.h",
858 "objectivec/GPBProtocolBuffers.h",
859 "objectivec/GPBProtocolBuffers_RuntimeSupport.h",
860 "objectivec/GPBRootObject.h",
861 "objectivec/GPBRuntimeTypes.h",
862 "objectivec/GPBUnknownField.h",
863 "objectivec/GPBUnknownFieldSet.h",
864 "objectivec/GPBUtilities.h",
865 "objectivec/GPBWellKnownTypes.h",
866 "objectivec/GPBWireFormat.h",
867 "objectivec/google/protobuf/Any.pbobjc.h",
868 "objectivec/google/protobuf/Api.pbobjc.h",
869 "objectivec/google/protobuf/Duration.pbobjc.h",
870 "objectivec/google/protobuf/Empty.pbobjc.h",
871 "objectivec/google/protobuf/FieldMask.pbobjc.h",
872 "objectivec/google/protobuf/SourceContext.pbobjc.h",
873 "objectivec/google/protobuf/Struct.pbobjc.h",
874 "objectivec/google/protobuf/Timestamp.pbobjc.h",
875 "objectivec/google/protobuf/Type.pbobjc.h",
876 "objectivec/google/protobuf/Wrappers.pbobjc.h",
877]
878
879OBJC_PRIVATE_HDRS = [
880 "objectivec/GPBArray_PackagePrivate.h",
881 "objectivec/GPBCodedInputStream_PackagePrivate.h",
882 "objectivec/GPBCodedOutputStream_PackagePrivate.h",
883 "objectivec/GPBDescriptor_PackagePrivate.h",
884 "objectivec/GPBDictionary_PackagePrivate.h",
885 "objectivec/GPBMessage_PackagePrivate.h",
886 "objectivec/GPBRootObject_PackagePrivate.h",
887 "objectivec/GPBUnknownFieldSet_PackagePrivate.h",
888 "objectivec/GPBUnknownField_PackagePrivate.h",
889 "objectivec/GPBUtilities_PackagePrivate.h",
890]
891
892OBJC_SRCS = [
893 "objectivec/GPBArray.m",
894 "objectivec/GPBCodedInputStream.m",
895 "objectivec/GPBCodedOutputStream.m",
896 "objectivec/GPBDescriptor.m",
897 "objectivec/GPBDictionary.m",
898 "objectivec/GPBExtensionInternals.m",
899 "objectivec/GPBExtensionRegistry.m",
900 "objectivec/GPBMessage.m",
901 "objectivec/GPBRootObject.m",
902 "objectivec/GPBUnknownField.m",
903 "objectivec/GPBUnknownFieldSet.m",
904 "objectivec/GPBUtilities.m",
905 "objectivec/GPBWellKnownTypes.m",
906 "objectivec/GPBWireFormat.m",
907 "objectivec/google/protobuf/Any.pbobjc.m",
908 "objectivec/google/protobuf/Api.pbobjc.m",
909 "objectivec/google/protobuf/Duration.pbobjc.m",
910 "objectivec/google/protobuf/Empty.pbobjc.m",
911 "objectivec/google/protobuf/FieldMask.pbobjc.m",
912 "objectivec/google/protobuf/SourceContext.pbobjc.m",
913 "objectivec/google/protobuf/Struct.pbobjc.m",
914 "objectivec/google/protobuf/Timestamp.pbobjc.m",
915 "objectivec/google/protobuf/Type.pbobjc.m",
916 "objectivec/google/protobuf/Wrappers.pbobjc.m",
917]
918
919objc_library(
920 name = "objectivec",
921 hdrs = OBJC_HDRS + OBJC_PRIVATE_HDRS,
922 includes = [
923 "objectivec",
924 ],
925 non_arc_srcs = OBJC_SRCS,
926 visibility = ["//visibility:public"],
927)