BUILD 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  1. # Bazel (https://bazel.build/) BUILD file for Protobuf.
  2. load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
  3. load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library", native_cc_proto_library = "cc_proto_library")
  4. load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
  5. load("@rules_python//python:defs.bzl", "py_library")
  6. load("@rules_java//java:defs.bzl", "java_binary", "java_proto_library", "java_lite_proto_library")
  7. load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test")
  8. licenses(["notice"])
  9. exports_files(["LICENSE"])
  10. ################################################################################
  11. # build configuration
  12. ################################################################################
  13. ################################################################################
  14. # ZLIB configuration
  15. ################################################################################
  16. ZLIB_DEPS = ["@zlib//:zlib"]
  17. ################################################################################
  18. # Protobuf Runtime Library
  19. ################################################################################
  20. MSVC_COPTS = [
  21. "/DHAVE_PTHREAD",
  22. "/wd4018", # -Wno-sign-compare
  23. "/wd4065", # switch statement contains 'default' but no 'case' labels
  24. "/wd4146", # unary minus operator applied to unsigned type, result still unsigned
  25. "/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
  26. "/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
  27. "/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
  28. "/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
  29. "/wd4307", # 'operator' : integral constant overflow
  30. "/wd4309", # 'conversion' : truncation of constant value
  31. "/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
  32. "/wd4355", # 'this' : used in base member initializer list
  33. "/wd4506", # no definition for inline function 'function'
  34. "/wd4514", # -Wno-unused-function
  35. "/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
  36. "/wd4996", # The compiler encountered a deprecated declaration.
  37. ]
  38. COPTS = select({
  39. ":msvc": MSVC_COPTS,
  40. "//conditions:default": [
  41. "-DHAVE_PTHREAD",
  42. "-DHAVE_ZLIB",
  43. "-Woverloaded-virtual",
  44. "-Wno-sign-compare",
  45. "-Wno-unused-function",
  46. # Prevents ISO C++ const string assignment warnings for pyext sources.
  47. "-Wno-write-strings",
  48. "-Wno-deprecated-declarations",
  49. ],
  50. })
  51. load(":compiler_config_setting.bzl", "create_compiler_config_setting")
  52. create_compiler_config_setting(
  53. name = "msvc",
  54. value = "msvc-cl",
  55. visibility = [
  56. # Public, but Protobuf only visibility.
  57. "//:__subpackages__",
  58. ],
  59. )
  60. config_setting(
  61. name = "android",
  62. values = {
  63. "crosstool_top": "//external:android/crosstool",
  64. },
  65. visibility = [
  66. # Public, but Protobuf only visibility.
  67. "//:__subpackages__",
  68. ],
  69. )
  70. config_setting(
  71. name = "android-libcpp",
  72. values = {
  73. "crosstool_top": "@androidndk//:toolchain-libcpp",
  74. },
  75. visibility = [
  76. # Public, but Protobuf only visibility.
  77. "//:__subpackages__",
  78. ],
  79. )
  80. config_setting(
  81. name = "android-gnu-libstdcpp",
  82. values = {
  83. "crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp",
  84. },
  85. visibility = [
  86. # Public, but Protobuf only visibility.
  87. "//:__subpackages__",
  88. ],
  89. )
  90. # Android and MSVC builds do not need to link in a separate pthread library.
  91. LINK_OPTS = select({
  92. ":android": [],
  93. ":android-libcpp": [],
  94. ":android-gnu-libstdcpp": [],
  95. ":msvc": [
  96. # Suppress linker warnings about files with no symbols defined.
  97. "-ignore:4221",
  98. ],
  99. "//conditions:default": [
  100. "-lpthread",
  101. "-lm",
  102. ],
  103. })
  104. load(
  105. ":protobuf.bzl",
  106. "adapt_proto_library",
  107. "cc_proto_library",
  108. "internal_copied_filegroup",
  109. "internal_gen_well_known_protos_java",
  110. "internal_protobuf_py_tests",
  111. "py_proto_library",
  112. )
  113. cc_library(
  114. name = "protobuf_lite",
  115. srcs = [
  116. # AUTOGEN(protobuf_lite_srcs)
  117. "src/google/protobuf/any_lite.cc",
  118. "src/google/protobuf/arena.cc",
  119. "src/google/protobuf/arenastring.cc",
  120. "src/google/protobuf/extension_set.cc",
  121. "src/google/protobuf/generated_enum_util.cc",
  122. "src/google/protobuf/generated_message_table_driven_lite.cc",
  123. "src/google/protobuf/generated_message_util.cc",
  124. "src/google/protobuf/implicit_weak_message.cc",
  125. "src/google/protobuf/io/coded_stream.cc",
  126. "src/google/protobuf/io/io_win32.cc",
  127. "src/google/protobuf/io/strtod.cc",
  128. "src/google/protobuf/io/zero_copy_stream.cc",
  129. "src/google/protobuf/io/zero_copy_stream_impl.cc",
  130. "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
  131. "src/google/protobuf/map.cc",
  132. "src/google/protobuf/message_lite.cc",
  133. "src/google/protobuf/parse_context.cc",
  134. "src/google/protobuf/repeated_field.cc",
  135. "src/google/protobuf/stubs/bytestream.cc",
  136. "src/google/protobuf/stubs/common.cc",
  137. "src/google/protobuf/stubs/int128.cc",
  138. "src/google/protobuf/stubs/status.cc",
  139. "src/google/protobuf/stubs/statusor.cc",
  140. "src/google/protobuf/stubs/stringpiece.cc",
  141. "src/google/protobuf/stubs/stringprintf.cc",
  142. "src/google/protobuf/stubs/structurally_valid.cc",
  143. "src/google/protobuf/stubs/strutil.cc",
  144. "src/google/protobuf/stubs/time.cc",
  145. "src/google/protobuf/wire_format_lite.cc",
  146. ],
  147. hdrs = glob([
  148. "src/google/protobuf/**/*.h",
  149. "src/google/protobuf/**/*.inc",
  150. ]),
  151. copts = COPTS,
  152. includes = ["src/"],
  153. linkopts = LINK_OPTS,
  154. visibility = ["//visibility:public"],
  155. )
  156. PROTOBUF_DEPS = select({
  157. ":msvc": [],
  158. "//conditions:default": ZLIB_DEPS,
  159. })
  160. cc_library(
  161. name = "protobuf",
  162. srcs = [
  163. # AUTOGEN(protobuf_srcs)
  164. "src/google/protobuf/any.cc",
  165. "src/google/protobuf/any.pb.cc",
  166. "src/google/protobuf/api.pb.cc",
  167. "src/google/protobuf/compiler/importer.cc",
  168. "src/google/protobuf/compiler/parser.cc",
  169. "src/google/protobuf/descriptor.cc",
  170. "src/google/protobuf/descriptor.pb.cc",
  171. "src/google/protobuf/descriptor_database.cc",
  172. "src/google/protobuf/duration.pb.cc",
  173. "src/google/protobuf/dynamic_message.cc",
  174. "src/google/protobuf/empty.pb.cc",
  175. "src/google/protobuf/extension_set_heavy.cc",
  176. "src/google/protobuf/field_mask.pb.cc",
  177. "src/google/protobuf/generated_message_reflection.cc",
  178. "src/google/protobuf/generated_message_table_driven.cc",
  179. "src/google/protobuf/io/gzip_stream.cc",
  180. "src/google/protobuf/io/printer.cc",
  181. "src/google/protobuf/io/tokenizer.cc",
  182. "src/google/protobuf/map_field.cc",
  183. "src/google/protobuf/message.cc",
  184. "src/google/protobuf/reflection_ops.cc",
  185. "src/google/protobuf/service.cc",
  186. "src/google/protobuf/source_context.pb.cc",
  187. "src/google/protobuf/struct.pb.cc",
  188. "src/google/protobuf/stubs/substitute.cc",
  189. "src/google/protobuf/text_format.cc",
  190. "src/google/protobuf/timestamp.pb.cc",
  191. "src/google/protobuf/type.pb.cc",
  192. "src/google/protobuf/unknown_field_set.cc",
  193. "src/google/protobuf/util/delimited_message_util.cc",
  194. "src/google/protobuf/util/field_comparator.cc",
  195. "src/google/protobuf/util/field_mask_util.cc",
  196. "src/google/protobuf/util/internal/datapiece.cc",
  197. "src/google/protobuf/util/internal/default_value_objectwriter.cc",
  198. "src/google/protobuf/util/internal/error_listener.cc",
  199. "src/google/protobuf/util/internal/field_mask_utility.cc",
  200. "src/google/protobuf/util/internal/json_escaping.cc",
  201. "src/google/protobuf/util/internal/json_objectwriter.cc",
  202. "src/google/protobuf/util/internal/json_stream_parser.cc",
  203. "src/google/protobuf/util/internal/object_writer.cc",
  204. "src/google/protobuf/util/internal/proto_writer.cc",
  205. "src/google/protobuf/util/internal/protostream_objectsource.cc",
  206. "src/google/protobuf/util/internal/protostream_objectwriter.cc",
  207. "src/google/protobuf/util/internal/type_info.cc",
  208. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  209. "src/google/protobuf/util/internal/utility.cc",
  210. "src/google/protobuf/util/json_util.cc",
  211. "src/google/protobuf/util/message_differencer.cc",
  212. "src/google/protobuf/util/time_util.cc",
  213. "src/google/protobuf/util/type_resolver_util.cc",
  214. "src/google/protobuf/wire_format.cc",
  215. "src/google/protobuf/wrappers.pb.cc",
  216. ],
  217. hdrs = glob([
  218. "src/**/*.h",
  219. "src/**/*.inc",
  220. ]),
  221. copts = COPTS,
  222. includes = ["src/"],
  223. linkopts = LINK_OPTS,
  224. visibility = ["//visibility:public"],
  225. deps = [":protobuf_lite"] + PROTOBUF_DEPS,
  226. )
  227. # This provides just the header files for use in projects that need to build
  228. # shared libraries for dynamic loading. This target is available until Bazel
  229. # adds native support for such use cases.
  230. # TODO(keveman): Remove this target once the support gets added to Bazel.
  231. cc_library(
  232. name = "protobuf_headers",
  233. hdrs = glob([
  234. "src/**/*.h",
  235. "src/**/*.inc",
  236. ]),
  237. includes = ["src/"],
  238. visibility = ["//visibility:public"],
  239. )
  240. # Map of all well known protos.
  241. # name => (include path, imports)
  242. WELL_KNOWN_PROTO_MAP = {
  243. "any": ("src/google/protobuf/any.proto", []),
  244. "api": (
  245. "src/google/protobuf/api.proto",
  246. [
  247. "source_context",
  248. "type",
  249. ],
  250. ),
  251. "compiler_plugin": (
  252. "src/google/protobuf/compiler/plugin.proto",
  253. ["descriptor"],
  254. ),
  255. "descriptor": ("src/google/protobuf/descriptor.proto", []),
  256. "duration": ("src/google/protobuf/duration.proto", []),
  257. "empty": ("src/google/protobuf/empty.proto", []),
  258. "field_mask": ("src/google/protobuf/field_mask.proto", []),
  259. "source_context": ("src/google/protobuf/source_context.proto", []),
  260. "struct": ("src/google/protobuf/struct.proto", []),
  261. "timestamp": ("src/google/protobuf/timestamp.proto", []),
  262. "type": (
  263. "src/google/protobuf/type.proto",
  264. [
  265. "any",
  266. "source_context",
  267. ],
  268. ),
  269. "wrappers": ("src/google/protobuf/wrappers.proto", []),
  270. }
  271. WELL_KNOWN_PROTOS = [value[0] for value in WELL_KNOWN_PROTO_MAP.values()]
  272. filegroup(
  273. name = "well_known_protos",
  274. srcs = WELL_KNOWN_PROTOS,
  275. visibility = ["//visibility:public"],
  276. )
  277. adapt_proto_library(
  278. name = "cc_wkt_protos_genproto",
  279. deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
  280. visibility = ["//visibility:public"],
  281. )
  282. cc_library(
  283. name = "cc_wkt_protos",
  284. deprecation = "Only for backward compatibility. Do not use.",
  285. visibility = ["//visibility:public"],
  286. )
  287. ################################################################################
  288. # Well Known Types Proto Library Rules
  289. #
  290. # These proto_library rules can be used with one of the language specific proto
  291. # library rules i.e. java_proto_library:
  292. #
  293. # java_proto_library(
  294. # name = "any_java_proto",
  295. # deps = ["@com_google_protobuf//:any_proto],
  296. # )
  297. ################################################################################
  298. [proto_library(
  299. name = proto[0] + "_proto",
  300. srcs = [proto[1][0]],
  301. strip_import_prefix = "src",
  302. visibility = ["//visibility:public"],
  303. deps = [dep + "_proto" for dep in proto[1][1]],
  304. ) for proto in WELL_KNOWN_PROTO_MAP.items()]
  305. [native_cc_proto_library(
  306. name = proto + "_cc_proto",
  307. deps = [proto + "_proto"],
  308. visibility = ["//visibility:private"],
  309. ) for proto in WELL_KNOWN_PROTO_MAP.keys()]
  310. cc_proto_blacklist_test(
  311. name = "cc_proto_blacklist_test",
  312. deps = [proto + "_cc_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
  313. tags = [
  314. # Exclude this target from wildcard expansion (//...). Due to
  315. # https://github.com/bazelbuild/bazel/issues/10590, this test has to
  316. # be nominated using the `@com_google_protobuf//` prefix. We do that,
  317. # e.g., in kokoro/linux/bazel/build.sh.
  318. # See also https://github.com/protocolbuffers/protobuf/pull/7096.
  319. "manual",
  320. ],
  321. )
  322. ################################################################################
  323. # Protocol Buffers Compiler
  324. ################################################################################
  325. cc_library(
  326. name = "protoc_lib",
  327. srcs = [
  328. # AUTOGEN(protoc_lib_srcs)
  329. "src/google/protobuf/compiler/code_generator.cc",
  330. "src/google/protobuf/compiler/command_line_interface.cc",
  331. "src/google/protobuf/compiler/cpp/cpp_enum.cc",
  332. "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
  333. "src/google/protobuf/compiler/cpp/cpp_extension.cc",
  334. "src/google/protobuf/compiler/cpp/cpp_field.cc",
  335. "src/google/protobuf/compiler/cpp/cpp_file.cc",
  336. "src/google/protobuf/compiler/cpp/cpp_generator.cc",
  337. "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
  338. "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
  339. "src/google/protobuf/compiler/cpp/cpp_message.cc",
  340. "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
  341. "src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc",
  342. "src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc",
  343. "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
  344. "src/google/protobuf/compiler/cpp/cpp_service.cc",
  345. "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
  346. "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
  347. "src/google/protobuf/compiler/csharp/csharp_enum.cc",
  348. "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
  349. "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
  350. "src/google/protobuf/compiler/csharp/csharp_generator.cc",
  351. "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
  352. "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
  353. "src/google/protobuf/compiler/csharp/csharp_message.cc",
  354. "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
  355. "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
  356. "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
  357. "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
  358. "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
  359. "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
  360. "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
  361. "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
  362. "src/google/protobuf/compiler/java/java_context.cc",
  363. "src/google/protobuf/compiler/java/java_doc_comment.cc",
  364. "src/google/protobuf/compiler/java/java_enum.cc",
  365. "src/google/protobuf/compiler/java/java_enum_field.cc",
  366. "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
  367. "src/google/protobuf/compiler/java/java_enum_lite.cc",
  368. "src/google/protobuf/compiler/java/java_extension.cc",
  369. "src/google/protobuf/compiler/java/java_extension_lite.cc",
  370. "src/google/protobuf/compiler/java/java_field.cc",
  371. "src/google/protobuf/compiler/java/java_file.cc",
  372. "src/google/protobuf/compiler/java/java_generator.cc",
  373. "src/google/protobuf/compiler/java/java_generator_factory.cc",
  374. "src/google/protobuf/compiler/java/java_helpers.cc",
  375. "src/google/protobuf/compiler/java/java_kotlin_generator.cc",
  376. "src/google/protobuf/compiler/java/java_map_field.cc",
  377. "src/google/protobuf/compiler/java/java_map_field_lite.cc",
  378. "src/google/protobuf/compiler/java/java_message.cc",
  379. "src/google/protobuf/compiler/java/java_message_builder.cc",
  380. "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
  381. "src/google/protobuf/compiler/java/java_message_field.cc",
  382. "src/google/protobuf/compiler/java/java_message_field_lite.cc",
  383. "src/google/protobuf/compiler/java/java_message_lite.cc",
  384. "src/google/protobuf/compiler/java/java_name_resolver.cc",
  385. "src/google/protobuf/compiler/java/java_primitive_field.cc",
  386. "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
  387. "src/google/protobuf/compiler/java/java_service.cc",
  388. "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
  389. "src/google/protobuf/compiler/java/java_string_field.cc",
  390. "src/google/protobuf/compiler/java/java_string_field_lite.cc",
  391. "src/google/protobuf/compiler/js/js_generator.cc",
  392. "src/google/protobuf/compiler/js/well_known_types_embed.cc",
  393. "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
  394. "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
  395. "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
  396. "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
  397. "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
  398. "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
  399. "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
  400. "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
  401. "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
  402. "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
  403. "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
  404. "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
  405. "src/google/protobuf/compiler/php/php_generator.cc",
  406. "src/google/protobuf/compiler/plugin.cc",
  407. "src/google/protobuf/compiler/plugin.pb.cc",
  408. "src/google/protobuf/compiler/python/python_generator.cc",
  409. "src/google/protobuf/compiler/ruby/ruby_generator.cc",
  410. "src/google/protobuf/compiler/subprocess.cc",
  411. "src/google/protobuf/compiler/zip_writer.cc",
  412. ],
  413. copts = COPTS,
  414. includes = ["src/"],
  415. linkopts = LINK_OPTS,
  416. visibility = ["//visibility:public"],
  417. deps = [":protobuf"],
  418. )
  419. cc_binary(
  420. name = "protoc",
  421. srcs = ["src/google/protobuf/compiler/main.cc"],
  422. linkopts = LINK_OPTS,
  423. visibility = ["//visibility:public"],
  424. deps = [":protoc_lib"],
  425. )
  426. ################################################################################
  427. # Tests
  428. ################################################################################
  429. filegroup(
  430. name = "testdata",
  431. visibility = ["//:__subpackages__"],
  432. srcs = glob(["src/google/protobuf/testdata/**/*"]),
  433. )
  434. RELATIVE_LITE_TEST_PROTOS = [
  435. # AUTOGEN(lite_test_protos)
  436. "google/protobuf/map_lite_unittest.proto",
  437. "google/protobuf/unittest_import_lite.proto",
  438. "google/protobuf/unittest_import_public_lite.proto",
  439. "google/protobuf/unittest_lite.proto",
  440. ]
  441. LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  442. RELATIVE_TEST_PROTOS = [
  443. # AUTOGEN(test_protos)
  444. "google/protobuf/any_test.proto",
  445. "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
  446. "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
  447. "google/protobuf/map_proto2_unittest.proto",
  448. "google/protobuf/map_unittest.proto",
  449. "google/protobuf/unittest.proto",
  450. "google/protobuf/unittest_arena.proto",
  451. "google/protobuf/unittest_custom_options.proto",
  452. "google/protobuf/unittest_drop_unknown_fields.proto",
  453. "google/protobuf/unittest_embed_optimize_for.proto",
  454. "google/protobuf/unittest_empty.proto",
  455. "google/protobuf/unittest_enormous_descriptor.proto",
  456. "google/protobuf/unittest_import.proto",
  457. "google/protobuf/unittest_import_public.proto",
  458. "google/protobuf/unittest_lazy_dependencies.proto",
  459. "google/protobuf/unittest_lazy_dependencies_custom_option.proto",
  460. "google/protobuf/unittest_lazy_dependencies_enum.proto",
  461. "google/protobuf/unittest_lite_imports_nonlite.proto",
  462. "google/protobuf/unittest_mset.proto",
  463. "google/protobuf/unittest_mset_wire_format.proto",
  464. "google/protobuf/unittest_no_field_presence.proto",
  465. "google/protobuf/unittest_no_generic_services.proto",
  466. "google/protobuf/unittest_optimize_for.proto",
  467. "google/protobuf/unittest_preserve_unknown_enum.proto",
  468. "google/protobuf/unittest_preserve_unknown_enum2.proto",
  469. "google/protobuf/unittest_proto3.proto",
  470. "google/protobuf/unittest_proto3_arena.proto",
  471. "google/protobuf/unittest_proto3_arena_lite.proto",
  472. "google/protobuf/unittest_proto3_lite.proto",
  473. "google/protobuf/unittest_proto3_optional.proto",
  474. "google/protobuf/unittest_well_known_types.proto",
  475. "google/protobuf/util/internal/testdata/anys.proto",
  476. "google/protobuf/util/internal/testdata/books.proto",
  477. "google/protobuf/util/internal/testdata/default_value.proto",
  478. "google/protobuf/util/internal/testdata/default_value_test.proto",
  479. "google/protobuf/util/internal/testdata/field_mask.proto",
  480. "google/protobuf/util/internal/testdata/maps.proto",
  481. "google/protobuf/util/internal/testdata/oneofs.proto",
  482. "google/protobuf/util/internal/testdata/proto3.proto",
  483. "google/protobuf/util/internal/testdata/struct.proto",
  484. "google/protobuf/util/internal/testdata/timestamp_duration.proto",
  485. "google/protobuf/util/internal/testdata/wrappers.proto",
  486. "google/protobuf/util/json_format.proto",
  487. "google/protobuf/util/json_format_proto3.proto",
  488. "google/protobuf/util/message_differencer_unittest.proto",
  489. ]
  490. TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
  491. GENERIC_RELATIVE_TEST_PROTOS = [
  492. "google/protobuf/unittest.proto",
  493. "google/protobuf/unittest_arena.proto",
  494. "google/protobuf/unittest_custom_options.proto",
  495. "google/protobuf/unittest_drop_unknown_fields.proto",
  496. "google/protobuf/unittest_embed_optimize_for.proto",
  497. "google/protobuf/unittest_empty.proto",
  498. "google/protobuf/unittest_enormous_descriptor.proto",
  499. "google/protobuf/unittest_import.proto",
  500. "google/protobuf/unittest_import_public.proto",
  501. "google/protobuf/unittest_lazy_dependencies.proto",
  502. "google/protobuf/unittest_lazy_dependencies_custom_option.proto",
  503. "google/protobuf/unittest_lazy_dependencies_enum.proto",
  504. "google/protobuf/unittest_lite_imports_nonlite.proto",
  505. "google/protobuf/unittest_mset.proto",
  506. "google/protobuf/unittest_mset_wire_format.proto",
  507. "google/protobuf/unittest_no_field_presence.proto",
  508. "google/protobuf/unittest_no_generic_services.proto",
  509. "google/protobuf/unittest_optimize_for.proto",
  510. "google/protobuf/unittest_preserve_unknown_enum.proto",
  511. "google/protobuf/unittest_preserve_unknown_enum2.proto",
  512. "google/protobuf/unittest_proto3.proto",
  513. "google/protobuf/unittest_proto3_arena.proto",
  514. "google/protobuf/unittest_proto3_arena_lite.proto",
  515. "google/protobuf/unittest_proto3_lite.proto",
  516. "google/protobuf/unittest_proto3_optional.proto",
  517. "google/protobuf/unittest_well_known_types.proto",
  518. ]
  519. GENERIC_TEST_PROTOS = ["src/" + s for s in GENERIC_RELATIVE_TEST_PROTOS]
  520. proto_library(
  521. name = "generic_test_protos",
  522. visibility = ["//:__subpackages__"],
  523. strip_import_prefix = "src",
  524. srcs = LITE_TEST_PROTOS + GENERIC_TEST_PROTOS,
  525. deps = [
  526. "//:any_proto",
  527. "//:api_proto",
  528. "//:descriptor_proto",
  529. "//:duration_proto",
  530. "//:empty_proto",
  531. "//:field_mask_proto",
  532. "//:source_context_proto",
  533. "//:struct_proto",
  534. "//:timestamp_proto",
  535. "//:type_proto",
  536. "//:wrappers_proto",
  537. ],
  538. )
  539. cc_proto_library(
  540. name = "cc_test_protos",
  541. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  542. include = "src",
  543. default_runtime = ":protobuf",
  544. protoc = ":protoc",
  545. deps = [":cc_wkt_protos"],
  546. )
  547. COMMON_TEST_SRCS = [
  548. # AUTOGEN(common_test_srcs)
  549. "src/google/protobuf/arena_test_util.cc",
  550. "src/google/protobuf/map_test_util.inc",
  551. "src/google/protobuf/test_util.cc",
  552. "src/google/protobuf/test_util.inc",
  553. "src/google/protobuf/testing/file.cc",
  554. "src/google/protobuf/testing/googletest.cc",
  555. ]
  556. cc_binary(
  557. name = "test_plugin",
  558. testonly = True,
  559. srcs = [
  560. # AUTOGEN(test_plugin_srcs)
  561. "src/google/protobuf/compiler/mock_code_generator.cc",
  562. "src/google/protobuf/compiler/test_plugin.cc",
  563. "src/google/protobuf/testing/file.cc",
  564. ],
  565. deps = [
  566. ":protobuf",
  567. ":protoc_lib",
  568. "@com_google_googletest//:gtest",
  569. ],
  570. )
  571. cc_test(
  572. name = "win32_test",
  573. srcs = ["src/google/protobuf/io/io_win32_unittest.cc"],
  574. tags = [
  575. "manual",
  576. "windows",
  577. ],
  578. deps = [
  579. ":protobuf_lite",
  580. "@com_google_googletest//:gtest",
  581. "@com_google_googletest//:gtest_main",
  582. ],
  583. )
  584. cc_test(
  585. name = "protobuf_test",
  586. srcs = COMMON_TEST_SRCS + [
  587. # AUTOGEN(test_srcs)
  588. "src/google/protobuf/any_test.cc",
  589. "src/google/protobuf/arena_unittest.cc",
  590. "src/google/protobuf/arenastring_unittest.cc",
  591. "src/google/protobuf/compiler/annotation_test_util.cc",
  592. "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
  593. "src/google/protobuf/compiler/cpp/cpp_move_unittest.cc",
  594. "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
  595. "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
  596. "src/google/protobuf/compiler/cpp/cpp_unittest.inc",
  597. "src/google/protobuf/compiler/cpp/metadata_test.cc",
  598. "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc",
  599. "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
  600. "src/google/protobuf/compiler/importer_unittest.cc",
  601. "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
  602. "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
  603. "src/google/protobuf/compiler/mock_code_generator.cc",
  604. "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
  605. "src/google/protobuf/compiler/parser_unittest.cc",
  606. "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
  607. "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
  608. "src/google/protobuf/descriptor_database_unittest.cc",
  609. "src/google/protobuf/descriptor_unittest.cc",
  610. "src/google/protobuf/drop_unknown_fields_test.cc",
  611. "src/google/protobuf/dynamic_message_unittest.cc",
  612. "src/google/protobuf/extension_set_unittest.cc",
  613. "src/google/protobuf/generated_message_reflection_unittest.cc",
  614. "src/google/protobuf/io/coded_stream_unittest.cc",
  615. "src/google/protobuf/io/io_win32_unittest.cc",
  616. "src/google/protobuf/io/printer_unittest.cc",
  617. "src/google/protobuf/io/tokenizer_unittest.cc",
  618. "src/google/protobuf/io/zero_copy_stream_unittest.cc",
  619. "src/google/protobuf/map_field_test.cc",
  620. "src/google/protobuf/map_test.cc",
  621. "src/google/protobuf/message_unittest.cc",
  622. "src/google/protobuf/message_unittest.inc",
  623. "src/google/protobuf/no_field_presence_test.cc",
  624. "src/google/protobuf/preserve_unknown_enum_test.cc",
  625. "src/google/protobuf/proto3_arena_lite_unittest.cc",
  626. "src/google/protobuf/proto3_arena_unittest.cc",
  627. "src/google/protobuf/proto3_lite_unittest.cc",
  628. "src/google/protobuf/proto3_lite_unittest.inc",
  629. "src/google/protobuf/reflection_ops_unittest.cc",
  630. "src/google/protobuf/repeated_field_reflection_unittest.cc",
  631. "src/google/protobuf/repeated_field_unittest.cc",
  632. "src/google/protobuf/stubs/bytestream_unittest.cc",
  633. "src/google/protobuf/stubs/common_unittest.cc",
  634. "src/google/protobuf/stubs/int128_unittest.cc",
  635. "src/google/protobuf/stubs/status_test.cc",
  636. "src/google/protobuf/stubs/statusor_test.cc",
  637. "src/google/protobuf/stubs/stringpiece_unittest.cc",
  638. "src/google/protobuf/stubs/stringprintf_unittest.cc",
  639. "src/google/protobuf/stubs/structurally_valid_unittest.cc",
  640. "src/google/protobuf/stubs/strutil_unittest.cc",
  641. "src/google/protobuf/stubs/template_util_unittest.cc",
  642. "src/google/protobuf/stubs/time_test.cc",
  643. "src/google/protobuf/text_format_unittest.cc",
  644. "src/google/protobuf/unknown_field_set_unittest.cc",
  645. "src/google/protobuf/util/delimited_message_util_test.cc",
  646. "src/google/protobuf/util/field_comparator_test.cc",
  647. "src/google/protobuf/util/field_mask_util_test.cc",
  648. "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
  649. "src/google/protobuf/util/internal/json_objectwriter_test.cc",
  650. "src/google/protobuf/util/internal/json_stream_parser_test.cc",
  651. "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
  652. "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
  653. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  654. "src/google/protobuf/util/json_util_test.cc",
  655. "src/google/protobuf/util/message_differencer_unittest.cc",
  656. "src/google/protobuf/util/time_util_test.cc",
  657. "src/google/protobuf/util/type_resolver_util_test.cc",
  658. "src/google/protobuf/well_known_types_unittest.cc",
  659. "src/google/protobuf/wire_format_unittest.cc",
  660. ] + select({
  661. "//conditions:default": [
  662. # AUTOGEN(non_msvc_test_srcs)
  663. "src/google/protobuf/compiler/command_line_interface_unittest.cc",
  664. ],
  665. ":msvc": [],
  666. }),
  667. copts = COPTS,
  668. data = [
  669. ":test_plugin",
  670. ] + glob([
  671. "src/google/protobuf/**/*",
  672. # Files for csharp_bootstrap_unittest.cc.
  673. "conformance/**/*",
  674. "csharp/src/**/*",
  675. ]),
  676. includes = [
  677. "src/",
  678. ],
  679. linkopts = LINK_OPTS,
  680. deps = [
  681. ":cc_test_protos",
  682. ":protobuf",
  683. ":protoc_lib",
  684. "@com_google_googletest//:gtest",
  685. "@com_google_googletest//:gtest_main",
  686. ] + PROTOBUF_DEPS,
  687. )
  688. ################################################################################
  689. # Java support
  690. ################################################################################
  691. internal_gen_well_known_protos_java(
  692. name = "gen_well_known_protos_java",
  693. deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
  694. visibility = [
  695. "//java:__subpackages__",
  696. ],
  697. )
  698. internal_gen_well_known_protos_java(
  699. name = "gen_well_known_protos_javalite",
  700. deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
  701. javalite = True,
  702. visibility = [
  703. "//java:__subpackages__",
  704. ],
  705. )
  706. alias(
  707. name = "protobuf_java",
  708. actual = "//java/core",
  709. visibility = ["//visibility:public"],
  710. )
  711. alias(
  712. name = "protobuf_javalite",
  713. actual = "//java/lite",
  714. visibility = ["//visibility:public"],
  715. )
  716. alias(
  717. name = "protobuf_java_util",
  718. actual = "//java/util",
  719. visibility = ["//visibility:public"],
  720. )
  721. alias(
  722. name = "java_toolchain",
  723. actual = "//java/core:toolchain",
  724. visibility = ["//visibility:public"],
  725. )
  726. alias(
  727. name = "javalite_toolchain",
  728. actual = "//java/lite:toolchain",
  729. visibility = ["//visibility:public"],
  730. )
  731. ################################################################################
  732. # Python support
  733. ################################################################################
  734. py_library(
  735. name = "python_srcs",
  736. srcs = glob(
  737. [
  738. "python/google/protobuf/**/*.py",
  739. ],
  740. exclude = [
  741. "python/google/protobuf/internal/*_test.py",
  742. "python/google/protobuf/internal/test_util.py",
  743. ],
  744. ),
  745. imports = ["python"],
  746. srcs_version = "PY2AND3",
  747. )
  748. cc_binary(
  749. name = "python/google/protobuf/internal/_api_implementation.so",
  750. srcs = ["python/google/protobuf/internal/api_implementation.cc"],
  751. copts = COPTS + [
  752. "-DPYTHON_PROTO2_CPP_IMPL_V2",
  753. ],
  754. tags = [
  755. # Exclude this target from wildcard expansion (//...) because it may
  756. # not even be buildable. It will be built if it is needed according
  757. # to :use_fast_cpp_protos.
  758. # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes
  759. "manual",
  760. ],
  761. linkshared = 1,
  762. linkstatic = 1,
  763. deps = select({
  764. "//conditions:default": [],
  765. ":use_fast_cpp_protos": ["//external:python_headers"],
  766. }),
  767. )
  768. cc_binary(
  769. name = "python/google/protobuf/pyext/_message.so",
  770. srcs = glob([
  771. "python/google/protobuf/pyext/*.cc",
  772. "python/google/protobuf/pyext/*.h",
  773. ]),
  774. copts = COPTS + [
  775. "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
  776. ] + select({
  777. "//conditions:default": [],
  778. ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
  779. }),
  780. includes = [
  781. "python/",
  782. "src/",
  783. ],
  784. tags = [
  785. # Exclude this target from wildcard expansion (//...) because it may
  786. # not even be buildable. It will be built if it is needed according
  787. # to :use_fast_cpp_protos.
  788. # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes
  789. "manual",
  790. ],
  791. linkshared = 1,
  792. linkstatic = 1,
  793. deps = [
  794. ":protobuf",
  795. ":proto_api",
  796. ] + select({
  797. "//conditions:default": [],
  798. ":use_fast_cpp_protos": ["//external:python_headers"],
  799. }),
  800. )
  801. config_setting(
  802. name = "use_fast_cpp_protos",
  803. values = {
  804. "define": "use_fast_cpp_protos=true",
  805. },
  806. visibility = [
  807. # Public, but Protobuf only visibility.
  808. "//:__subpackages__",
  809. ],
  810. )
  811. config_setting(
  812. name = "allow_oversize_protos",
  813. values = {
  814. "define": "allow_oversize_protos=true",
  815. },
  816. visibility = [
  817. # Public, but Protobuf only visibility.
  818. "//:__subpackages__",
  819. ],
  820. )
  821. # Copy the builtin proto files from src/google/protobuf to
  822. # python/google/protobuf. This way, the generated Python sources will be in the
  823. # same directory as the Python runtime sources. This is necessary for the
  824. # modules to be imported correctly since they are all part of the same Python
  825. # package.
  826. internal_copied_filegroup(
  827. name = "protos_python",
  828. srcs = WELL_KNOWN_PROTOS,
  829. dest = "python",
  830. strip_prefix = "src",
  831. )
  832. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  833. # which case we can simply add :protos_python in srcs.
  834. COPIED_WELL_KNOWN_PROTOS = ["python/" + s[4:] for s in WELL_KNOWN_PROTOS]
  835. py_proto_library(
  836. name = "protobuf_python",
  837. srcs = COPIED_WELL_KNOWN_PROTOS,
  838. include = "python",
  839. data = select({
  840. "//conditions:default": [],
  841. ":use_fast_cpp_protos": [
  842. ":python/google/protobuf/internal/_api_implementation.so",
  843. ":python/google/protobuf/pyext/_message.so",
  844. ],
  845. }),
  846. default_runtime = "",
  847. protoc = ":protoc",
  848. py_libs = [
  849. ":python_srcs",
  850. "@six//:six",
  851. ],
  852. srcs_version = "PY2AND3",
  853. visibility = ["//visibility:public"],
  854. )
  855. # Copy the test proto files from src/google/protobuf to
  856. # python/google/protobuf. This way, the generated Python sources will be in the
  857. # same directory as the Python runtime sources. This is necessary for the
  858. # modules to be imported correctly by the tests since they are all part of the
  859. # same Python package.
  860. internal_copied_filegroup(
  861. name = "protos_python_test",
  862. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  863. dest = "python",
  864. strip_prefix = "src",
  865. )
  866. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  867. # which case we can simply add :protos_python_test in srcs.
  868. COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  869. COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
  870. py_proto_library(
  871. name = "python_common_test_protos",
  872. srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
  873. include = "python",
  874. default_runtime = "",
  875. protoc = ":protoc",
  876. srcs_version = "PY2AND3",
  877. deps = [":protobuf_python"],
  878. )
  879. py_proto_library(
  880. name = "python_specific_test_protos",
  881. srcs = glob([
  882. "python/google/protobuf/internal/*.proto",
  883. "python/google/protobuf/internal/import_test_package/*.proto",
  884. ]),
  885. include = "python",
  886. default_runtime = ":protobuf_python",
  887. protoc = ":protoc",
  888. srcs_version = "PY2AND3",
  889. deps = [":python_common_test_protos"],
  890. )
  891. py_library(
  892. name = "python_tests",
  893. srcs = glob(
  894. [
  895. "python/google/protobuf/internal/*_test.py",
  896. "python/google/protobuf/internal/test_util.py",
  897. "python/google/protobuf/internal/import_test_package/__init__.py",
  898. ],
  899. ),
  900. imports = ["python"],
  901. srcs_version = "PY2AND3",
  902. deps = [
  903. ":protobuf_python",
  904. ":python_common_test_protos",
  905. ":python_specific_test_protos",
  906. ],
  907. )
  908. internal_protobuf_py_tests(
  909. name = "python_tests_batch",
  910. data = glob([
  911. "src/google/protobuf/**/*",
  912. ]),
  913. modules = [
  914. "descriptor_database_test",
  915. "descriptor_pool_test",
  916. "descriptor_test",
  917. "generator_test",
  918. "json_format_test",
  919. "message_factory_test",
  920. "message_test",
  921. "proto_builder_test",
  922. "reflection_test",
  923. "service_reflection_test",
  924. "symbol_database_test",
  925. "text_encoding_test",
  926. "text_format_test",
  927. "unknown_fields_test",
  928. "wire_format_test",
  929. ],
  930. deps = [":python_tests"],
  931. )
  932. cc_library(
  933. name = "proto_api",
  934. hdrs = ["python/google/protobuf/proto_api.h"],
  935. visibility = ["//visibility:public"],
  936. deps = [
  937. "//external:python_headers",
  938. ],
  939. )
  940. proto_lang_toolchain(
  941. name = "cc_toolchain",
  942. blacklisted_protos = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
  943. command_line = "--cpp_out=$(OUT)",
  944. runtime = ":protobuf",
  945. visibility = ["//visibility:public"],
  946. )
  947. alias(
  948. name = "objectivec",
  949. actual = "//objectivec",
  950. visibility = ["//visibility:public"],
  951. )
  952. alias(
  953. name = "protobuf_objc",
  954. actual = "//objectivec",
  955. visibility = ["//visibility:public"],
  956. )
  957. ################################################################################
  958. # Test generated proto support
  959. ################################################################################
  960. genrule(
  961. name = "generated_protos",
  962. srcs = ["src/google/protobuf/unittest_import.proto"],
  963. outs = ["unittest_gen.proto"],
  964. cmd = "cat $(SRCS) | sed 's|google/|src/google/|' > $(OUTS)",
  965. )
  966. proto_library(
  967. name = "generated_protos_proto",
  968. srcs = [
  969. "src/google/protobuf/unittest_import_public.proto",
  970. "unittest_gen.proto",
  971. ],
  972. )
  973. py_proto_library(
  974. name = "generated_protos_py",
  975. srcs = [
  976. "src/google/protobuf/unittest_import_public.proto",
  977. "unittest_gen.proto",
  978. ],
  979. default_runtime = "",
  980. protoc = ":protoc",
  981. )
  982. ################################################################################
  983. # Conformance tests
  984. ################################################################################
  985. proto_library(
  986. name = "test_messages_proto2_proto",
  987. srcs = ["src/google/protobuf/test_messages_proto2.proto"],
  988. visibility = ["//visibility:public"],
  989. )
  990. proto_library(
  991. name = "test_messages_proto3_proto",
  992. srcs = ["src/google/protobuf/test_messages_proto3.proto"],
  993. visibility = ["//visibility:public"],
  994. deps = [
  995. ":any_proto",
  996. ":duration_proto",
  997. ":field_mask_proto",
  998. ":struct_proto",
  999. ":timestamp_proto",
  1000. ":wrappers_proto",
  1001. ],
  1002. )
  1003. cc_proto_library(
  1004. name = "test_messages_proto2_proto_cc",
  1005. srcs = ["src/google/protobuf/test_messages_proto2.proto"],
  1006. )
  1007. cc_proto_library(
  1008. name = "test_messages_proto3_proto_cc",
  1009. srcs = ["src/google/protobuf/test_messages_proto3.proto"],
  1010. deps = [
  1011. ":cc_wkt_protos",
  1012. ],
  1013. )
  1014. proto_library(
  1015. name = "conformance_proto",
  1016. srcs = ["conformance/conformance.proto"],
  1017. visibility = ["//visibility:public"],
  1018. )
  1019. cc_proto_library(
  1020. name = "conformance_proto_cc",
  1021. srcs = ["conformance/conformance.proto"],
  1022. )
  1023. cc_library(
  1024. name = "jsoncpp",
  1025. srcs = ["conformance/third_party/jsoncpp/jsoncpp.cpp"],
  1026. hdrs = ["conformance/third_party/jsoncpp/json.h"],
  1027. includes = ["conformance"],
  1028. )
  1029. cc_library(
  1030. name = "conformance_test",
  1031. srcs = [
  1032. "conformance/conformance_test.cc",
  1033. "conformance/conformance_test_runner.cc",
  1034. ],
  1035. hdrs = [
  1036. "conformance/conformance_test.h",
  1037. ],
  1038. includes = [
  1039. "conformance",
  1040. "src",
  1041. ],
  1042. deps = [":conformance_proto_cc"],
  1043. )
  1044. cc_library(
  1045. name = "binary_json_conformance_suite",
  1046. srcs = ["conformance/binary_json_conformance_suite.cc"],
  1047. hdrs = ["conformance/binary_json_conformance_suite.h"],
  1048. deps = [
  1049. ":conformance_test",
  1050. ":jsoncpp",
  1051. ":test_messages_proto2_proto_cc",
  1052. ":test_messages_proto3_proto_cc",
  1053. ],
  1054. )
  1055. cc_library(
  1056. name = "text_format_conformance_suite",
  1057. srcs = ["conformance/text_format_conformance_suite.cc"],
  1058. hdrs = ["conformance/text_format_conformance_suite.h"],
  1059. deps = [
  1060. ":conformance_test",
  1061. ":test_messages_proto2_proto_cc",
  1062. ":test_messages_proto3_proto_cc",
  1063. ],
  1064. )
  1065. cc_binary(
  1066. name = "conformance_test_runner",
  1067. srcs = ["conformance/conformance_test_main.cc"],
  1068. visibility = ["//visibility:public"],
  1069. deps = [
  1070. ":binary_json_conformance_suite",
  1071. ":conformance_test",
  1072. ":text_format_conformance_suite",
  1073. ],
  1074. )
  1075. sh_test(
  1076. name = "build_files_updated_unittest",
  1077. srcs = [
  1078. "build_files_updated_unittest.sh",
  1079. ],
  1080. data = [
  1081. "BUILD",
  1082. "cmake/extract_includes.bat.in",
  1083. "cmake/libprotobuf.cmake",
  1084. "cmake/libprotobuf-lite.cmake",
  1085. "cmake/libprotoc.cmake",
  1086. "cmake/tests.cmake",
  1087. "src/Makefile.am",
  1088. "update_file_lists.sh",
  1089. ],
  1090. )
  1091. java_proto_library(
  1092. name = "test_messages_proto2_java_proto",
  1093. visibility = [
  1094. "//java:__subpackages__",
  1095. ],
  1096. deps = [":test_messages_proto2_proto"],
  1097. )
  1098. java_proto_library(
  1099. name = "test_messages_proto3_java_proto",
  1100. visibility = [
  1101. "//java:__subpackages__",
  1102. ],
  1103. deps = [":test_messages_proto3_proto"],
  1104. )
  1105. java_proto_library(
  1106. name = "conformance_java_proto",
  1107. visibility = [
  1108. "//java:__subpackages__",
  1109. ],
  1110. deps = [":conformance_proto"],
  1111. )
  1112. java_lite_proto_library(
  1113. name = "test_messages_proto2_java_proto_lite",
  1114. visibility = [
  1115. "//java:__subpackages__",
  1116. ],
  1117. deps = [":test_messages_proto2_proto"],
  1118. )
  1119. java_lite_proto_library(
  1120. name = "conformance_java_proto_lite",
  1121. visibility = [
  1122. "//java:__subpackages__",
  1123. ],
  1124. deps = [":conformance_proto"],
  1125. )
  1126. java_lite_proto_library(
  1127. name = "test_messages_proto3_java_proto_lite",
  1128. visibility = [
  1129. "//java:__subpackages__",
  1130. ],
  1131. deps = [":test_messages_proto3_proto"],
  1132. )
  1133. java_binary(
  1134. name = "conformance_java",
  1135. srcs = ["conformance/ConformanceJava.java"],
  1136. visibility = [
  1137. "//java:__subpackages__",
  1138. ],
  1139. main_class = "ConformanceJava",
  1140. deps = [
  1141. ":conformance_java_proto",
  1142. ":test_messages_proto2_java_proto",
  1143. ":test_messages_proto3_java_proto",
  1144. "//:protobuf_java",
  1145. "//:protobuf_java_util",
  1146. ],
  1147. )
  1148. java_binary(
  1149. name = "conformance_java_lite",
  1150. srcs = ["conformance/ConformanceJavaLite.java"],
  1151. visibility = [
  1152. "//java:__subpackages__",
  1153. ],
  1154. main_class = "ConformanceJavaLite",
  1155. deps = [
  1156. ":conformance_java_proto_lite",
  1157. ":test_messages_proto2_java_proto_lite",
  1158. ":test_messages_proto3_java_proto_lite",
  1159. "//:protobuf_javalite",
  1160. "//:protobuf_java_util",
  1161. ],
  1162. )
  1163. exports_files([
  1164. "conformance/conformance_test_runner.sh",
  1165. "conformance/failure_list_java.txt",
  1166. "conformance/failure_list_java_lite.txt",
  1167. "conformance/text_format_failure_list_java.txt",
  1168. "conformance/text_format_failure_list_java_lite.txt",
  1169. ])