BUILD 42 KB

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