BUILD 42 KB

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