blob: 0f6e41e3abdc89e8f60fb9d7d37b66db65fe2b2a [file] [log] [blame]
Yifan Hong60c819e2024-02-09 14:47:17 -08001# Bazel (https://bazel.build/) BUILD file for Protobuf.
Cole Fausta68a6762022-05-25 14:58:45 -07002
Yifan Hong60c819e2024-02-09 14:47:17 -08003load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
4load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
5load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
6load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
7load("@rules_python//python:defs.bzl", "py_library")
8load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
9load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS", "PROTOC_LINK_OPTS")
10load(
11 ":protobuf.bzl",
12 "adapt_proto_library",
13 "cc_proto_library",
14 "internal_copied_filegroup",
15 "internal_protobuf_py_tests",
16 "py_proto_library",
Cole Fausta68a6762022-05-25 14:58:45 -070017)
18
Yifan Hong60c819e2024-02-09 14:47:17 -080019licenses(["notice"])
Cole Fausta68a6762022-05-25 14:58:45 -070020
Yifan Hong60c819e2024-02-09 14:47:17 -080021exports_files(["LICENSE"])
22
23################################################################################
24# Protobuf Runtime Library
25################################################################################
26
27cc_library(
28 name = "protobuf_lite",
29 srcs = [
30 # AUTOGEN(protobuf_lite_srcs)
31 "src/google/protobuf/any_lite.cc",
32 "src/google/protobuf/arena.cc",
33 "src/google/protobuf/arenastring.cc",
34 "src/google/protobuf/arenaz_sampler.cc",
35 "src/google/protobuf/extension_set.cc",
36 "src/google/protobuf/generated_enum_util.cc",
37 "src/google/protobuf/generated_message_tctable_lite.cc",
38 "src/google/protobuf/generated_message_util.cc",
39 "src/google/protobuf/implicit_weak_message.cc",
40 "src/google/protobuf/inlined_string_field.cc",
41 "src/google/protobuf/io/coded_stream.cc",
42 "src/google/protobuf/io/io_win32.cc",
43 "src/google/protobuf/io/strtod.cc",
44 "src/google/protobuf/io/zero_copy_stream.cc",
45 "src/google/protobuf/io/zero_copy_stream_impl.cc",
46 "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
47 "src/google/protobuf/map.cc",
48 "src/google/protobuf/message_lite.cc",
49 "src/google/protobuf/parse_context.cc",
50 "src/google/protobuf/repeated_field.cc",
51 "src/google/protobuf/repeated_ptr_field.cc",
52 "src/google/protobuf/stubs/bytestream.cc",
53 "src/google/protobuf/stubs/common.cc",
54 "src/google/protobuf/stubs/int128.cc",
55 "src/google/protobuf/stubs/status.cc",
56 "src/google/protobuf/stubs/statusor.cc",
57 "src/google/protobuf/stubs/stringpiece.cc",
58 "src/google/protobuf/stubs/stringprintf.cc",
59 "src/google/protobuf/stubs/structurally_valid.cc",
60 "src/google/protobuf/stubs/strutil.cc",
61 "src/google/protobuf/stubs/time.cc",
62 "src/google/protobuf/wire_format_lite.cc",
63 ],
64 hdrs = glob([
65 "src/google/protobuf/**/*.h",
66 "src/google/protobuf/**/*.inc",
67 ]),
68 copts = COPTS,
69 includes = ["src/"],
70 linkopts = LINK_OPTS,
71 visibility = ["//visibility:public"],
Cole Fausta68a6762022-05-25 14:58:45 -070072)
73
Yifan Hong60c819e2024-02-09 14:47:17 -080074cc_library(
75 name = "protobuf",
76 srcs = [
77 # AUTOGEN(protobuf_srcs)
78 "src/google/protobuf/any.cc",
79 "src/google/protobuf/any.pb.cc",
80 "src/google/protobuf/api.pb.cc",
81 "src/google/protobuf/compiler/importer.cc",
82 "src/google/protobuf/compiler/parser.cc",
83 "src/google/protobuf/descriptor.cc",
84 "src/google/protobuf/descriptor.pb.cc",
85 "src/google/protobuf/descriptor_database.cc",
86 "src/google/protobuf/duration.pb.cc",
87 "src/google/protobuf/dynamic_message.cc",
88 "src/google/protobuf/empty.pb.cc",
89 "src/google/protobuf/extension_set_heavy.cc",
90 "src/google/protobuf/field_mask.pb.cc",
91 "src/google/protobuf/generated_message_bases.cc",
92 "src/google/protobuf/generated_message_reflection.cc",
93 "src/google/protobuf/generated_message_tctable_full.cc",
94 "src/google/protobuf/io/gzip_stream.cc",
95 "src/google/protobuf/io/printer.cc",
96 "src/google/protobuf/io/tokenizer.cc",
97 "src/google/protobuf/map_field.cc",
98 "src/google/protobuf/message.cc",
99 "src/google/protobuf/reflection_ops.cc",
100 "src/google/protobuf/service.cc",
101 "src/google/protobuf/source_context.pb.cc",
102 "src/google/protobuf/struct.pb.cc",
103 "src/google/protobuf/stubs/substitute.cc",
104 "src/google/protobuf/text_format.cc",
105 "src/google/protobuf/timestamp.pb.cc",
106 "src/google/protobuf/type.pb.cc",
107 "src/google/protobuf/unknown_field_set.cc",
108 "src/google/protobuf/util/delimited_message_util.cc",
109 "src/google/protobuf/util/field_comparator.cc",
110 "src/google/protobuf/util/field_mask_util.cc",
111 "src/google/protobuf/util/internal/datapiece.cc",
112 "src/google/protobuf/util/internal/default_value_objectwriter.cc",
113 "src/google/protobuf/util/internal/error_listener.cc",
114 "src/google/protobuf/util/internal/field_mask_utility.cc",
115 "src/google/protobuf/util/internal/json_escaping.cc",
116 "src/google/protobuf/util/internal/json_objectwriter.cc",
117 "src/google/protobuf/util/internal/json_stream_parser.cc",
118 "src/google/protobuf/util/internal/object_writer.cc",
119 "src/google/protobuf/util/internal/proto_writer.cc",
120 "src/google/protobuf/util/internal/protostream_objectsource.cc",
121 "src/google/protobuf/util/internal/protostream_objectwriter.cc",
122 "src/google/protobuf/util/internal/type_info.cc",
123 "src/google/protobuf/util/internal/utility.cc",
124 "src/google/protobuf/util/json_util.cc",
125 "src/google/protobuf/util/message_differencer.cc",
126 "src/google/protobuf/util/time_util.cc",
127 "src/google/protobuf/util/type_resolver_util.cc",
128 "src/google/protobuf/wire_format.cc",
129 "src/google/protobuf/wrappers.pb.cc",
130 ],
131 hdrs = glob([
132 "src/**/*.h",
133 "src/**/*.inc",
134 ]),
135 copts = COPTS,
136 includes = ["src/"],
137 linkopts = LINK_OPTS,
138 visibility = ["//visibility:public"],
139 deps = [":protobuf_lite"] + select({
140 "//build_defs:config_msvc": [],
141 "//conditions:default": ["@zlib//:zlib"],
142 }),
143)
144
145# This provides just the header files for use in projects that need to build
146# shared libraries for dynamic loading. This target is available until Bazel
147# adds native support for such use cases.
148# TODO(keveman): Remove this target once the support gets added to Bazel.
149cc_library(
150 name = "protobuf_headers",
151 hdrs = glob([
152 "src/**/*.h",
153 "src/**/*.inc",
154 ]),
155 includes = ["src/"],
156 visibility = ["//visibility:public"],
157)
158
159# DEPRECATED: Prefer :well_known_type_protos for the Well-Known Types
160# (https://developers.google.com/protocol-buffers/docs/reference/google.protobuf)
161# or :descriptor_proto(_srcs) for descriptor.proto (source), or
162# :compiler_plugin_proto for compiler/plugin.proto.
163filegroup(
164 name = "well_known_protos",
165 srcs = [
166 "src/google/protobuf/compiler/plugin.proto",
167 "src/google/protobuf/descriptor.proto",
168 ":well_known_type_protos",
169 ],
170 deprecation = "Prefer :well_known_type_protos instead.",
171 visibility = ["//visibility:public"],
172)
173
174filegroup(
175 name = "well_known_type_protos",
176 srcs = [
177 "src/google/protobuf/any.proto",
178 "src/google/protobuf/api.proto",
179 "src/google/protobuf/duration.proto",
180 "src/google/protobuf/empty.proto",
181 "src/google/protobuf/field_mask.proto",
182 "src/google/protobuf/source_context.proto",
183 "src/google/protobuf/struct.proto",
184 "src/google/protobuf/timestamp.proto",
185 "src/google/protobuf/type.proto",
186 "src/google/protobuf/wrappers.proto",
187 ],
188 visibility = ["//visibility:public"],
189)
190
191filegroup(
192 name = "built_in_runtime_protos",
193 srcs = [
194 "src/google/protobuf/compiler/plugin.proto",
195 "src/google/protobuf/descriptor.proto",
196 ],
197 visibility = ["//:__subpackages__"],
198)
199
200exports_files(
201 srcs = [
202 "src/google/protobuf/any.proto",
203 "src/google/protobuf/api.proto",
204 "src/google/protobuf/compiler/plugin.proto",
205 "src/google/protobuf/descriptor.proto",
206 "src/google/protobuf/duration.proto",
207 "src/google/protobuf/empty.proto",
208 "src/google/protobuf/field_mask.proto",
209 "src/google/protobuf/source_context.proto",
210 "src/google/protobuf/struct.proto",
211 "src/google/protobuf/timestamp.proto",
212 "src/google/protobuf/type.proto",
213 "src/google/protobuf/wrappers.proto",
214 ],
215 visibility = ["//pkg:__pkg__"],
216)
217
218alias(
219 name = "lite_well_known_protos",
220 actual = ":well_known_type_protos",
221 visibility = ["//visibility:public"],
222)
223
224adapt_proto_library(
225 name = "cc_wkt_protos_genproto",
226 visibility = ["//visibility:public"],
227 deps = [
228 "//:any_proto",
229 "//:api_proto",
230 "//:compiler_plugin_proto",
231 "//:descriptor_proto",
232 "//:duration_proto",
233 "//:empty_proto",
234 "//:field_mask_proto",
235 "//:source_context_proto",
236 "//:struct_proto",
237 "//:timestamp_proto",
238 "//:type_proto",
239 "//:wrappers_proto",
240 ],
241)
242
243cc_library(
244 name = "cc_wkt_protos",
245 deprecation = "Only for backward compatibility. Do not use.",
246 visibility = ["//visibility:public"],
247)
248
249################################################################################
250# Well Known Types Proto Library Rules
251#
252# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf
253################################################################################
254# These proto_library rules can be used with one of the language specific proto
255# library rules i.e. java_proto_library:
256#
257# java_proto_library(
258# name = "any_java_proto",
259# deps = ["@com_google_protobuf//:any_proto],
260# )
261################################################################################
262
263proto_library(
264 name = "any_proto",
265 srcs = ["src/google/protobuf/any.proto"],
266 strip_import_prefix = "src",
267 visibility = ["//visibility:public"],
Cole Fausta68a6762022-05-25 14:58:45 -0700268)
269
270proto_library(
Yifan Hong60c819e2024-02-09 14:47:17 -0800271 name = "api_proto",
272 srcs = ["src/google/protobuf/api.proto"],
273 strip_import_prefix = "src",
274 visibility = ["//visibility:public"],
275 deps = [
276 "//:source_context_proto",
277 "//:type_proto",
278 ],
279)
280
281proto_library(
282 name = "duration_proto",
283 srcs = ["//:src/google/protobuf/duration.proto"],
284 strip_import_prefix = "src",
285 visibility = ["//visibility:public"],
286)
287
288proto_library(
289 name = "empty_proto",
290 srcs = ["src/google/protobuf/empty.proto"],
291 strip_import_prefix = "src",
292 visibility = ["//visibility:public"],
293)
294
295proto_library(
296 name = "field_mask_proto",
297 srcs = ["src/google/protobuf/field_mask.proto"],
298 strip_import_prefix = "src",
299 visibility = ["//visibility:public"],
300)
301
302proto_library(
303 name = "source_context_proto",
304 srcs = ["src/google/protobuf/source_context.proto"],
305 strip_import_prefix = "src",
306 visibility = ["//visibility:public"],
307)
308
309proto_library(
310 name = "struct_proto",
311 srcs = ["src/google/protobuf/struct.proto"],
312 strip_import_prefix = "src",
313 visibility = ["//visibility:public"],
314)
315
316proto_library(
317 name = "timestamp_proto",
318 srcs = ["src/google/protobuf/timestamp.proto"],
319 strip_import_prefix = "src",
320 visibility = ["//visibility:public"],
321)
322
323proto_library(
324 name = "type_proto",
325 srcs = ["src/google/protobuf/type.proto"],
326 strip_import_prefix = "src",
327 visibility = ["//visibility:public"],
328 deps = [
329 "//:any_proto",
330 "//:source_context_proto",
331 ],
332)
333
334proto_library(
335 name = "wrappers_proto",
336 srcs = ["src/google/protobuf/wrappers.proto"],
337 strip_import_prefix = "src",
338 visibility = ["//visibility:public"],
339)
340
341# Built-in runtime types
342
343proto_library(
344 name = "compiler_plugin_proto",
345 srcs = ["src/google/protobuf/compiler/plugin.proto"],
346 strip_import_prefix = "src",
347 visibility = ["//visibility:public"],
348 deps = ["//:descriptor_proto"],
349)
350
351proto_library(
352 name = "descriptor_proto",
353 srcs = ["src/google/protobuf/descriptor.proto"],
354 strip_import_prefix = "src",
355 visibility = ["//visibility:public"],
356)
357
358################################################################################
359# Protocol Buffers Compiler
360################################################################################
361
362cc_library(
363 name = "protoc_lib",
364 srcs = [
365 # AUTOGEN(protoc_lib_srcs)
366 "src/google/protobuf/compiler/code_generator.cc",
367 "src/google/protobuf/compiler/command_line_interface.cc",
368 "src/google/protobuf/compiler/cpp/enum.cc",
369 "src/google/protobuf/compiler/cpp/enum_field.cc",
370 "src/google/protobuf/compiler/cpp/extension.cc",
371 "src/google/protobuf/compiler/cpp/field.cc",
372 "src/google/protobuf/compiler/cpp/file.cc",
373 "src/google/protobuf/compiler/cpp/generator.cc",
374 "src/google/protobuf/compiler/cpp/helpers.cc",
375 "src/google/protobuf/compiler/cpp/map_field.cc",
376 "src/google/protobuf/compiler/cpp/message.cc",
377 "src/google/protobuf/compiler/cpp/message_field.cc",
378 "src/google/protobuf/compiler/cpp/padding_optimizer.cc",
379 "src/google/protobuf/compiler/cpp/parse_function_generator.cc",
380 "src/google/protobuf/compiler/cpp/primitive_field.cc",
381 "src/google/protobuf/compiler/cpp/service.cc",
382 "src/google/protobuf/compiler/cpp/string_field.cc",
383 "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
384 "src/google/protobuf/compiler/csharp/csharp_enum.cc",
385 "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
386 "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
387 "src/google/protobuf/compiler/csharp/csharp_generator.cc",
388 "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
389 "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
390 "src/google/protobuf/compiler/csharp/csharp_message.cc",
391 "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
392 "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
393 "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
394 "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
395 "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
396 "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
397 "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
398 "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
399 "src/google/protobuf/compiler/java/context.cc",
400 "src/google/protobuf/compiler/java/doc_comment.cc",
401 "src/google/protobuf/compiler/java/enum.cc",
402 "src/google/protobuf/compiler/java/enum_field.cc",
403 "src/google/protobuf/compiler/java/enum_field_lite.cc",
404 "src/google/protobuf/compiler/java/enum_lite.cc",
405 "src/google/protobuf/compiler/java/extension.cc",
406 "src/google/protobuf/compiler/java/extension_lite.cc",
407 "src/google/protobuf/compiler/java/field.cc",
408 "src/google/protobuf/compiler/java/file.cc",
409 "src/google/protobuf/compiler/java/generator.cc",
410 "src/google/protobuf/compiler/java/generator_factory.cc",
411 "src/google/protobuf/compiler/java/helpers.cc",
412 "src/google/protobuf/compiler/java/kotlin_generator.cc",
413 "src/google/protobuf/compiler/java/map_field.cc",
414 "src/google/protobuf/compiler/java/map_field_lite.cc",
415 "src/google/protobuf/compiler/java/message.cc",
416 "src/google/protobuf/compiler/java/message_builder.cc",
417 "src/google/protobuf/compiler/java/message_builder_lite.cc",
418 "src/google/protobuf/compiler/java/message_field.cc",
419 "src/google/protobuf/compiler/java/message_field_lite.cc",
420 "src/google/protobuf/compiler/java/message_lite.cc",
421 "src/google/protobuf/compiler/java/name_resolver.cc",
422 "src/google/protobuf/compiler/java/primitive_field.cc",
423 "src/google/protobuf/compiler/java/primitive_field_lite.cc",
424 "src/google/protobuf/compiler/java/service.cc",
425 "src/google/protobuf/compiler/java/shared_code_generator.cc",
426 "src/google/protobuf/compiler/java/string_field.cc",
427 "src/google/protobuf/compiler/java/string_field_lite.cc",
428 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
429 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
430 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
431 "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
432 "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
433 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
434 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
435 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
436 "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
437 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
438 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
439 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
440 "src/google/protobuf/compiler/php/php_generator.cc",
441 "src/google/protobuf/compiler/plugin.cc",
442 "src/google/protobuf/compiler/plugin.pb.cc",
443 "src/google/protobuf/compiler/python/generator.cc",
444 "src/google/protobuf/compiler/python/helpers.cc",
445 "src/google/protobuf/compiler/python/pyi_generator.cc",
446 "src/google/protobuf/compiler/ruby/ruby_generator.cc",
447 "src/google/protobuf/compiler/subprocess.cc",
448 "src/google/protobuf/compiler/zip_writer.cc",
449 ],
450 copts = COPTS,
451 includes = ["src/"],
452 linkopts = LINK_OPTS,
453 visibility = ["//visibility:public"],
454 deps = [":protobuf"],
455)
456
457cc_binary(
458 name = "protoc",
459 srcs = ["src/google/protobuf/compiler/main.cc"],
460 linkopts = LINK_OPTS + PROTOC_LINK_OPTS,
461 visibility = ["//visibility:public"],
462 deps = [":protoc_lib"],
463)
464
465################################################################################
466# Tests
467################################################################################
468
469filegroup(
470 name = "testdata",
471 srcs = glob(["src/google/protobuf/testdata/**/*"]),
472 visibility = [
473 "//:__subpackages__",
474 "@upb//:__subpackages__",
475 ],
476)
477
478RELATIVE_LITE_TEST_PROTOS = [
479 # AUTOGEN(lite_test_protos)
480 "google/protobuf/map_lite_unittest.proto",
481 "google/protobuf/unittest_import_lite.proto",
482 "google/protobuf/unittest_import_public_lite.proto",
483 "google/protobuf/unittest_lite.proto",
484]
485
486LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
487
488RELATIVE_TEST_PROTOS = [
489 # AUTOGEN(test_protos)
490 "google/protobuf/any_test.proto",
491 "google/protobuf/compiler/cpp/test_bad_identifiers.proto",
492 "google/protobuf/compiler/cpp/test_large_enum_value.proto",
493 "google/protobuf/map_proto2_unittest.proto",
494 "google/protobuf/map_unittest.proto",
495 "google/protobuf/unittest.proto",
496 "google/protobuf/unittest_arena.proto",
497 "google/protobuf/unittest_custom_options.proto",
498 "google/protobuf/unittest_drop_unknown_fields.proto",
499 "google/protobuf/unittest_embed_optimize_for.proto",
500 "google/protobuf/unittest_empty.proto",
501 "google/protobuf/unittest_enormous_descriptor.proto",
502 "google/protobuf/unittest_import.proto",
503 "google/protobuf/unittest_import_public.proto",
504 "google/protobuf/unittest_lazy_dependencies.proto",
505 "google/protobuf/unittest_lazy_dependencies_custom_option.proto",
506 "google/protobuf/unittest_lazy_dependencies_enum.proto",
507 "google/protobuf/unittest_lite_imports_nonlite.proto",
508 "google/protobuf/unittest_mset.proto",
509 "google/protobuf/unittest_mset_wire_format.proto",
510 "google/protobuf/unittest_no_field_presence.proto",
511 "google/protobuf/unittest_no_generic_services.proto",
512 "google/protobuf/unittest_optimize_for.proto",
513 "google/protobuf/unittest_preserve_unknown_enum.proto",
514 "google/protobuf/unittest_preserve_unknown_enum2.proto",
515 "google/protobuf/unittest_proto3.proto",
516 "google/protobuf/unittest_proto3_arena.proto",
517 "google/protobuf/unittest_proto3_arena_lite.proto",
518 "google/protobuf/unittest_proto3_lite.proto",
519 "google/protobuf/unittest_proto3_optional.proto",
520 "google/protobuf/unittest_well_known_types.proto",
521 "google/protobuf/util/internal/testdata/anys.proto",
522 "google/protobuf/util/internal/testdata/books.proto",
523 "google/protobuf/util/internal/testdata/default_value.proto",
524 "google/protobuf/util/internal/testdata/default_value_test.proto",
525 "google/protobuf/util/internal/testdata/field_mask.proto",
526 "google/protobuf/util/internal/testdata/maps.proto",
527 "google/protobuf/util/internal/testdata/oneofs.proto",
528 "google/protobuf/util/internal/testdata/proto3.proto",
529 "google/protobuf/util/internal/testdata/struct.proto",
530 "google/protobuf/util/internal/testdata/timestamp_duration.proto",
531 "google/protobuf/util/internal/testdata/wrappers.proto",
532 "google/protobuf/util/json_format.proto",
533 "google/protobuf/util/json_format_proto3.proto",
534 "google/protobuf/util/message_differencer_unittest.proto",
535]
536
537TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
538
539GENERIC_RELATIVE_TEST_PROTOS = [
540 "google/protobuf/map_proto2_unittest.proto",
541 "google/protobuf/map_unittest.proto",
542 "google/protobuf/unittest.proto",
543 "google/protobuf/unittest_arena.proto",
544 "google/protobuf/unittest_custom_options.proto",
545 "google/protobuf/unittest_drop_unknown_fields.proto",
546 "google/protobuf/unittest_embed_optimize_for.proto",
547 "google/protobuf/unittest_empty.proto",
548 "google/protobuf/unittest_enormous_descriptor.proto",
549 "google/protobuf/unittest_import.proto",
550 "google/protobuf/unittest_import_public.proto",
551 "google/protobuf/unittest_lazy_dependencies.proto",
552 "google/protobuf/unittest_lazy_dependencies_custom_option.proto",
553 "google/protobuf/unittest_lazy_dependencies_enum.proto",
554 "google/protobuf/unittest_lite_imports_nonlite.proto",
555 "google/protobuf/unittest_mset.proto",
556 "google/protobuf/unittest_mset_wire_format.proto",
557 "google/protobuf/unittest_no_field_presence.proto",
558 "google/protobuf/unittest_no_generic_services.proto",
559 "google/protobuf/unittest_optimize_for.proto",
560 "google/protobuf/unittest_preserve_unknown_enum.proto",
561 "google/protobuf/unittest_preserve_unknown_enum2.proto",
562 "google/protobuf/unittest_proto3.proto",
563 "google/protobuf/unittest_proto3_arena.proto",
564 "google/protobuf/unittest_proto3_arena_lite.proto",
565 "google/protobuf/unittest_proto3_lite.proto",
566 "google/protobuf/unittest_proto3_optional.proto",
567 "google/protobuf/unittest_well_known_types.proto",
568]
569
570GENERIC_TEST_PROTOS = ["src/" + s for s in GENERIC_RELATIVE_TEST_PROTOS]
571
572proto_library(
573 name = "generic_test_protos",
574 srcs = LITE_TEST_PROTOS + GENERIC_TEST_PROTOS,
575 strip_import_prefix = "src",
576 visibility = ["//:__subpackages__"],
577 deps = [
578 "//:any_proto",
579 "//:api_proto",
580 "//:descriptor_proto",
581 "//:duration_proto",
582 "//:empty_proto",
583 "//:field_mask_proto",
584 "//:source_context_proto",
585 "//:struct_proto",
586 "//:timestamp_proto",
587 "//:type_proto",
588 "//:wrappers_proto",
589 ],
590)
591
592cc_proto_library(
593 name = "cc_test_protos",
594 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
595 include = "src",
596 default_runtime = ":protobuf",
597 protoc = ":protoc",
598 deps = [":cc_wkt_protos"],
599)
600
601COMMON_TEST_SRCS = [
602 # AUTOGEN(common_test_srcs)
603 "src/google/protobuf/arena_test_util.cc",
604 "src/google/protobuf/map_lite_test_util.cc",
605 "src/google/protobuf/test_util_lite.cc",
606 "src/google/protobuf/map_test_util.inc",
607 "src/google/protobuf/reflection_tester.cc",
608 "src/google/protobuf/test_util.cc",
609 "src/google/protobuf/test_util.inc",
610 "src/google/protobuf/testing/file.cc",
611 "src/google/protobuf/testing/googletest.cc",
612]
613
614cc_binary(
615 name = "test_plugin",
616 testonly = True,
617 srcs = [
618 # AUTOGEN(test_plugin_srcs)
619 "src/google/protobuf/compiler/mock_code_generator.cc",
620 "src/google/protobuf/compiler/test_plugin.cc",
621 "src/google/protobuf/testing/file.cc",
622 ],
623 deps = [
624 ":protobuf",
625 ":protoc_lib",
626 "@com_google_googletest//:gtest",
627 ],
628)
629
630cc_test(
631 name = "win32_test",
632 srcs = ["src/google/protobuf/io/io_win32_unittest.cc"],
633 tags = [
634 "manual",
635 "windows",
636 ],
637 deps = [
638 ":protobuf_lite",
639 "@com_google_googletest//:gtest",
640 "@com_google_googletest//:gtest_main",
641 ],
642)
643
644cc_test(
645 name = "protobuf_test",
646 srcs = COMMON_TEST_SRCS + [
647 # AUTOGEN(test_srcs)
648 "src/google/protobuf/any_test.cc",
649 "src/google/protobuf/arena_unittest.cc",
650 "src/google/protobuf/arenastring_unittest.cc",
651 "src/google/protobuf/arenaz_sampler_test.cc",
652 "src/google/protobuf/compiler/annotation_test_util.cc",
653 "src/google/protobuf/compiler/command_line_interface_unittest.cc",
654 "src/google/protobuf/compiler/cpp/bootstrap_unittest.cc",
655 "src/google/protobuf/compiler/cpp/metadata_test.cc",
656 "src/google/protobuf/compiler/cpp/move_unittest.cc",
657 "src/google/protobuf/compiler/cpp/plugin_unittest.cc",
658 "src/google/protobuf/compiler/cpp/unittest.cc",
659 "src/google/protobuf/compiler/cpp/unittest.inc",
660 "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc",
661 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
662 "src/google/protobuf/compiler/importer_unittest.cc",
663 "src/google/protobuf/compiler/java/doc_comment_unittest.cc",
664 "src/google/protobuf/compiler/java/plugin_unittest.cc",
665 "src/google/protobuf/compiler/mock_code_generator.cc",
666 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
667 "src/google/protobuf/compiler/parser_unittest.cc",
668 "src/google/protobuf/compiler/python/plugin_unittest.cc",
669 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
670 "src/google/protobuf/descriptor_database_unittest.cc",
671 "src/google/protobuf/descriptor_unittest.cc",
672 "src/google/protobuf/drop_unknown_fields_test.cc",
673 "src/google/protobuf/dynamic_message_unittest.cc",
674 "src/google/protobuf/extension_set_unittest.cc",
675 "src/google/protobuf/generated_message_reflection_unittest.cc",
676 "src/google/protobuf/generated_message_tctable_lite_test.cc",
677 "src/google/protobuf/inlined_string_field_unittest.cc",
678 "src/google/protobuf/io/coded_stream_unittest.cc",
679 "src/google/protobuf/io/io_win32_unittest.cc",
680 "src/google/protobuf/io/printer_unittest.cc",
681 "src/google/protobuf/io/tokenizer_unittest.cc",
682 "src/google/protobuf/io/zero_copy_stream_unittest.cc",
683 "src/google/protobuf/map_field_test.cc",
684 "src/google/protobuf/map_test.cc",
685 "src/google/protobuf/map_test.inc",
686 "src/google/protobuf/message_unittest.cc",
687 "src/google/protobuf/message_unittest.inc",
688 "src/google/protobuf/no_field_presence_test.cc",
689 "src/google/protobuf/preserve_unknown_enum_test.cc",
690 "src/google/protobuf/proto3_arena_lite_unittest.cc",
691 "src/google/protobuf/proto3_arena_unittest.cc",
692 "src/google/protobuf/proto3_lite_unittest.cc",
693 "src/google/protobuf/proto3_lite_unittest.inc",
694 "src/google/protobuf/reflection_ops_unittest.cc",
695 "src/google/protobuf/repeated_field_reflection_unittest.cc",
696 "src/google/protobuf/repeated_field_unittest.cc",
697 "src/google/protobuf/stubs/bytestream_unittest.cc",
698 "src/google/protobuf/stubs/common_unittest.cc",
699 "src/google/protobuf/stubs/int128_unittest.cc",
700 "src/google/protobuf/stubs/status_test.cc",
701 "src/google/protobuf/stubs/statusor_test.cc",
702 "src/google/protobuf/stubs/stringpiece_unittest.cc",
703 "src/google/protobuf/stubs/stringprintf_unittest.cc",
704 "src/google/protobuf/stubs/structurally_valid_unittest.cc",
705 "src/google/protobuf/stubs/strutil_unittest.cc",
706 "src/google/protobuf/stubs/template_util_unittest.cc",
707 "src/google/protobuf/stubs/time_test.cc",
708 "src/google/protobuf/text_format_unittest.cc",
709 "src/google/protobuf/unknown_field_set_unittest.cc",
710 "src/google/protobuf/util/delimited_message_util_test.cc",
711 "src/google/protobuf/util/field_comparator_test.cc",
712 "src/google/protobuf/util/field_mask_util_test.cc",
713 "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
714 "src/google/protobuf/util/internal/json_objectwriter_test.cc",
715 "src/google/protobuf/util/internal/json_stream_parser_test.cc",
716 "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
717 "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
718 "src/google/protobuf/util/internal/type_info_test_helper.cc",
719 "src/google/protobuf/util/json_util_test.cc",
720 "src/google/protobuf/util/message_differencer_unittest.cc",
721 "src/google/protobuf/util/time_util_test.cc",
722 "src/google/protobuf/util/type_resolver_util_test.cc",
723 "src/google/protobuf/well_known_types_unittest.cc",
724 "src/google/protobuf/wire_format_unittest.cc",
725 "src/google/protobuf/wire_format_unittest.inc",
726 ],
727 copts = COPTS + select({
728 "//build_defs:config_msvc": [],
729 "//conditions:default": [
730 "-Wno-deprecated-declarations",
731 ],
732 }),
733 data = [
734 # Files for csharp_bootstrap_unittest.cc.
735 "//conformance:all_files",
736 ":test_plugin",
737 ] + glob([
738 "src/google/protobuf/**/*",
739 ]) + glob(
740 [
741 # Files for csharp_bootstrap_unittest.cc.
742 "csharp/src/**/*",
743 ],
744 allow_empty = True,
745 ),
746 includes = [
747 "src/",
748 ],
749 linkopts = LINK_OPTS,
750 deps = [
751 ":cc_test_protos",
752 ":protobuf",
753 ":protoc_lib",
754 "@com_google_googletest//:gtest",
755 "@com_google_googletest//:gtest_main",
756 ] + select({
757 "//build_defs:config_msvc": [],
758 "//conditions:default": ["@zlib//:zlib"],
759 }),
760)
761
762################################################################################
763# Java support
764################################################################################
765
766alias(
767 name = "protobuf_java",
768 actual = "//java/core",
769 visibility = ["//visibility:public"],
770)
771
772alias(
773 name = "protobuf_javalite",
774 actual = "//java/lite",
775 visibility = ["//visibility:public"],
776)
777
778alias(
779 name = "protobuf_java_util",
780 actual = "//java/util",
781 visibility = ["//visibility:public"],
782)
783
784alias(
785 name = "java_toolchain",
786 actual = "//java/core:toolchain",
787 visibility = ["//visibility:public"],
788)
789
790alias(
791 name = "javalite_toolchain",
792 actual = "//java/lite:toolchain",
793 visibility = ["//visibility:public"],
794)
795
796################################################################################
797# Python support
798################################################################################
799
800py_library(
801 name = "python_srcs",
802 srcs = glob(
803 [
804 "python/google/protobuf/**/*.py",
805 ],
806 ),
807 imports = ["python"],
808 srcs_version = "PY2AND3",
809 visibility = ["@upb//:__subpackages__"],
810)
811
812py_library(
813 name = "python_test_srcs",
814 srcs = glob(
815 [
816 "python/google/protobuf/internal/*_test.py",
817 "python/google/protobuf/internal/test_util.py",
818 ],
819 ),
820 imports = ["python"],
821 srcs_version = "PY3",
822 visibility = ["@upb//:__subpackages__"],
823)
824
825cc_binary(
826 name = "python/google/protobuf/internal/_api_implementation.so",
827 srcs = ["python/google/protobuf/internal/api_implementation.cc"],
828 copts = COPTS + [
829 "-DPYTHON_PROTO2_CPP_IMPL_V2",
830 ],
831 linkshared = 1,
832 linkstatic = 1,
833 tags = [
834 # Exclude this target from wildcard expansion (//...) because it may
835 # not even be buildable. It will be built if it is needed according
836 # to :use_fast_cpp_protos.
837 # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes
838 "manual",
839 ],
840 deps = select({
841 "//conditions:default": [],
842 ":use_fast_cpp_protos": ["//external:python_headers"],
843 }),
844)
845
846cc_binary(
847 name = "python/google/protobuf/pyext/_message.so",
848 srcs = glob([
849 "python/google/protobuf/pyext/*.cc",
850 "python/google/protobuf/pyext/*.h",
851 ]),
852 copts = COPTS + [
853 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
854 ] + select({
855 "//conditions:default": [],
856 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
857 }),
858 includes = [
859 "python/",
860 "src/",
861 ],
862 linkshared = 1,
863 linkstatic = 1,
864 tags = [
865 # Exclude this target from wildcard expansion (//...) because it may
866 # not even be buildable. It will be built if it is needed according
867 # to :use_fast_cpp_protos.
868 # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes
869 "manual",
870 ],
871 deps = [
872 ":protobuf",
873 ":proto_api",
874 ] + select({
875 "//conditions:default": [],
876 ":use_fast_cpp_protos": ["//external:python_headers"],
877 }),
878)
879
880config_setting(
881 name = "use_fast_cpp_protos",
882 values = {
883 "define": "use_fast_cpp_protos=true",
884 },
885 visibility = [
886 # Public, but Protobuf only visibility.
887 "//:__subpackages__",
888 ],
889)
890
891config_setting(
892 name = "allow_oversize_protos",
893 values = {
894 "define": "allow_oversize_protos=true",
895 },
896 visibility = [
897 # Public, but Protobuf only visibility.
898 "//:__subpackages__",
899 ],
900)
901
902# Copy the builtin proto files from src/google/protobuf to
903# python/google/protobuf. This way, the generated Python sources will be in the
904# same directory as the Python runtime sources. This is necessary for the
905# modules to be imported correctly since they are all part of the same Python
906# package.
907internal_copied_filegroup(
908 name = "protos_python",
909 srcs = [
910 "src/google/protobuf/any.proto",
911 "src/google/protobuf/api.proto",
912 "src/google/protobuf/compiler/plugin.proto",
913 "src/google/protobuf/descriptor.proto",
914 "src/google/protobuf/duration.proto",
915 "src/google/protobuf/empty.proto",
916 "src/google/protobuf/field_mask.proto",
917 "src/google/protobuf/source_context.proto",
918 "src/google/protobuf/struct.proto",
919 "src/google/protobuf/timestamp.proto",
920 "src/google/protobuf/type.proto",
921 "src/google/protobuf/wrappers.proto",
922 ],
923 dest = "python",
924 strip_prefix = "src",
925)
926
927py_proto_library(
928 name = "well_known_types_py_pb2",
929 srcs = [
930 "python/google/protobuf/any.proto",
931 "python/google/protobuf/api.proto",
932 "python/google/protobuf/compiler/plugin.proto",
933 "python/google/protobuf/descriptor.proto",
934 "python/google/protobuf/duration.proto",
935 "python/google/protobuf/empty.proto",
936 "python/google/protobuf/field_mask.proto",
937 "python/google/protobuf/source_context.proto",
938 "python/google/protobuf/struct.proto",
939 "python/google/protobuf/timestamp.proto",
940 "python/google/protobuf/type.proto",
941 "python/google/protobuf/wrappers.proto",
942 ],
943 include = "python",
944 default_runtime = "",
945 protoc = ":protoc",
946 srcs_version = "PY2AND3",
947 visibility = ["//visibility:public"],
948)
949
950py_library(
951 name = "protobuf_python",
952 data = select({
953 "//conditions:default": [],
954 ":use_fast_cpp_protos": [
955 ":python/google/protobuf/internal/_api_implementation.so",
956 ":python/google/protobuf/pyext/_message.so",
957 ],
958 }),
959 visibility = ["//visibility:public"],
960 deps = [
961 ":python_srcs",
962 ":well_known_types_py_pb2",
963 ],
964)
965
966# Copy the test proto files from src/google/protobuf to
967# python/google/protobuf. This way, the generated Python sources will be in the
968# same directory as the Python runtime sources. This is necessary for the
969# modules to be imported correctly by the tests since they are all part of the
970# same Python package.
971internal_copied_filegroup(
972 name = "protos_python_test",
973 srcs = LITE_TEST_PROTOS + TEST_PROTOS,
974 dest = "python",
975 strip_prefix = "src",
976)
977
978# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
979# which case we can simply add :protos_python_test in srcs.
980COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
981
982COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
983
984py_proto_library(
985 name = "python_common_test_protos",
986 srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
987 include = "python",
988 default_runtime = "",
989 protoc = ":protoc",
990 srcs_version = "PY2AND3",
991 visibility = ["//visibility:public"],
992 deps = [":well_known_types_py_pb2"],
993)
994
995py_proto_library(
996 name = "python_specific_test_protos",
997 srcs = glob([
998 "python/google/protobuf/internal/*.proto",
999 "python/google/protobuf/internal/import_test_package/*.proto",
1000 ]),
1001 include = "python",
1002 default_runtime = ":protobuf_python",
1003 protoc = ":protoc",
1004 srcs_version = "PY2AND3",
1005 visibility = ["//visibility:public"],
1006 deps = [":python_common_test_protos"],
1007)
1008
1009py_library(
1010 name = "python_tests",
1011 srcs = glob(
1012 [
1013 "python/google/protobuf/internal/*_test.py",
1014 "python/google/protobuf/internal/test_util.py",
1015 "python/google/protobuf/internal/import_test_package/__init__.py",
1016 ],
1017 ),
1018 imports = ["python"],
1019 srcs_version = "PY2AND3",
1020 deps = [
1021 ":protobuf_python",
1022 ":python_common_test_protos",
1023 ":python_specific_test_protos",
1024 ],
1025)
1026
1027internal_protobuf_py_tests(
1028 name = "python_tests_batch",
1029 data = glob([
1030 "src/google/protobuf/**/*",
1031 ]),
1032 modules = [
1033 "descriptor_database_test",
1034 "descriptor_pool_test",
1035 "descriptor_test",
1036 "generator_test",
1037 "json_format_test",
1038 "message_factory_test",
1039 "message_test",
1040 "proto_builder_test",
1041 "reflection_test",
1042 "service_reflection_test",
1043 "symbol_database_test",
1044 "text_encoding_test",
1045 "text_format_test",
1046 "unknown_fields_test",
1047 "wire_format_test",
1048 ],
1049 deps = [":python_tests"],
1050)
1051
1052cc_library(
1053 name = "proto_api",
1054 hdrs = ["python/google/protobuf/proto_api.h"],
1055 visibility = ["//visibility:public"],
1056 deps = [
1057 "//external:python_headers",
1058 ],
1059)
1060
1061proto_lang_toolchain(
1062 name = "cc_toolchain",
1063 blacklisted_protos = [
1064 "@com_google_protobuf//:any_proto",
1065 "@com_google_protobuf//:api_proto",
1066 "@com_google_protobuf//:compiler_plugin_proto",
1067 "@com_google_protobuf//:descriptor_proto",
1068 "@com_google_protobuf//:duration_proto",
1069 "@com_google_protobuf//:empty_proto",
1070 "@com_google_protobuf//:field_mask_proto",
1071 "@com_google_protobuf//:source_context_proto",
1072 "@com_google_protobuf//:struct_proto",
1073 "@com_google_protobuf//:timestamp_proto",
1074 "@com_google_protobuf//:type_proto",
1075 "@com_google_protobuf//:wrappers_proto",
1076 ],
1077 command_line = "--cpp_out=$(OUT)",
1078 runtime = ":protobuf",
1079 visibility = ["//visibility:public"],
1080)
1081
1082alias(
1083 name = "objectivec",
1084 actual = "//objectivec",
1085 tags = ["manual"],
1086 visibility = ["//visibility:public"],
1087)
1088
1089alias(
1090 name = "protobuf_objc",
1091 actual = "//objectivec",
1092 tags = ["manual"],
1093 visibility = ["//visibility:public"],
1094)
1095
1096################################################################################
1097# Test generated proto support
1098################################################################################
1099
1100genrule(
1101 name = "generated_protos",
1102 srcs = ["src/google/protobuf/unittest_import.proto"],
1103 outs = ["unittest_gen_import.proto"],
1104 cmd = "cat $(SRCS) | sed 's|google/|src/google/|' > $(OUTS)",
1105)
1106
1107proto_library(
1108 name = "generated_protos_proto",
1109 srcs = [
1110 "src/google/protobuf/unittest_import_public.proto",
1111 "unittest_gen_import.proto",
1112 ],
1113)
1114
1115py_proto_library(
1116 name = "generated_protos_py",
1117 srcs = [
1118 "src/google/protobuf/unittest_import_public.proto",
1119 "unittest_gen_import.proto",
1120 ],
1121 default_runtime = "",
1122 protoc = ":protoc",
1123)
1124
1125################################################################################
1126# Conformance tests
1127################################################################################
1128
1129alias(
1130 name = "conformance_test_runner",
1131 actual = "//conformance:conformance_test_runner",
1132 visibility = ["//visibility:public"],
1133)
1134
1135proto_library(
1136 name = "test_messages_proto2_proto",
1137 strip_import_prefix = "src",
1138 srcs = ["src/google/protobuf/test_messages_proto2.proto"],
1139 visibility = ["//visibility:public"],
1140)
1141
1142proto_library(
1143 name = "test_messages_proto3_proto",
1144 strip_import_prefix = "src",
1145 srcs = ["src/google/protobuf/test_messages_proto3.proto"],
1146 visibility = ["//visibility:public"],
1147 deps = [
1148 ":any_proto",
1149 ":duration_proto",
1150 ":field_mask_proto",
1151 ":struct_proto",
1152 ":timestamp_proto",
1153 ":wrappers_proto",
1154 ],
1155)
1156
1157# TODO: re-enable this test if appropriate, or replace with something that
1158# uses the new setup.
1159# sh_test(
1160# name = "build_files_updated_unittest",
1161# srcs = [
1162# "build_files_updated_unittest.sh",
1163# ],
1164# data = [
1165# "BUILD",
1166# "cmake/extract_includes.bat.in",
1167# "cmake/libprotobuf.cmake",
1168# "cmake/libprotobuf-lite.cmake",
1169# "cmake/libprotoc.cmake",
1170# "cmake/tests.cmake",
1171# "src/Makefile.am",
1172# "update_file_lists.sh",
1173# ],
1174# )
1175
1176java_proto_library(
1177 name = "test_messages_proto2_java_proto",
1178 visibility = [
1179 "//conformance:__pkg__",
1180 "//java:__subpackages__",
1181 ],
1182 deps = [":test_messages_proto2_proto"],
1183)
1184
1185java_proto_library(
1186 name = "test_messages_proto3_java_proto",
1187 visibility = [
1188 "//conformance:__pkg__",
1189 "//java:__subpackages__",
1190 ],
1191 deps = [":test_messages_proto3_proto"],
1192)
1193
1194java_lite_proto_library(
1195 name = "test_messages_proto2_java_proto_lite",
1196 visibility = [
1197 "//conformance:__pkg__",
1198 "//java:__subpackages__",
1199 ],
1200 deps = [":test_messages_proto2_proto"],
1201)
1202
1203java_lite_proto_library(
1204 name = "test_messages_proto3_java_proto_lite",
1205 visibility = [
1206 "//conformance:__pkg__",
1207 "//java:__subpackages__",
1208 ],
1209 deps = [":test_messages_proto3_proto"],
1210)
1211
1212filegroup(
1213 name = "bzl_srcs",
1214 srcs = glob(["**/*.bzl"]),
1215 visibility = ["//visibility:public"],
1216)
1217
1218# Kotlin proto rules
1219
1220proto_library(
1221 name = "kt_unittest_lite",
1222 srcs = [
1223 "src/google/protobuf/map_lite_unittest.proto",
1224 "src/google/protobuf/unittest_import_lite.proto",
1225 "src/google/protobuf/unittest_import_public_lite.proto",
1226 "src/google/protobuf/unittest_lite.proto",
1227 ],
1228 visibility = ["//java/kotlin-lite:__subpackages__"],
Cole Fausta68a6762022-05-25 14:58:45 -07001229 strip_import_prefix = "src",
1230)
Zi Wangbd4496b2023-09-07 11:55:38 -07001231
Yifan Hong60c819e2024-02-09 14:47:17 -08001232proto_library(
1233 name = "kt_unittest",
Zi Wang87050d52023-09-07 15:43:08 -07001234 srcs = [
Yifan Hong60c819e2024-02-09 14:47:17 -08001235 "src/google/protobuf/map_proto2_unittest.proto",
1236 "src/google/protobuf/unittest.proto",
1237 "src/google/protobuf/unittest_import.proto",
1238 "src/google/protobuf/unittest_import_public.proto",
Zi Wang87050d52023-09-07 15:43:08 -07001239 ],
Yifan Hong60c819e2024-02-09 14:47:17 -08001240 visibility = ["//java/kotlin:__subpackages__"],
1241 strip_import_prefix = "src",
Zi Wang87050d52023-09-07 15:43:08 -07001242)
1243
Yifan Hong60c819e2024-02-09 14:47:17 -08001244proto_library(
1245 name = "kt_proto3_unittest",
1246 srcs = [
1247 "src/google/protobuf/unittest_import.proto",
1248 "src/google/protobuf/unittest_import_public.proto",
1249 "src/google/protobuf/unittest_proto3.proto",
1250 ],
1251 visibility = [
1252 "//java/kotlin:__subpackages__",
1253 "//java/kotlin-lite:__subpackages__",
1254 ],
1255 strip_import_prefix = "src",
Zi Wangbd4496b2023-09-07 11:55:38 -07001256)
1257
Yifan Hong60c819e2024-02-09 14:47:17 -08001258################################################################################
1259# Packaging rules
1260################################################################################
1261
1262# Files included in all source distributions
1263pkg_files(
1264 name = "common_dist_files",
1265 srcs = glob(
1266 [
1267 "*.bzl",
1268 "cmake/*.cmake",
1269 "cmake/*.in",
1270 "editors/*",
1271
1272 # Several of these files are generated by autogen.sh, so using
1273 # glob() lets us ignore them if they are missing. (This is not good
1274 # practice, though.)
1275 "Makefile.in",
1276 "aclocal.m4",
1277 "ar-lib",
1278 "compile",
1279 "config*",
1280 "depcomp",
1281 "install-sh",
1282 "ltmain.sh",
1283 "m4/*.m4",
1284 "missing",
1285 "protobuf*.pc.in",
1286 "test-driver",
1287 ],
1288 allow_empty = True,
1289 ) + [
1290 "BUILD.bazel",
1291 "CHANGES.txt",
1292 "CMakeLists.txt",
1293 "CONTRIBUTORS.txt",
1294 "LICENSE",
1295 "Makefile.am",
1296 "README.md",
1297 "WORKSPACE",
1298 "autogen.sh",
1299 "build_files_updated_unittest.sh",
1300 "cmake/CMakeLists.txt",
1301 "cmake/README.md",
1302 "generate_descriptor_proto.sh",
1303 "maven_install.json",
1304 "update_file_lists.sh",
1305 "//third_party:BUILD.bazel",
1306 "//third_party:zlib.BUILD",
1307 "//util/python:BUILD.bazel",
1308 ],
1309 strip_prefix = strip_prefix.from_root(""),
1310 visibility = ["//pkg:__pkg__"],
1311)
1312
1313# C++ runtime
1314pkg_files(
1315 name = "cpp_dist_files",
1316 srcs = glob(
1317 ["src/**/*"],
1318 exclude = [
1319 "src/google/protobuf/compiler/objectivec/method_dump.sh", # not in autotools dist
1320 ],
1321 ),
1322 strip_prefix = strip_prefix.from_root(""),
1323 visibility = ["//pkg:__pkg__"],
1324)
1325
1326# Additional files for C#
1327pkg_files(
1328 name = "csharp_dist_files",
1329 srcs = [
1330 "global.json",
1331 ],
1332 visibility = ["//pkg:__pkg__"],
1333)
1334
1335# Additional files for ObjC
1336pkg_files(
1337 name = "objectivec_dist_files",
1338 srcs = [
1339 "Protobuf.podspec",
1340 ],
1341 visibility = ["//pkg:__pkg__"],
1342)
1343
1344# Python runtime
1345pkg_files(
1346 name = "python_dist_files",
1347 srcs = glob([
1348 "python/google/**/*.proto",
1349 "python/google/**/*.py",
1350 "python/google/protobuf/internal/*.cc",
1351 "python/google/protobuf/pyext/*.cc",
1352 "python/google/protobuf/pyext/*.h",
1353 ]) + [
1354 "python/MANIFEST.in",
1355 "python/README.md",
1356 "python/google/protobuf/proto_api.h",
1357 "python/google/protobuf/pyext/README",
1358 "python/google/protobuf/python_protobuf.h",
1359 "python/mox.py",
1360 "python/release.sh",
1361 "python/setup.cfg",
1362 "python/setup.py",
1363 "python/stubout.py",
1364 "python/tox.ini",
1365 ],
1366 strip_prefix = strip_prefix.from_root(""),
1367 visibility = ["//pkg:__pkg__"],
Zi Wangbd4496b2023-09-07 11:55:38 -07001368)