BUILD 46 KB

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