1# Bazel (https://bazel.build/) BUILD file for Protobuf. 2 3load("@bazel_skylib//rules:common_settings.bzl", "string_flag") 4load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library", native_cc_proto_library = "cc_proto_library") 5load("@rules_pkg//:pkg.bzl", "pkg_zip") 6load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_files") 7load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library") 8load("@rules_python//python:defs.bzl", "py_library") 9load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library") 10load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test") 11load(":protobuf_release.bzl", "package_naming") 12licenses(["notice"]) 13 14exports_files(["LICENSE"]) 15 16################################################################################ 17# build configuration 18################################################################################ 19 20################################################################################ 21# ZLIB configuration 22################################################################################ 23 24ZLIB_DEPS = ["@zlib//:zlib"] 25 26################################################################################ 27# Protobuf Runtime Library 28################################################################################ 29 30MSVC_COPTS = [ 31 "/wd4065", # switch statement contains 'default' but no 'case' labels 32 "/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data 33 "/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' 34 "/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data 35 "/wd4305", # 'identifier' : truncation from 'type1' to 'type2' 36 "/wd4307", # 'operator' : integral constant overflow 37 "/wd4309", # 'conversion' : truncation of constant value 38 "/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 39 "/wd4355", # 'this' : used in base member initializer list 40 "/wd4506", # no definition for inline function 'function' 41 "/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning) 42 "/wd4996", # The compiler encountered a deprecated declaration. 43] 44 45COPTS = select({ 46 ":msvc": MSVC_COPTS, 47 "//conditions:default": [ 48 "-DHAVE_ZLIB", 49 "-Woverloaded-virtual", 50 "-Wno-sign-compare", 51 ], 52}) 53 54load(":compiler_config_setting.bzl", "create_compiler_config_setting") 55 56create_compiler_config_setting( 57 name = "msvc", 58 value = "msvc-cl", 59 visibility = [ 60 # Public, but Protobuf only visibility. 61 "//:__subpackages__", 62 ], 63) 64 65# Android NDK builds can specify different crosstool_top flags to choose which 66# STL they use for C++. We need these multiple variants to catch all of those 67# versions of crosstool_top and reliably detect Android. 68# 69# For more info on the various crosstool_tops used by NDK Bazel builds, see: 70# https://docs.bazel.build/versions/master/android-ndk.html#configuring-the-stl 71 72config_setting( 73 name = "android", 74 values = { 75 "crosstool_top": "//external:android/crosstool", 76 }, 77 visibility = [ 78 # Public, but Protobuf only visibility. 79 "//:__subpackages__", 80 ], 81) 82 83config_setting( 84 name = "android-stlport", 85 values = { 86 "crosstool_top": "@androidndk//:toolchain-stlport", 87 }, 88 visibility = [ 89 # Public, but Protobuf only visibility. 90 "//:__subpackages__", 91 ], 92) 93 94config_setting( 95 name = "android-libcpp", 96 values = { 97 "crosstool_top": "@androidndk//:toolchain-libcpp", 98 }, 99 visibility = [ 100 # Public, but Protobuf only visibility. 101 "//:__subpackages__", 102 ], 103) 104 105config_setting( 106 name = "android-gnu-libstdcpp", 107 values = { 108 "crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp", 109 }, 110 visibility = [ 111 # Public, but Protobuf only visibility. 112 "//:__subpackages__", 113 ], 114) 115 116config_setting( 117 name = "android-default", 118 values = { 119 "crosstool_top": "@androidndk//:default_crosstool", 120 }, 121 visibility = [ 122 # Public, but Protobuf only visibility. 123 "//:__subpackages__", 124 ], 125) 126 127# Android and MSVC builds do not need to link in a separate pthread library. 128LINK_OPTS = select({ 129 ":android": [], 130 ":android-stlport": [], 131 ":android-libcpp": [], 132 ":android-gnu-libstdcpp": [], 133 ":android-default": [], 134 ":msvc": [ 135 # Suppress linker warnings about files with no symbols defined. 136 "-ignore:4221", 137 ], 138 "//conditions:default": [ 139 "-lpthread", 140 "-lm", 141 ], 142}) 143 144load( 145 ":protobuf.bzl", 146 "adapt_proto_library", 147 "cc_proto_library", 148 "internal_copied_filegroup", 149 "internal_gen_kt_protos", 150 "internal_gen_well_known_protos_java", 151 "internal_protobuf_py_tests", 152 "py_proto_library", 153) 154 155cc_library( 156 name = "protobuf_lite", 157 srcs = [ 158 # AUTOGEN(protobuf_lite_srcs) 159 "src/google/protobuf/any_lite.cc", 160 "src/google/protobuf/arena.cc", 161 "src/google/protobuf/arenastring.cc", 162 "src/google/protobuf/extension_set.cc", 163 "src/google/protobuf/generated_enum_util.cc", 164 "src/google/protobuf/generated_message_tctable_lite.cc", 165 "src/google/protobuf/generated_message_util.cc", 166 "src/google/protobuf/implicit_weak_message.cc", 167 "src/google/protobuf/inlined_string_field.cc", 168 "src/google/protobuf/io/coded_stream.cc", 169 "src/google/protobuf/io/io_win32.cc", 170 "src/google/protobuf/io/strtod.cc", 171 "src/google/protobuf/io/zero_copy_stream.cc", 172 "src/google/protobuf/io/zero_copy_stream_impl.cc", 173 "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", 174 "src/google/protobuf/map.cc", 175 "src/google/protobuf/message_lite.cc", 176 "src/google/protobuf/parse_context.cc", 177 "src/google/protobuf/repeated_field.cc", 178 "src/google/protobuf/repeated_ptr_field.cc", 179 "src/google/protobuf/stubs/bytestream.cc", 180 "src/google/protobuf/stubs/common.cc", 181 "src/google/protobuf/stubs/int128.cc", 182 "src/google/protobuf/stubs/status.cc", 183 "src/google/protobuf/stubs/statusor.cc", 184 "src/google/protobuf/stubs/stringpiece.cc", 185 "src/google/protobuf/stubs/stringprintf.cc", 186 "src/google/protobuf/stubs/structurally_valid.cc", 187 "src/google/protobuf/stubs/strutil.cc", 188 "src/google/protobuf/stubs/time.cc", 189 "src/google/protobuf/wire_format_lite.cc", 190 ], 191 hdrs = glob([ 192 "src/google/protobuf/**/*.h", 193 "src/google/protobuf/**/*.inc", 194 ]), 195 copts = COPTS, 196 includes = ["src/"], 197 linkopts = LINK_OPTS, 198 visibility = ["//visibility:public"], 199) 200 201PROTOBUF_DEPS = select({ 202 ":msvc": [], 203 "//conditions:default": ZLIB_DEPS, 204}) 205 206cc_library( 207 name = "protobuf", 208 srcs = [ 209 # AUTOGEN(protobuf_srcs) 210 "src/google/protobuf/any.cc", 211 "src/google/protobuf/any.pb.cc", 212 "src/google/protobuf/api.pb.cc", 213 "src/google/protobuf/compiler/importer.cc", 214 "src/google/protobuf/compiler/parser.cc", 215 "src/google/protobuf/descriptor.cc", 216 "src/google/protobuf/descriptor.pb.cc", 217 "src/google/protobuf/descriptor_database.cc", 218 "src/google/protobuf/duration.pb.cc", 219 "src/google/protobuf/dynamic_message.cc", 220 "src/google/protobuf/empty.pb.cc", 221 "src/google/protobuf/extension_set_heavy.cc", 222 "src/google/protobuf/field_mask.pb.cc", 223 "src/google/protobuf/generated_message_bases.cc", 224 "src/google/protobuf/generated_message_reflection.cc", 225 "src/google/protobuf/generated_message_tctable_full.cc", 226 "src/google/protobuf/io/gzip_stream.cc", 227 "src/google/protobuf/io/printer.cc", 228 "src/google/protobuf/io/tokenizer.cc", 229 "src/google/protobuf/map_field.cc", 230 "src/google/protobuf/message.cc", 231 "src/google/protobuf/reflection_ops.cc", 232 "src/google/protobuf/service.cc", 233 "src/google/protobuf/source_context.pb.cc", 234 "src/google/protobuf/struct.pb.cc", 235 "src/google/protobuf/stubs/substitute.cc", 236 "src/google/protobuf/text_format.cc", 237 "src/google/protobuf/timestamp.pb.cc", 238 "src/google/protobuf/type.pb.cc", 239 "src/google/protobuf/unknown_field_set.cc", 240 "src/google/protobuf/util/delimited_message_util.cc", 241 "src/google/protobuf/util/field_comparator.cc", 242 "src/google/protobuf/util/field_mask_util.cc", 243 "src/google/protobuf/util/internal/datapiece.cc", 244 "src/google/protobuf/util/internal/default_value_objectwriter.cc", 245 "src/google/protobuf/util/internal/error_listener.cc", 246 "src/google/protobuf/util/internal/field_mask_utility.cc", 247 "src/google/protobuf/util/internal/json_escaping.cc", 248 "src/google/protobuf/util/internal/json_objectwriter.cc", 249 "src/google/protobuf/util/internal/json_stream_parser.cc", 250 "src/google/protobuf/util/internal/object_writer.cc", 251 "src/google/protobuf/util/internal/proto_writer.cc", 252 "src/google/protobuf/util/internal/protostream_objectsource.cc", 253 "src/google/protobuf/util/internal/protostream_objectwriter.cc", 254 "src/google/protobuf/util/internal/type_info.cc", 255 "src/google/protobuf/util/internal/utility.cc", 256 "src/google/protobuf/util/json_util.cc", 257 "src/google/protobuf/util/message_differencer.cc", 258 "src/google/protobuf/util/time_util.cc", 259 "src/google/protobuf/util/type_resolver_util.cc", 260 "src/google/protobuf/wire_format.cc", 261 "src/google/protobuf/wrappers.pb.cc", 262 ], 263 hdrs = glob([ 264 "src/**/*.h", 265 "src/**/*.inc", 266 ]), 267 copts = COPTS, 268 includes = ["src/"], 269 linkopts = LINK_OPTS, 270 visibility = ["//visibility:public"], 271 deps = [":protobuf_lite"] + PROTOBUF_DEPS, 272) 273 274# This provides just the header files for use in projects that need to build 275# shared libraries for dynamic loading. This target is available until Bazel 276# adds native support for such use cases. 277# TODO(keveman): Remove this target once the support gets added to Bazel. 278cc_library( 279 name = "protobuf_headers", 280 hdrs = glob([ 281 "src/**/*.h", 282 "src/**/*.inc", 283 ]), 284 includes = ["src/"], 285 visibility = ["//visibility:public"], 286) 287 288# Map of all well known protos. 289# name => (include path, imports) 290WELL_KNOWN_PROTO_MAP = { 291 "any": ("src/google/protobuf/any.proto", []), 292 "api": ( 293 "src/google/protobuf/api.proto", 294 [ 295 "source_context", 296 "type", 297 ], 298 ), 299 "compiler_plugin": ( 300 "src/google/protobuf/compiler/plugin.proto", 301 ["descriptor"], 302 ), 303 "descriptor": ("src/google/protobuf/descriptor.proto", []), 304 "duration": ("src/google/protobuf/duration.proto", []), 305 "empty": ("src/google/protobuf/empty.proto", []), 306 "field_mask": ("src/google/protobuf/field_mask.proto", []), 307 "source_context": ("src/google/protobuf/source_context.proto", []), 308 "struct": ("src/google/protobuf/struct.proto", []), 309 "timestamp": ("src/google/protobuf/timestamp.proto", []), 310 "type": ( 311 "src/google/protobuf/type.proto", 312 [ 313 "any", 314 "source_context", 315 ], 316 ), 317 "wrappers": ("src/google/protobuf/wrappers.proto", []), 318} 319 320WELL_KNOWN_PROTOS = [value[0] for value in WELL_KNOWN_PROTO_MAP.values()] 321 322LITE_WELL_KNOWN_PROTO_MAP = { 323 "any": ("src/google/protobuf/any.proto", []), 324 "api": ( 325 "src/google/protobuf/api.proto", 326 [ 327 "source_context", 328 "type", 329 ], 330 ), 331 "duration": ("src/google/protobuf/duration.proto", []), 332 "empty": ("src/google/protobuf/empty.proto", []), 333 "field_mask": ("src/google/protobuf/field_mask.proto", []), 334 "source_context": ("src/google/protobuf/source_context.proto", []), 335 "struct": ("src/google/protobuf/struct.proto", []), 336 "timestamp": ("src/google/protobuf/timestamp.proto", []), 337 "type": ( 338 "src/google/protobuf/type.proto", 339 [ 340 "any", 341 "source_context", 342 ], 343 ), 344 "wrappers": ("src/google/protobuf/wrappers.proto", []), 345} 346 347LITE_WELL_KNOWN_PROTOS = [value[0] for value in LITE_WELL_KNOWN_PROTO_MAP.values()] 348 349filegroup( 350 name = "well_known_protos", 351 srcs = WELL_KNOWN_PROTOS, 352 visibility = ["//visibility:public"], 353) 354 355filegroup( 356 name = "lite_well_known_protos", 357 srcs = LITE_WELL_KNOWN_PROTOS, 358 visibility = ["//visibility:public"], 359) 360 361adapt_proto_library( 362 name = "cc_wkt_protos_genproto", 363 visibility = ["//visibility:public"], 364 deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()], 365) 366 367cc_library( 368 name = "cc_wkt_protos", 369 deprecation = "Only for backward compatibility. Do not use.", 370 visibility = ["//visibility:public"], 371) 372 373################################################################################ 374# Well Known Types Proto Library Rules 375# 376# These proto_library rules can be used with one of the language specific proto 377# library rules i.e. java_proto_library: 378# 379# java_proto_library( 380# name = "any_java_proto", 381# deps = ["@com_google_protobuf//:any_proto], 382# ) 383################################################################################ 384 385[proto_library( 386 name = proto[0] + "_proto", 387 srcs = [proto[1][0]], 388 strip_import_prefix = "src", 389 visibility = ["//visibility:public"], 390 deps = [dep + "_proto" for dep in proto[1][1]], 391) for proto in WELL_KNOWN_PROTO_MAP.items()] 392 393[native_cc_proto_library( 394 name = proto + "_cc_proto", 395 visibility = ["//visibility:private"], 396 deps = [proto + "_proto"], 397) for proto in WELL_KNOWN_PROTO_MAP.keys()] 398 399cc_proto_blacklist_test( 400 name = "cc_proto_blacklist_test", 401 tags = [ 402 # Exclude this target from wildcard expansion (//...). Due to 403 # https://github.com/bazelbuild/bazel/issues/10590, this test has to 404 # be nominated using the `@com_google_protobuf//` prefix. We do that, 405 # e.g., in kokoro/linux/bazel/build.sh. 406 # See also https://github.com/protocolbuffers/protobuf/pull/7096. 407 "manual", 408 ], 409 deps = [proto + "_cc_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()], 410) 411 412################################################################################ 413# Protocol Buffers Compiler 414################################################################################ 415 416cc_library( 417 name = "protoc_lib", 418 srcs = [ 419 # AUTOGEN(protoc_lib_srcs) 420 "src/google/protobuf/compiler/code_generator.cc", 421 "src/google/protobuf/compiler/command_line_interface.cc", 422 "src/google/protobuf/compiler/cpp/cpp_enum.cc", 423 "src/google/protobuf/compiler/cpp/cpp_enum_field.cc", 424 "src/google/protobuf/compiler/cpp/cpp_extension.cc", 425 "src/google/protobuf/compiler/cpp/cpp_field.cc", 426 "src/google/protobuf/compiler/cpp/cpp_file.cc", 427 "src/google/protobuf/compiler/cpp/cpp_generator.cc", 428 "src/google/protobuf/compiler/cpp/cpp_helpers.cc", 429 "src/google/protobuf/compiler/cpp/cpp_map_field.cc", 430 "src/google/protobuf/compiler/cpp/cpp_message.cc", 431 "src/google/protobuf/compiler/cpp/cpp_message_field.cc", 432 "src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc", 433 "src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc", 434 "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc", 435 "src/google/protobuf/compiler/cpp/cpp_service.cc", 436 "src/google/protobuf/compiler/cpp/cpp_string_field.cc", 437 "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc", 438 "src/google/protobuf/compiler/csharp/csharp_enum.cc", 439 "src/google/protobuf/compiler/csharp/csharp_enum_field.cc", 440 "src/google/protobuf/compiler/csharp/csharp_field_base.cc", 441 "src/google/protobuf/compiler/csharp/csharp_generator.cc", 442 "src/google/protobuf/compiler/csharp/csharp_helpers.cc", 443 "src/google/protobuf/compiler/csharp/csharp_map_field.cc", 444 "src/google/protobuf/compiler/csharp/csharp_message.cc", 445 "src/google/protobuf/compiler/csharp/csharp_message_field.cc", 446 "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc", 447 "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc", 448 "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc", 449 "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc", 450 "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc", 451 "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc", 452 "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc", 453 "src/google/protobuf/compiler/java/java_context.cc", 454 "src/google/protobuf/compiler/java/java_doc_comment.cc", 455 "src/google/protobuf/compiler/java/java_enum.cc", 456 "src/google/protobuf/compiler/java/java_enum_field.cc", 457 "src/google/protobuf/compiler/java/java_enum_field_lite.cc", 458 "src/google/protobuf/compiler/java/java_enum_lite.cc", 459 "src/google/protobuf/compiler/java/java_extension.cc", 460 "src/google/protobuf/compiler/java/java_extension_lite.cc", 461 "src/google/protobuf/compiler/java/java_field.cc", 462 "src/google/protobuf/compiler/java/java_file.cc", 463 "src/google/protobuf/compiler/java/java_generator.cc", 464 "src/google/protobuf/compiler/java/java_generator_factory.cc", 465 "src/google/protobuf/compiler/java/java_helpers.cc", 466 "src/google/protobuf/compiler/java/java_kotlin_generator.cc", 467 "src/google/protobuf/compiler/java/java_map_field.cc", 468 "src/google/protobuf/compiler/java/java_map_field_lite.cc", 469 "src/google/protobuf/compiler/java/java_message.cc", 470 "src/google/protobuf/compiler/java/java_message_builder.cc", 471 "src/google/protobuf/compiler/java/java_message_builder_lite.cc", 472 "src/google/protobuf/compiler/java/java_message_field.cc", 473 "src/google/protobuf/compiler/java/java_message_field_lite.cc", 474 "src/google/protobuf/compiler/java/java_message_lite.cc", 475 "src/google/protobuf/compiler/java/java_name_resolver.cc", 476 "src/google/protobuf/compiler/java/java_primitive_field.cc", 477 "src/google/protobuf/compiler/java/java_primitive_field_lite.cc", 478 "src/google/protobuf/compiler/java/java_service.cc", 479 "src/google/protobuf/compiler/java/java_shared_code_generator.cc", 480 "src/google/protobuf/compiler/java/java_string_field.cc", 481 "src/google/protobuf/compiler/java/java_string_field_lite.cc", 482 "src/google/protobuf/compiler/js/js_generator.cc", 483 "src/google/protobuf/compiler/js/well_known_types_embed.cc", 484 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", 485 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", 486 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", 487 "src/google/protobuf/compiler/objectivec/objectivec_field.cc", 488 "src/google/protobuf/compiler/objectivec/objectivec_file.cc", 489 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc", 490 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc", 491 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc", 492 "src/google/protobuf/compiler/objectivec/objectivec_message.cc", 493 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc", 494 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc", 495 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", 496 "src/google/protobuf/compiler/php/php_generator.cc", 497 "src/google/protobuf/compiler/plugin.cc", 498 "src/google/protobuf/compiler/plugin.pb.cc", 499 "src/google/protobuf/compiler/python/python_generator.cc", 500 "src/google/protobuf/compiler/python/python_helpers.cc", 501 "src/google/protobuf/compiler/python/python_pyi_generator.cc", 502 "src/google/protobuf/compiler/ruby/ruby_generator.cc", 503 "src/google/protobuf/compiler/subprocess.cc", 504 "src/google/protobuf/compiler/zip_writer.cc", 505 ], 506 copts = COPTS, 507 includes = ["src/"], 508 linkopts = LINK_OPTS, 509 visibility = ["//visibility:public"], 510 deps = [":protobuf"], 511) 512 513cc_binary( 514 name = "protoc", 515 srcs = ["src/google/protobuf/compiler/main.cc"], 516 linkopts = LINK_OPTS, 517 visibility = ["//visibility:public"], 518 deps = [":protoc_lib"], 519) 520 521 522################################################################################ 523# Generates protoc release artifacts. 524################################################################################ 525 526genrule( 527 name = "protoc_readme", 528 visibility = ["//visibility:private"], 529 cmd = """ 530echo "Protocol Buffers - Google's data interchange format 531Copyright 2008 Google Inc. 532https://developers.google.com/protocol-buffers/ 533This package contains a precompiled binary version of the protocol buffer 534compiler (protoc). This binary is intended for users who want to use Protocol 535Buffers in languages other than C++ but do not want to compile protoc 536themselves. To install, simply place this binary somewhere in your PATH. 537If you intend to use the included well known types then don't forget to 538copy the contents of the 'include' directory somewhere as well, for example 539into '/usr/local/include/'. 540Please refer to our official github site for more installation instructions: 541 https://github.com/protocolbuffers/protobuf" > $@ 542 """, 543 outs = ["readme.txt"], 544) 545 546# plugin.proto is excluded from this list because it belongs in a nested folder (protobuf/compiler/plugin.proto) 547pkg_files( 548 name = "wkt_protos_files", 549 srcs = [value[0] for value in WELL_KNOWN_PROTO_MAP.values() if not value[0].endswith("plugin.proto")], 550 visibility = ["//visibility:private"], 551 prefix = "include/google/protobuf", 552) 553 554pkg_files( 555 name = "compiler_plugin_protos_files", 556 srcs = ["src/google/protobuf/compiler/plugin.proto"], 557 visibility = ["//visibility:private"], 558 prefix = "include/google/protobuf/compiler", 559) 560 561pkg_files( 562 name = "protoc_files", 563 srcs = [":protoc"], 564 attributes = pkg_attributes(mode = "0555"), 565 visibility = ["//visibility:private"], 566 prefix = "bin/", 567) 568 569package_naming( 570 name = "protoc_pkg_naming", 571) 572 573pkg_zip( 574 name = "protoc_release", 575 package_file_name = "protoc-{version}-{platform}.zip", 576 package_variables = ":protoc_pkg_naming", 577 srcs = [ 578 ":protoc_files", 579 ":wkt_protos_files", 580 ":compiler_plugin_protos_files", 581 "readme.txt", 582 ], 583) 584 585################################################################################ 586# Tests 587################################################################################ 588 589filegroup( 590 name = "testdata", 591 srcs = glob(["src/google/protobuf/testdata/**/*"]), 592 visibility = ["//:__subpackages__"], 593) 594 595RELATIVE_LITE_TEST_PROTOS = [ 596 # AUTOGEN(lite_test_protos) 597 "google/protobuf/map_lite_unittest.proto", 598 "google/protobuf/unittest_import_lite.proto", 599 "google/protobuf/unittest_import_public_lite.proto", 600 "google/protobuf/unittest_lite.proto", 601] 602 603LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS] 604 605RELATIVE_TEST_PROTOS = [ 606 # AUTOGEN(test_protos) 607 "google/protobuf/any_test.proto", 608 "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto", 609 "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto", 610 "google/protobuf/map_proto2_unittest.proto", 611 "google/protobuf/map_unittest.proto", 612 "google/protobuf/unittest.proto", 613 "google/protobuf/unittest_arena.proto", 614 "google/protobuf/unittest_custom_options.proto", 615 "google/protobuf/unittest_drop_unknown_fields.proto", 616 "google/protobuf/unittest_embed_optimize_for.proto", 617 "google/protobuf/unittest_empty.proto", 618 "google/protobuf/unittest_enormous_descriptor.proto", 619 "google/protobuf/unittest_import.proto", 620 "google/protobuf/unittest_import_public.proto", 621 "google/protobuf/unittest_lazy_dependencies.proto", 622 "google/protobuf/unittest_lazy_dependencies_custom_option.proto", 623 "google/protobuf/unittest_lazy_dependencies_enum.proto", 624 "google/protobuf/unittest_lite_imports_nonlite.proto", 625 "google/protobuf/unittest_mset.proto", 626 "google/protobuf/unittest_mset_wire_format.proto", 627 "google/protobuf/unittest_no_field_presence.proto", 628 "google/protobuf/unittest_no_generic_services.proto", 629 "google/protobuf/unittest_optimize_for.proto", 630 "google/protobuf/unittest_preserve_unknown_enum.proto", 631 "google/protobuf/unittest_preserve_unknown_enum2.proto", 632 "google/protobuf/unittest_proto3.proto", 633 "google/protobuf/unittest_proto3_arena.proto", 634 "google/protobuf/unittest_proto3_arena_lite.proto", 635 "google/protobuf/unittest_proto3_lite.proto", 636 "google/protobuf/unittest_proto3_optional.proto", 637 "google/protobuf/unittest_well_known_types.proto", 638 "google/protobuf/util/internal/testdata/anys.proto", 639 "google/protobuf/util/internal/testdata/books.proto", 640 "google/protobuf/util/internal/testdata/default_value.proto", 641 "google/protobuf/util/internal/testdata/default_value_test.proto", 642 "google/protobuf/util/internal/testdata/field_mask.proto", 643 "google/protobuf/util/internal/testdata/maps.proto", 644 "google/protobuf/util/internal/testdata/oneofs.proto", 645 "google/protobuf/util/internal/testdata/proto3.proto", 646 "google/protobuf/util/internal/testdata/struct.proto", 647 "google/protobuf/util/internal/testdata/timestamp_duration.proto", 648 "google/protobuf/util/internal/testdata/wrappers.proto", 649 "google/protobuf/util/json_format.proto", 650 "google/protobuf/util/json_format_proto3.proto", 651 "google/protobuf/util/message_differencer_unittest.proto", 652] 653 654TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS] 655 656GENERIC_RELATIVE_TEST_PROTOS = [ 657 "google/protobuf/map_proto2_unittest.proto", 658 "google/protobuf/map_unittest.proto", 659 "google/protobuf/unittest.proto", 660 "google/protobuf/unittest_arena.proto", 661 "google/protobuf/unittest_custom_options.proto", 662 "google/protobuf/unittest_drop_unknown_fields.proto", 663 "google/protobuf/unittest_embed_optimize_for.proto", 664 "google/protobuf/unittest_empty.proto", 665 "google/protobuf/unittest_enormous_descriptor.proto", 666 "google/protobuf/unittest_import.proto", 667 "google/protobuf/unittest_import_public.proto", 668 "google/protobuf/unittest_lazy_dependencies.proto", 669 "google/protobuf/unittest_lazy_dependencies_custom_option.proto", 670 "google/protobuf/unittest_lazy_dependencies_enum.proto", 671 "google/protobuf/unittest_lite_imports_nonlite.proto", 672 "google/protobuf/unittest_mset.proto", 673 "google/protobuf/unittest_mset_wire_format.proto", 674 "google/protobuf/unittest_no_field_presence.proto", 675 "google/protobuf/unittest_no_generic_services.proto", 676 "google/protobuf/unittest_optimize_for.proto", 677 "google/protobuf/unittest_preserve_unknown_enum.proto", 678 "google/protobuf/unittest_preserve_unknown_enum2.proto", 679 "google/protobuf/unittest_proto3.proto", 680 "google/protobuf/unittest_proto3_arena.proto", 681 "google/protobuf/unittest_proto3_arena_lite.proto", 682 "google/protobuf/unittest_proto3_lite.proto", 683 "google/protobuf/unittest_proto3_optional.proto", 684 "google/protobuf/unittest_well_known_types.proto", 685] 686 687GENERIC_TEST_PROTOS = ["src/" + s for s in GENERIC_RELATIVE_TEST_PROTOS] 688 689proto_library( 690 name = "generic_test_protos", 691 srcs = LITE_TEST_PROTOS + GENERIC_TEST_PROTOS, 692 strip_import_prefix = "src", 693 visibility = ["//:__subpackages__"], 694 deps = [ 695 "//:any_proto", 696 "//:api_proto", 697 "//:descriptor_proto", 698 "//:duration_proto", 699 "//:empty_proto", 700 "//:field_mask_proto", 701 "//:source_context_proto", 702 "//:struct_proto", 703 "//:timestamp_proto", 704 "//:type_proto", 705 "//:wrappers_proto", 706 ], 707) 708 709cc_proto_library( 710 name = "cc_test_protos", 711 srcs = LITE_TEST_PROTOS + TEST_PROTOS, 712 include = "src", 713 default_runtime = ":protobuf", 714 protoc = ":protoc", 715 deps = [":cc_wkt_protos"], 716) 717 718COMMON_TEST_SRCS = [ 719 # AUTOGEN(common_test_srcs) 720 "src/google/protobuf/arena_test_util.cc", 721 "src/google/protobuf/map_lite_test_util.cc", 722 "src/google/protobuf/test_util_lite.cc", 723 "src/google/protobuf/map_test_util.inc", 724 "src/google/protobuf/reflection_tester.cc", 725 "src/google/protobuf/test_util.cc", 726 "src/google/protobuf/test_util.inc", 727 "src/google/protobuf/testing/file.cc", 728 "src/google/protobuf/testing/googletest.cc", 729] 730 731cc_binary( 732 name = "test_plugin", 733 testonly = True, 734 srcs = [ 735 # AUTOGEN(test_plugin_srcs) 736 "src/google/protobuf/compiler/mock_code_generator.cc", 737 "src/google/protobuf/compiler/test_plugin.cc", 738 "src/google/protobuf/testing/file.cc", 739 ], 740 deps = [ 741 ":protobuf", 742 ":protoc_lib", 743 "@com_google_googletest//:gtest", 744 ], 745) 746 747cc_test( 748 name = "win32_test", 749 srcs = ["src/google/protobuf/io/io_win32_unittest.cc"], 750 tags = [ 751 "manual", 752 "windows", 753 ], 754 deps = [ 755 ":protobuf_lite", 756 "@com_google_googletest//:gtest", 757 "@com_google_googletest//:gtest_main", 758 ], 759) 760 761cc_test( 762 name = "protobuf_test", 763 srcs = COMMON_TEST_SRCS + [ 764 # AUTOGEN(test_srcs) 765 "src/google/protobuf/any_test.cc", 766 "src/google/protobuf/arena_unittest.cc", 767 "src/google/protobuf/arenastring_unittest.cc", 768 "src/google/protobuf/compiler/annotation_test_util.cc", 769 "src/google/protobuf/compiler/command_line_interface_unittest.cc", 770 "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc", 771 "src/google/protobuf/compiler/cpp/cpp_move_unittest.cc", 772 "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc", 773 "src/google/protobuf/compiler/cpp/cpp_unittest.cc", 774 "src/google/protobuf/compiler/cpp/cpp_unittest.inc", 775 "src/google/protobuf/compiler/cpp/metadata_test.cc", 776 "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc", 777 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc", 778 "src/google/protobuf/compiler/importer_unittest.cc", 779 "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc", 780 "src/google/protobuf/compiler/java/java_plugin_unittest.cc", 781 "src/google/protobuf/compiler/mock_code_generator.cc", 782 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc", 783 "src/google/protobuf/compiler/parser_unittest.cc", 784 "src/google/protobuf/compiler/python/python_plugin_unittest.cc", 785 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc", 786 "src/google/protobuf/descriptor_database_unittest.cc", 787 "src/google/protobuf/descriptor_unittest.cc", 788 "src/google/protobuf/drop_unknown_fields_test.cc", 789 "src/google/protobuf/dynamic_message_unittest.cc", 790 "src/google/protobuf/extension_set_unittest.cc", 791 "src/google/protobuf/generated_message_reflection_unittest.cc", 792 "src/google/protobuf/inlined_string_field_unittest.cc", 793 "src/google/protobuf/io/coded_stream_unittest.cc", 794 "src/google/protobuf/io/io_win32_unittest.cc", 795 "src/google/protobuf/io/printer_unittest.cc", 796 "src/google/protobuf/io/tokenizer_unittest.cc", 797 "src/google/protobuf/io/zero_copy_stream_unittest.cc", 798 "src/google/protobuf/map_field_test.cc", 799 "src/google/protobuf/map_test.cc", 800 "src/google/protobuf/map_test.inc", 801 "src/google/protobuf/message_unittest.cc", 802 "src/google/protobuf/message_unittest.inc", 803 "src/google/protobuf/no_field_presence_test.cc", 804 "src/google/protobuf/preserve_unknown_enum_test.cc", 805 "src/google/protobuf/proto3_arena_lite_unittest.cc", 806 "src/google/protobuf/proto3_arena_unittest.cc", 807 "src/google/protobuf/proto3_lite_unittest.cc", 808 "src/google/protobuf/proto3_lite_unittest.inc", 809 "src/google/protobuf/reflection_ops_unittest.cc", 810 "src/google/protobuf/repeated_field_reflection_unittest.cc", 811 "src/google/protobuf/repeated_field_unittest.cc", 812 "src/google/protobuf/stubs/bytestream_unittest.cc", 813 "src/google/protobuf/stubs/common_unittest.cc", 814 "src/google/protobuf/stubs/int128_unittest.cc", 815 "src/google/protobuf/stubs/status_test.cc", 816 "src/google/protobuf/stubs/statusor_test.cc", 817 "src/google/protobuf/stubs/stringpiece_unittest.cc", 818 "src/google/protobuf/stubs/stringprintf_unittest.cc", 819 "src/google/protobuf/stubs/structurally_valid_unittest.cc", 820 "src/google/protobuf/stubs/strutil_unittest.cc", 821 "src/google/protobuf/stubs/template_util_unittest.cc", 822 "src/google/protobuf/stubs/time_test.cc", 823 "src/google/protobuf/text_format_unittest.cc", 824 "src/google/protobuf/unknown_field_set_unittest.cc", 825 "src/google/protobuf/util/delimited_message_util_test.cc", 826 "src/google/protobuf/util/field_comparator_test.cc", 827 "src/google/protobuf/util/field_mask_util_test.cc", 828 "src/google/protobuf/util/internal/default_value_objectwriter_test.cc", 829 "src/google/protobuf/util/internal/json_objectwriter_test.cc", 830 "src/google/protobuf/util/internal/json_stream_parser_test.cc", 831 "src/google/protobuf/util/internal/protostream_objectsource_test.cc", 832 "src/google/protobuf/util/internal/protostream_objectwriter_test.cc", 833 "src/google/protobuf/util/internal/type_info_test_helper.cc", 834 "src/google/protobuf/util/json_util_test.cc", 835 "src/google/protobuf/util/message_differencer_unittest.cc", 836 "src/google/protobuf/util/time_util_test.cc", 837 "src/google/protobuf/util/type_resolver_util_test.cc", 838 "src/google/protobuf/well_known_types_unittest.cc", 839 "src/google/protobuf/wire_format_unittest.cc", 840 "src/google/protobuf/wire_format_unittest.inc", 841 ] + select({ 842 "//conditions:default": [ 843 # AUTOGEN(non_msvc_test_srcs) 844 ], 845 ":msvc": [], 846 }), 847 copts = COPTS + select({ 848 ":msvc": [], 849 "//conditions:default": [ 850 "-Wno-deprecated-declarations", 851 ], 852 }), 853 data = [ 854 ":test_plugin", 855 ] + glob([ 856 "src/google/protobuf/**/*", 857 # Files for csharp_bootstrap_unittest.cc. 858 "conformance/**/*", 859 "csharp/src/**/*", 860 ]), 861 includes = [ 862 "src/", 863 ], 864 linkopts = LINK_OPTS, 865 deps = [ 866 ":cc_test_protos", 867 ":protobuf", 868 ":protoc_lib", 869 "@com_google_googletest//:gtest", 870 "@com_google_googletest//:gtest_main", 871 ] + PROTOBUF_DEPS, 872) 873 874################################################################################ 875# Java support 876################################################################################ 877 878internal_gen_well_known_protos_java( 879 name = "gen_well_known_protos_java", 880 visibility = [ 881 "//java:__subpackages__", 882 ], 883 deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()], 884) 885 886internal_gen_well_known_protos_java( 887 name = "gen_well_known_protos_javalite", 888 javalite = True, 889 visibility = [ 890 "//java:__subpackages__", 891 ], 892 deps = [proto + "_proto" for proto in LITE_WELL_KNOWN_PROTO_MAP.keys()], 893) 894 895internal_gen_kt_protos( 896 name = "gen_well_known_protos_kotlin", 897 visibility = [ 898 "//java:__subpackages__", 899 ], 900 deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()], 901) 902 903internal_gen_kt_protos( 904 name = "gen_well_known_protos_kotlinlite", 905 visibility = [ 906 "//java:__subpackages__", 907 ], 908 lite = True, 909 deps = [proto + "_proto" for proto in LITE_WELL_KNOWN_PROTO_MAP.keys()], 910) 911 912alias( 913 name = "protobuf_java", 914 actual = "//java/core", 915 visibility = ["//visibility:public"], 916) 917 918alias( 919 name = "protobuf_javalite", 920 actual = "//java/lite", 921 visibility = ["//visibility:public"], 922) 923 924alias( 925 name = "protobuf_java_util", 926 actual = "//java/util", 927 visibility = ["//visibility:public"], 928) 929 930alias( 931 name = "java_toolchain", 932 actual = "//java/core:toolchain", 933 visibility = ["//visibility:public"], 934) 935 936alias( 937 name = "javalite_toolchain", 938 actual = "//java/lite:toolchain", 939 visibility = ["//visibility:public"], 940) 941 942################################################################################ 943# Python support 944################################################################################ 945 946py_library( 947 name = "python_srcs", 948 srcs = glob( 949 [ 950 "python/google/protobuf/**/*.py", 951 ], 952 exclude = [ 953 "python/google/protobuf/internal/*_test.py", 954 "python/google/protobuf/internal/test_util.py", 955 ], 956 ), 957 imports = ["python"], 958 srcs_version = "PY2AND3", 959) 960 961cc_binary( 962 name = "python/google/protobuf/internal/_api_implementation.so", 963 srcs = ["python/google/protobuf/internal/api_implementation.cc"], 964 copts = COPTS + [ 965 "-DPYTHON_PROTO2_CPP_IMPL_V2", 966 ], 967 linkshared = 1, 968 linkstatic = 1, 969 tags = [ 970 # Exclude this target from wildcard expansion (//...) because it may 971 # not even be buildable. It will be built if it is needed according 972 # to :use_fast_cpp_protos. 973 # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes 974 "manual", 975 ], 976 deps = select({ 977 "//conditions:default": [], 978 ":use_fast_cpp_protos": ["//external:python_headers"], 979 }), 980) 981 982cc_binary( 983 name = "python/google/protobuf/pyext/_message.so", 984 srcs = glob([ 985 "python/google/protobuf/pyext/*.cc", 986 "python/google/protobuf/pyext/*.h", 987 ]), 988 copts = COPTS + [ 989 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1", 990 ] + select({ 991 "//conditions:default": [], 992 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"], 993 }), 994 includes = [ 995 "python/", 996 "src/", 997 ], 998 linkshared = 1, 999 linkstatic = 1, 1000 tags = [ 1001 # Exclude this target from wildcard expansion (//...) because it may 1002 # not even be buildable. It will be built if it is needed according 1003 # to :use_fast_cpp_protos. 1004 # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes 1005 "manual", 1006 ], 1007 deps = [ 1008 ":protobuf", 1009 ":proto_api", 1010 ] + select({ 1011 "//conditions:default": [], 1012 ":use_fast_cpp_protos": ["//external:python_headers"], 1013 }), 1014) 1015 1016config_setting( 1017 name = "use_fast_cpp_protos", 1018 values = { 1019 "define": "use_fast_cpp_protos=true", 1020 }, 1021 visibility = [ 1022 # Public, but Protobuf only visibility. 1023 "//:__subpackages__", 1024 ], 1025) 1026 1027config_setting( 1028 name = "allow_oversize_protos", 1029 values = { 1030 "define": "allow_oversize_protos=true", 1031 }, 1032 visibility = [ 1033 # Public, but Protobuf only visibility. 1034 "//:__subpackages__", 1035 ], 1036) 1037 1038# Copy the builtin proto files from src/google/protobuf to 1039# python/google/protobuf. This way, the generated Python sources will be in the 1040# same directory as the Python runtime sources. This is necessary for the 1041# modules to be imported correctly since they are all part of the same Python 1042# package. 1043internal_copied_filegroup( 1044 name = "protos_python", 1045 srcs = WELL_KNOWN_PROTOS, 1046 dest = "python", 1047 strip_prefix = "src", 1048) 1049 1050# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in 1051# which case we can simply add :protos_python in srcs. 1052COPIED_WELL_KNOWN_PROTOS = ["python/" + s[4:] for s in WELL_KNOWN_PROTOS] 1053 1054py_proto_library( 1055 name = "protobuf_python", 1056 srcs = COPIED_WELL_KNOWN_PROTOS, 1057 include = "python", 1058 data = select({ 1059 "//conditions:default": [], 1060 ":use_fast_cpp_protos": [ 1061 ":python/google/protobuf/internal/_api_implementation.so", 1062 ":python/google/protobuf/pyext/_message.so", 1063 ], 1064 }), 1065 default_runtime = "", 1066 protoc = ":protoc", 1067 py_libs = [ 1068 ":python_srcs", 1069 ], 1070 srcs_version = "PY2AND3", 1071 visibility = ["//visibility:public"], 1072) 1073 1074# Copy the test proto files from src/google/protobuf to 1075# python/google/protobuf. This way, the generated Python sources will be in the 1076# same directory as the Python runtime sources. This is necessary for the 1077# modules to be imported correctly by the tests since they are all part of the 1078# same Python package. 1079internal_copied_filegroup( 1080 name = "protos_python_test", 1081 srcs = LITE_TEST_PROTOS + TEST_PROTOS, 1082 dest = "python", 1083 strip_prefix = "src", 1084) 1085 1086# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in 1087# which case we can simply add :protos_python_test in srcs. 1088COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS] 1089 1090COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS] 1091 1092py_proto_library( 1093 name = "python_common_test_protos", 1094 srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS, 1095 include = "python", 1096 default_runtime = "", 1097 protoc = ":protoc", 1098 srcs_version = "PY2AND3", 1099 deps = [":protobuf_python"], 1100) 1101 1102py_proto_library( 1103 name = "python_specific_test_protos", 1104 srcs = glob([ 1105 "python/google/protobuf/internal/*.proto", 1106 "python/google/protobuf/internal/import_test_package/*.proto", 1107 ]), 1108 include = "python", 1109 default_runtime = ":protobuf_python", 1110 protoc = ":protoc", 1111 srcs_version = "PY2AND3", 1112 deps = [":python_common_test_protos"], 1113) 1114 1115py_library( 1116 name = "python_tests", 1117 srcs = glob( 1118 [ 1119 "python/google/protobuf/internal/*_test.py", 1120 "python/google/protobuf/internal/test_util.py", 1121 "python/google/protobuf/internal/import_test_package/__init__.py", 1122 ], 1123 ), 1124 imports = ["python"], 1125 srcs_version = "PY2AND3", 1126 deps = [ 1127 ":protobuf_python", 1128 ":python_common_test_protos", 1129 ":python_specific_test_protos", 1130 ], 1131) 1132 1133internal_protobuf_py_tests( 1134 name = "python_tests_batch", 1135 data = glob([ 1136 "src/google/protobuf/**/*", 1137 ]), 1138 modules = [ 1139 "descriptor_database_test", 1140 "descriptor_pool_test", 1141 "descriptor_test", 1142 "generator_test", 1143 "json_format_test", 1144 "message_factory_test", 1145 "message_test", 1146 "proto_builder_test", 1147 "reflection_test", 1148 "service_reflection_test", 1149 "symbol_database_test", 1150 "text_encoding_test", 1151 "text_format_test", 1152 "unknown_fields_test", 1153 "wire_format_test", 1154 ], 1155 deps = [":python_tests"], 1156) 1157 1158cc_library( 1159 name = "proto_api", 1160 hdrs = ["python/google/protobuf/proto_api.h"], 1161 visibility = ["//visibility:public"], 1162 deps = [ 1163 "//external:python_headers", 1164 ], 1165) 1166 1167proto_lang_toolchain( 1168 name = "cc_toolchain", 1169 blacklisted_protos = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()], 1170 command_line = "--cpp_out=$(OUT)", 1171 runtime = ":protobuf", 1172 visibility = ["//visibility:public"], 1173) 1174 1175alias( 1176 name = "objectivec", 1177 actual = "//objectivec", 1178 visibility = ["//visibility:public"], 1179) 1180 1181alias( 1182 name = "protobuf_objc", 1183 actual = "//objectivec", 1184 visibility = ["//visibility:public"], 1185) 1186 1187################################################################################ 1188# Test generated proto support 1189################################################################################ 1190 1191genrule( 1192 name = "generated_protos", 1193 srcs = ["src/google/protobuf/unittest_import.proto"], 1194 outs = ["unittest_gen.proto"], 1195 cmd = "cat $(SRCS) | sed 's|google/|src/google/|' > $(OUTS)", 1196) 1197 1198proto_library( 1199 name = "generated_protos_proto", 1200 srcs = [ 1201 "src/google/protobuf/unittest_import_public.proto", 1202 "unittest_gen_import.proto", 1203 ], 1204) 1205 1206py_proto_library( 1207 name = "generated_protos_py", 1208 srcs = [ 1209 "src/google/protobuf/unittest_import_public.proto", 1210 "unittest_gen_import.proto", 1211 ], 1212 default_runtime = "", 1213 protoc = ":protoc", 1214) 1215 1216################################################################################ 1217# Conformance tests 1218################################################################################ 1219 1220proto_library( 1221 name = "test_messages_proto2_proto", 1222 srcs = ["src/google/protobuf/test_messages_proto2.proto"], 1223 visibility = ["//visibility:public"], 1224) 1225 1226proto_library( 1227 name = "test_messages_proto3_proto", 1228 srcs = ["src/google/protobuf/test_messages_proto3.proto"], 1229 visibility = ["//visibility:public"], 1230 deps = [ 1231 ":any_proto", 1232 ":duration_proto", 1233 ":field_mask_proto", 1234 ":struct_proto", 1235 ":timestamp_proto", 1236 ":wrappers_proto", 1237 ], 1238) 1239 1240cc_proto_library( 1241 name = "test_messages_proto2_proto_cc", 1242 srcs = ["src/google/protobuf/test_messages_proto2.proto"], 1243) 1244 1245cc_proto_library( 1246 name = "test_messages_proto3_proto_cc", 1247 srcs = ["src/google/protobuf/test_messages_proto3.proto"], 1248 deps = [ 1249 ":cc_wkt_protos", 1250 ], 1251) 1252 1253proto_library( 1254 name = "conformance_proto", 1255 srcs = ["conformance/conformance.proto"], 1256 visibility = ["//visibility:public"], 1257) 1258 1259cc_proto_library( 1260 name = "conformance_proto_cc", 1261 srcs = ["conformance/conformance.proto"], 1262) 1263 1264cc_library( 1265 name = "jsoncpp", 1266 srcs = ["conformance/third_party/jsoncpp/jsoncpp.cpp"], 1267 hdrs = ["conformance/third_party/jsoncpp/json.h"], 1268 includes = ["conformance"], 1269) 1270 1271cc_library( 1272 name = "conformance_test", 1273 srcs = [ 1274 "conformance/conformance_test.cc", 1275 "conformance/conformance_test_runner.cc", 1276 ], 1277 hdrs = [ 1278 "conformance/conformance_test.h", 1279 ], 1280 includes = [ 1281 "conformance", 1282 "src", 1283 ], 1284 deps = [":conformance_proto_cc"], 1285) 1286 1287cc_library( 1288 name = "binary_json_conformance_suite", 1289 srcs = ["conformance/binary_json_conformance_suite.cc"], 1290 hdrs = ["conformance/binary_json_conformance_suite.h"], 1291 deps = [ 1292 ":conformance_test", 1293 ":jsoncpp", 1294 ":test_messages_proto2_proto_cc", 1295 ":test_messages_proto3_proto_cc", 1296 ], 1297) 1298 1299cc_library( 1300 name = "text_format_conformance_suite", 1301 srcs = ["conformance/text_format_conformance_suite.cc"], 1302 hdrs = ["conformance/text_format_conformance_suite.h"], 1303 deps = [ 1304 ":conformance_test", 1305 ":test_messages_proto2_proto_cc", 1306 ":test_messages_proto3_proto_cc", 1307 ], 1308) 1309 1310cc_binary( 1311 name = "conformance_test_runner", 1312 srcs = ["conformance/conformance_test_main.cc"], 1313 visibility = ["//visibility:public"], 1314 deps = [ 1315 ":binary_json_conformance_suite", 1316 ":conformance_test", 1317 ":text_format_conformance_suite", 1318 ], 1319) 1320 1321# TODO: re-enable this test if appropriate, or replace with something that 1322# uses the new setup. 1323# sh_test( 1324# name = "build_files_updated_unittest", 1325# srcs = [ 1326# "build_files_updated_unittest.sh", 1327# ], 1328# data = [ 1329# "BUILD", 1330# "cmake/extract_includes.bat.in", 1331# "cmake/libprotobuf.cmake", 1332# "cmake/libprotobuf-lite.cmake", 1333# "cmake/libprotoc.cmake", 1334# "cmake/tests.cmake", 1335# "src/Makefile.am", 1336# "update_file_lists.sh", 1337# ], 1338# ) 1339 1340 1341java_proto_library( 1342 name = "java_test_protos", 1343 deps = [":generic_test_protos"], 1344 visibility = ["//java:__subpackages__"], 1345) 1346 1347java_lite_proto_library( 1348 name = "java_lite_test_protos", 1349 deps = [":generic_test_protos"], 1350 visibility = ["//java:__subpackages__"], 1351) 1352 1353java_proto_library( 1354 name = "test_messages_proto2_java_proto", 1355 visibility = [ 1356 "//java:__subpackages__", 1357 ], 1358 deps = [":test_messages_proto2_proto"], 1359) 1360 1361java_proto_library( 1362 name = "test_messages_proto3_java_proto", 1363 visibility = [ 1364 "//java:__subpackages__", 1365 ], 1366 deps = [":test_messages_proto3_proto"], 1367) 1368 1369java_proto_library( 1370 name = "conformance_java_proto", 1371 visibility = [ 1372 "//java:__subpackages__", 1373 ], 1374 deps = [":conformance_proto"], 1375) 1376 1377java_lite_proto_library( 1378 name = "test_messages_proto2_java_proto_lite", 1379 visibility = [ 1380 "//java:__subpackages__", 1381 ], 1382 deps = [":test_messages_proto2_proto"], 1383) 1384 1385java_lite_proto_library( 1386 name = "conformance_java_proto_lite", 1387 visibility = [ 1388 "//java:__subpackages__", 1389 ], 1390 deps = [":conformance_proto"], 1391) 1392 1393java_lite_proto_library( 1394 name = "test_messages_proto3_java_proto_lite", 1395 visibility = [ 1396 "//java:__subpackages__", 1397 ], 1398 deps = [":test_messages_proto3_proto"], 1399) 1400 1401java_binary( 1402 name = "conformance_java", 1403 srcs = ["conformance/ConformanceJava.java"], 1404 main_class = "ConformanceJava", 1405 visibility = [ 1406 "//java:__subpackages__", 1407 ], 1408 deps = [ 1409 ":conformance_java_proto", 1410 ":test_messages_proto2_java_proto", 1411 ":test_messages_proto3_java_proto", 1412 "//:protobuf_java", 1413 "//:protobuf_java_util", 1414 ], 1415) 1416 1417java_binary( 1418 name = "conformance_java_lite", 1419 srcs = ["conformance/ConformanceJavaLite.java"], 1420 main_class = "ConformanceJavaLite", 1421 visibility = [ 1422 "//java:__subpackages__", 1423 ], 1424 deps = [ 1425 ":conformance_java_proto_lite", 1426 ":test_messages_proto2_java_proto_lite", 1427 ":test_messages_proto3_java_proto_lite", 1428 "//:protobuf_java_util", 1429 "//:protobuf_javalite", 1430 ], 1431) 1432 1433exports_files([ 1434 "conformance/conformance_test_runner.sh", 1435 "conformance/failure_list_java.txt", 1436 "conformance/failure_list_java_lite.txt", 1437 "conformance/text_format_failure_list_java.txt", 1438 "conformance/text_format_failure_list_java_lite.txt", 1439]) 1440 1441filegroup( 1442 name = "bzl_srcs", 1443 srcs = glob(["**/*.bzl"]), 1444 visibility = ["//visibility:public"], 1445) 1446 1447# Kotlin proto rules 1448 1449proto_library( 1450 name = "kt_unittest_lite", 1451 srcs = [ 1452 "src/google/protobuf/unittest_lite.proto", 1453 "src/google/protobuf/unittest_import_lite.proto", 1454 "src/google/protobuf/unittest_import_public_lite.proto", 1455 "src/google/protobuf/map_lite_unittest.proto", 1456 ], 1457 strip_import_prefix = "src", 1458) 1459 1460internal_gen_kt_protos( 1461 name = "gen_kotlin_unittest_lite", 1462 deps = [":kt_unittest_lite"], 1463 lite = True, 1464 visibility = ["//java:__subpackages__"], 1465) 1466 1467proto_library( 1468 name = "kt_unittest", 1469 srcs = [ 1470 "src/google/protobuf/unittest.proto", 1471 "src/google/protobuf/unittest_import.proto", 1472 "src/google/protobuf/unittest_import_public.proto", 1473 "src/google/protobuf/map_proto2_unittest.proto", 1474 ], 1475 strip_import_prefix = "src", 1476) 1477 1478internal_gen_kt_protos( 1479 name = "gen_kotlin_unittest", 1480 deps = [":kt_unittest"], 1481 visibility = ["//java:__subpackages__"], 1482) 1483 1484proto_library( 1485 name = "kt_proto3_unittest", 1486 srcs = [ 1487 "src/google/protobuf/unittest_proto3.proto", 1488 "src/google/protobuf/unittest_import.proto", 1489 "src/google/protobuf/unittest_import_public.proto", 1490 ], 1491 strip_import_prefix = "src", 1492) 1493 1494internal_gen_kt_protos( 1495 name = "gen_kotlin_proto3_unittest_lite", 1496 deps = [":kt_proto3_unittest"], 1497 lite = True, 1498 visibility = ["//java:__subpackages__"], 1499) 1500 1501internal_gen_kt_protos( 1502 name = "gen_kotlin_proto3_unittest", 1503 deps = [":kt_proto3_unittest"], 1504 visibility = ["//java:__subpackages__"], 1505) 1506