BUILD 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  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_proto3_optional.proto",
  488. "google/protobuf/unittest_well_known_types.proto",
  489. "google/protobuf/util/internal/testdata/anys.proto",
  490. "google/protobuf/util/internal/testdata/books.proto",
  491. "google/protobuf/util/internal/testdata/default_value.proto",
  492. "google/protobuf/util/internal/testdata/default_value_test.proto",
  493. "google/protobuf/util/internal/testdata/field_mask.proto",
  494. "google/protobuf/util/internal/testdata/maps.proto",
  495. "google/protobuf/util/internal/testdata/oneofs.proto",
  496. "google/protobuf/util/internal/testdata/proto3.proto",
  497. "google/protobuf/util/internal/testdata/struct.proto",
  498. "google/protobuf/util/internal/testdata/timestamp_duration.proto",
  499. "google/protobuf/util/internal/testdata/wrappers.proto",
  500. "google/protobuf/util/json_format.proto",
  501. "google/protobuf/util/json_format_proto3.proto",
  502. "google/protobuf/util/message_differencer_unittest.proto",
  503. ]
  504. TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
  505. cc_proto_library(
  506. name = "cc_test_protos",
  507. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  508. include = "src",
  509. default_runtime = ":protobuf",
  510. protoc = ":protoc",
  511. deps = [":cc_wkt_protos"],
  512. )
  513. COMMON_TEST_SRCS = [
  514. # AUTOGEN(common_test_srcs)
  515. "src/google/protobuf/arena_test_util.cc",
  516. "src/google/protobuf/map_test_util.inc",
  517. "src/google/protobuf/test_util.cc",
  518. "src/google/protobuf/test_util.inc",
  519. "src/google/protobuf/testing/file.cc",
  520. "src/google/protobuf/testing/googletest.cc",
  521. ]
  522. cc_binary(
  523. name = "test_plugin",
  524. srcs = [
  525. # AUTOGEN(test_plugin_srcs)
  526. "src/google/protobuf/compiler/mock_code_generator.cc",
  527. "src/google/protobuf/compiler/test_plugin.cc",
  528. "src/google/protobuf/testing/file.cc",
  529. ],
  530. deps = [
  531. ":protobuf",
  532. ":protoc_lib",
  533. ] + GTEST,
  534. )
  535. cc_test(
  536. name = "win32_test",
  537. srcs = ["src/google/protobuf/io/io_win32_unittest.cc"],
  538. tags = [
  539. "manual",
  540. "windows",
  541. ],
  542. deps = [
  543. ":protobuf_lite",
  544. ] + GTEST_MAIN,
  545. )
  546. cc_test(
  547. name = "protobuf_test",
  548. srcs = COMMON_TEST_SRCS + [
  549. # AUTOGEN(test_srcs)
  550. "src/google/protobuf/any_test.cc",
  551. "src/google/protobuf/arena_unittest.cc",
  552. "src/google/protobuf/arenastring_unittest.cc",
  553. "src/google/protobuf/compiler/annotation_test_util.cc",
  554. "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
  555. "src/google/protobuf/compiler/cpp/cpp_move_unittest.cc",
  556. "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
  557. "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
  558. "src/google/protobuf/compiler/cpp/cpp_unittest.inc",
  559. "src/google/protobuf/compiler/cpp/metadata_test.cc",
  560. "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc",
  561. "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
  562. "src/google/protobuf/compiler/importer_unittest.cc",
  563. "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
  564. "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
  565. "src/google/protobuf/compiler/mock_code_generator.cc",
  566. "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
  567. "src/google/protobuf/compiler/parser_unittest.cc",
  568. "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
  569. "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
  570. "src/google/protobuf/descriptor_database_unittest.cc",
  571. "src/google/protobuf/descriptor_unittest.cc",
  572. "src/google/protobuf/drop_unknown_fields_test.cc",
  573. "src/google/protobuf/dynamic_message_unittest.cc",
  574. "src/google/protobuf/extension_set_unittest.cc",
  575. "src/google/protobuf/generated_message_reflection_unittest.cc",
  576. "src/google/protobuf/io/coded_stream_unittest.cc",
  577. "src/google/protobuf/io/io_win32_unittest.cc",
  578. "src/google/protobuf/io/printer_unittest.cc",
  579. "src/google/protobuf/io/tokenizer_unittest.cc",
  580. "src/google/protobuf/io/zero_copy_stream_unittest.cc",
  581. "src/google/protobuf/map_field_test.cc",
  582. "src/google/protobuf/map_test.cc",
  583. "src/google/protobuf/message_unittest.cc",
  584. "src/google/protobuf/message_unittest.inc",
  585. "src/google/protobuf/no_field_presence_test.cc",
  586. "src/google/protobuf/preserve_unknown_enum_test.cc",
  587. "src/google/protobuf/proto3_arena_lite_unittest.cc",
  588. "src/google/protobuf/proto3_arena_unittest.cc",
  589. "src/google/protobuf/proto3_lite_unittest.cc",
  590. "src/google/protobuf/proto3_lite_unittest.inc",
  591. "src/google/protobuf/reflection_ops_unittest.cc",
  592. "src/google/protobuf/repeated_field_reflection_unittest.cc",
  593. "src/google/protobuf/repeated_field_unittest.cc",
  594. "src/google/protobuf/stubs/bytestream_unittest.cc",
  595. "src/google/protobuf/stubs/common_unittest.cc",
  596. "src/google/protobuf/stubs/int128_unittest.cc",
  597. "src/google/protobuf/stubs/status_test.cc",
  598. "src/google/protobuf/stubs/statusor_test.cc",
  599. "src/google/protobuf/stubs/stringpiece_unittest.cc",
  600. "src/google/protobuf/stubs/stringprintf_unittest.cc",
  601. "src/google/protobuf/stubs/structurally_valid_unittest.cc",
  602. "src/google/protobuf/stubs/strutil_unittest.cc",
  603. "src/google/protobuf/stubs/template_util_unittest.cc",
  604. "src/google/protobuf/stubs/time_test.cc",
  605. "src/google/protobuf/text_format_unittest.cc",
  606. "src/google/protobuf/unknown_field_set_unittest.cc",
  607. "src/google/protobuf/util/delimited_message_util_test.cc",
  608. "src/google/protobuf/util/field_comparator_test.cc",
  609. "src/google/protobuf/util/field_mask_util_test.cc",
  610. "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
  611. "src/google/protobuf/util/internal/json_objectwriter_test.cc",
  612. "src/google/protobuf/util/internal/json_stream_parser_test.cc",
  613. "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
  614. "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
  615. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  616. "src/google/protobuf/util/json_util_test.cc",
  617. "src/google/protobuf/util/message_differencer_unittest.cc",
  618. "src/google/protobuf/util/time_util_test.cc",
  619. "src/google/protobuf/util/type_resolver_util_test.cc",
  620. "src/google/protobuf/well_known_types_unittest.cc",
  621. "src/google/protobuf/wire_format_unittest.cc",
  622. ] + select({
  623. "//conditions:default": [
  624. # AUTOGEN(non_msvc_test_srcs)
  625. "src/google/protobuf/compiler/command_line_interface_unittest.cc",
  626. ],
  627. ":msvc": [],
  628. }),
  629. copts = COPTS,
  630. data = [
  631. ":test_plugin",
  632. ] + glob([
  633. "src/google/protobuf/**/*",
  634. # Files for csharp_bootstrap_unittest.cc.
  635. "conformance/**/*",
  636. "csharp/src/**/*",
  637. ]),
  638. includes = [
  639. "src/",
  640. ],
  641. linkopts = LINK_OPTS,
  642. deps = [
  643. ":cc_test_protos",
  644. ":protobuf",
  645. ":protoc_lib",
  646. ] + PROTOBUF_DEPS + GTEST_MAIN,
  647. )
  648. ################################################################################
  649. # Java support
  650. ################################################################################
  651. internal_gen_well_known_protos_java(
  652. name = "gen_well_known_protos_java",
  653. deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
  654. visibility = [
  655. "//java:__subpackages__",
  656. ],
  657. )
  658. alias(
  659. name = "protobuf_java",
  660. actual = "//java/core",
  661. visibility = ["//visibility:public"],
  662. )
  663. alias(
  664. name = "protobuf_javalite",
  665. actual = "//java/lite",
  666. visibility = ["//visibility:public"],
  667. )
  668. alias(
  669. name = "protobuf_java_util",
  670. actual = "//java/util",
  671. visibility = ["//visibility:public"],
  672. )
  673. alias(
  674. name = "java_toolchain",
  675. actual = "//java/core:toolchain",
  676. visibility = ["//visibility:public"],
  677. )
  678. alias(
  679. name = "javalite_toolchain",
  680. actual = "//java/lite:toolchain",
  681. visibility = ["//visibility:public"],
  682. )
  683. ################################################################################
  684. # Python support
  685. ################################################################################
  686. py_library(
  687. name = "python_srcs",
  688. srcs = glob(
  689. [
  690. "python/google/**/*.py",
  691. ],
  692. exclude = [
  693. "python/google/protobuf/**/__init__.py",
  694. "python/google/protobuf/internal/*_test.py",
  695. "python/google/protobuf/internal/test_util.py",
  696. ],
  697. ),
  698. imports = ["python"],
  699. srcs_version = "PY2AND3",
  700. )
  701. cc_binary(
  702. name = "python/google/protobuf/internal/_api_implementation.so",
  703. srcs = ["python/google/protobuf/internal/api_implementation.cc"],
  704. copts = COPTS + [
  705. "-DPYTHON_PROTO2_CPP_IMPL_V2",
  706. ],
  707. linkshared = 1,
  708. linkstatic = 1,
  709. deps = select({
  710. "//conditions:default": [],
  711. ":use_fast_cpp_protos": ["//external:python_headers"],
  712. }),
  713. )
  714. cc_binary(
  715. name = "python/google/protobuf/pyext/_message.so",
  716. srcs = glob([
  717. "python/google/protobuf/pyext/*.cc",
  718. "python/google/protobuf/pyext/*.h",
  719. ]),
  720. copts = COPTS + [
  721. "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
  722. ] + select({
  723. "//conditions:default": [],
  724. ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
  725. }),
  726. includes = [
  727. "python/",
  728. "src/",
  729. ],
  730. linkshared = 1,
  731. linkstatic = 1,
  732. deps = [
  733. ":protobuf",
  734. ":proto_api",
  735. ] + select({
  736. "//conditions:default": [],
  737. ":use_fast_cpp_protos": ["//external:python_headers"],
  738. }),
  739. )
  740. config_setting(
  741. name = "use_fast_cpp_protos",
  742. values = {
  743. "define": "use_fast_cpp_protos=true",
  744. },
  745. visibility = [
  746. # Public, but Protobuf only visibility.
  747. "//:__subpackages__",
  748. ],
  749. )
  750. config_setting(
  751. name = "allow_oversize_protos",
  752. values = {
  753. "define": "allow_oversize_protos=true",
  754. },
  755. visibility = [
  756. # Public, but Protobuf only visibility.
  757. "//:__subpackages__",
  758. ],
  759. )
  760. # Copy the builtin proto files from src/google/protobuf to
  761. # python/google/protobuf. This way, the generated Python sources will be in the
  762. # same directory as the Python runtime sources. This is necessary for the
  763. # modules to be imported correctly since they are all part of the same Python
  764. # package.
  765. internal_copied_filegroup(
  766. name = "protos_python",
  767. srcs = WELL_KNOWN_PROTOS,
  768. dest = "python",
  769. strip_prefix = "src",
  770. )
  771. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  772. # which case we can simply add :protos_python in srcs.
  773. COPIED_WELL_KNOWN_PROTOS = ["python/" + s[4:] for s in WELL_KNOWN_PROTOS]
  774. py_proto_library(
  775. name = "protobuf_python",
  776. srcs = COPIED_WELL_KNOWN_PROTOS,
  777. include = "python",
  778. data = select({
  779. "//conditions:default": [],
  780. ":use_fast_cpp_protos": [
  781. ":python/google/protobuf/internal/_api_implementation.so",
  782. ":python/google/protobuf/pyext/_message.so",
  783. ],
  784. }),
  785. default_runtime = "",
  786. protoc = ":protoc",
  787. py_extra_srcs = glob(["python/**/__init__.py"]),
  788. py_libs = [
  789. ":python_srcs",
  790. "@six//:six",
  791. ],
  792. srcs_version = "PY2AND3",
  793. visibility = ["//visibility:public"],
  794. )
  795. # Copy the test proto files from src/google/protobuf to
  796. # python/google/protobuf. This way, the generated Python sources will be in the
  797. # same directory as the Python runtime sources. This is necessary for the
  798. # modules to be imported correctly by the tests since they are all part of the
  799. # same Python package.
  800. internal_copied_filegroup(
  801. name = "protos_python_test",
  802. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  803. dest = "python",
  804. strip_prefix = "src",
  805. )
  806. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  807. # which case we can simply add :protos_python_test in srcs.
  808. COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  809. COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
  810. py_proto_library(
  811. name = "python_common_test_protos",
  812. srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
  813. include = "python",
  814. default_runtime = "",
  815. protoc = ":protoc",
  816. srcs_version = "PY2AND3",
  817. deps = [":protobuf_python"],
  818. )
  819. py_proto_library(
  820. name = "python_specific_test_protos",
  821. srcs = glob([
  822. "python/google/protobuf/internal/*.proto",
  823. "python/google/protobuf/internal/import_test_package/*.proto",
  824. ]),
  825. include = "python",
  826. default_runtime = ":protobuf_python",
  827. protoc = ":protoc",
  828. srcs_version = "PY2AND3",
  829. deps = [":python_common_test_protos"],
  830. )
  831. py_library(
  832. name = "python_tests",
  833. srcs = glob(
  834. [
  835. "python/google/protobuf/internal/*_test.py",
  836. "python/google/protobuf/internal/test_util.py",
  837. "python/google/protobuf/internal/import_test_package/__init__.py",
  838. ],
  839. ),
  840. imports = ["python"],
  841. srcs_version = "PY2AND3",
  842. deps = [
  843. ":protobuf_python",
  844. ":python_common_test_protos",
  845. ":python_specific_test_protos",
  846. ],
  847. )
  848. internal_protobuf_py_tests(
  849. name = "python_tests_batch",
  850. data = glob([
  851. "src/google/protobuf/**/*",
  852. ]),
  853. modules = [
  854. "descriptor_database_test",
  855. "descriptor_pool_test",
  856. "descriptor_test",
  857. "generator_test",
  858. "json_format_test",
  859. "message_factory_test",
  860. "message_test",
  861. "proto_builder_test",
  862. "reflection_test",
  863. "service_reflection_test",
  864. "symbol_database_test",
  865. "text_encoding_test",
  866. "text_format_test",
  867. "unknown_fields_test",
  868. "wire_format_test",
  869. ],
  870. deps = [":python_tests"],
  871. )
  872. cc_library(
  873. name = "proto_api",
  874. hdrs = ["python/google/protobuf/proto_api.h"],
  875. visibility = ["//visibility:public"],
  876. deps = [
  877. "//external:python_headers",
  878. ],
  879. )
  880. # Note: We use `native_proto_common` here because we depend on an implementation-detail of
  881. # `proto_lang_toolchain`, which may not be available on `proto_common`.
  882. reject_blacklisted_files = hasattr(native_proto_common, "proto_lang_toolchain_rejects_files_do_not_use_or_we_will_break_you_without_mercy")
  883. cc_toolchain_blacklisted_protos = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()] if reject_blacklisted_files else [":well_known_protos"]
  884. proto_lang_toolchain(
  885. name = "cc_toolchain",
  886. blacklisted_protos = cc_toolchain_blacklisted_protos,
  887. command_line = "--cpp_out=$(OUT)",
  888. runtime = ":protobuf",
  889. visibility = ["//visibility:public"],
  890. )
  891. alias(
  892. name = "objectivec",
  893. actual = ":protobuf_objc",
  894. visibility = ["//visibility:public"],
  895. )
  896. objc_library(
  897. name = "protobuf_objc",
  898. hdrs = [
  899. "objectivec/GPBArray.h",
  900. "objectivec/GPBBootstrap.h",
  901. "objectivec/GPBCodedInputStream.h",
  902. "objectivec/GPBCodedOutputStream.h",
  903. "objectivec/GPBDescriptor.h",
  904. "objectivec/GPBDictionary.h",
  905. "objectivec/GPBExtensionInternals.h",
  906. "objectivec/GPBExtensionRegistry.h",
  907. "objectivec/GPBMessage.h",
  908. "objectivec/GPBProtocolBuffers.h",
  909. "objectivec/GPBProtocolBuffers_RuntimeSupport.h",
  910. "objectivec/GPBRootObject.h",
  911. "objectivec/GPBRuntimeTypes.h",
  912. "objectivec/GPBUnknownField.h",
  913. "objectivec/GPBUnknownFieldSet.h",
  914. "objectivec/GPBUtilities.h",
  915. "objectivec/GPBWellKnownTypes.h",
  916. "objectivec/GPBWireFormat.h",
  917. "objectivec/google/protobuf/Any.pbobjc.h",
  918. "objectivec/google/protobuf/Api.pbobjc.h",
  919. "objectivec/google/protobuf/Duration.pbobjc.h",
  920. "objectivec/google/protobuf/Empty.pbobjc.h",
  921. "objectivec/google/protobuf/FieldMask.pbobjc.h",
  922. "objectivec/google/protobuf/SourceContext.pbobjc.h",
  923. "objectivec/google/protobuf/Struct.pbobjc.h",
  924. "objectivec/google/protobuf/Timestamp.pbobjc.h",
  925. "objectivec/google/protobuf/Type.pbobjc.h",
  926. "objectivec/google/protobuf/Wrappers.pbobjc.h",
  927. # Package private headers, but exposed because the generated sources
  928. # need to use them.
  929. "objectivec/GPBArray_PackagePrivate.h",
  930. "objectivec/GPBCodedInputStream_PackagePrivate.h",
  931. "objectivec/GPBCodedOutputStream_PackagePrivate.h",
  932. "objectivec/GPBDescriptor_PackagePrivate.h",
  933. "objectivec/GPBDictionary_PackagePrivate.h",
  934. "objectivec/GPBMessage_PackagePrivate.h",
  935. "objectivec/GPBRootObject_PackagePrivate.h",
  936. "objectivec/GPBUnknownFieldSet_PackagePrivate.h",
  937. "objectivec/GPBUnknownField_PackagePrivate.h",
  938. "objectivec/GPBUtilities_PackagePrivate.h",
  939. ],
  940. copts = [
  941. "-Wno-vla",
  942. ],
  943. includes = [
  944. "objectivec",
  945. ],
  946. non_arc_srcs = [
  947. "objectivec/GPBArray.m",
  948. "objectivec/GPBCodedInputStream.m",
  949. "objectivec/GPBCodedOutputStream.m",
  950. "objectivec/GPBDescriptor.m",
  951. "objectivec/GPBDictionary.m",
  952. "objectivec/GPBExtensionInternals.m",
  953. "objectivec/GPBExtensionRegistry.m",
  954. "objectivec/GPBMessage.m",
  955. "objectivec/GPBRootObject.m",
  956. "objectivec/GPBUnknownField.m",
  957. "objectivec/GPBUnknownFieldSet.m",
  958. "objectivec/GPBUtilities.m",
  959. "objectivec/GPBWellKnownTypes.m",
  960. "objectivec/GPBWireFormat.m",
  961. "objectivec/google/protobuf/Any.pbobjc.m",
  962. "objectivec/google/protobuf/Api.pbobjc.m",
  963. "objectivec/google/protobuf/Duration.pbobjc.m",
  964. "objectivec/google/protobuf/Empty.pbobjc.m",
  965. "objectivec/google/protobuf/FieldMask.pbobjc.m",
  966. "objectivec/google/protobuf/SourceContext.pbobjc.m",
  967. "objectivec/google/protobuf/Struct.pbobjc.m",
  968. "objectivec/google/protobuf/Timestamp.pbobjc.m",
  969. "objectivec/google/protobuf/Type.pbobjc.m",
  970. "objectivec/google/protobuf/Wrappers.pbobjc.m",
  971. ],
  972. visibility = ["//visibility:public"],
  973. )
  974. ################################################################################
  975. # Test generated proto support
  976. ################################################################################
  977. genrule(
  978. name = "generated_protos",
  979. srcs = ["src/google/protobuf/unittest_import.proto"],
  980. outs = ["unittest_gen.proto"],
  981. cmd = "cat $(SRCS) | sed 's|google/|src/google/|' > $(OUTS)",
  982. )
  983. proto_library(
  984. name = "generated_protos_proto",
  985. srcs = [
  986. "src/google/protobuf/unittest_import_public.proto",
  987. "unittest_gen.proto",
  988. ],
  989. )
  990. py_proto_library(
  991. name = "generated_protos_py",
  992. srcs = [
  993. "src/google/protobuf/unittest_import_public.proto",
  994. "unittest_gen.proto",
  995. ],
  996. default_runtime = "",
  997. protoc = ":protoc",
  998. )
  999. ################################################################################
  1000. # Conformance tests
  1001. ################################################################################
  1002. proto_library(
  1003. name = "test_messages_proto2_proto",
  1004. srcs = ["src/google/protobuf/test_messages_proto2.proto"],
  1005. visibility = ["//visibility:public"],
  1006. )
  1007. proto_library(
  1008. name = "test_messages_proto3_proto",
  1009. srcs = ["src/google/protobuf/test_messages_proto3.proto"],
  1010. visibility = ["//visibility:public"],
  1011. deps = [
  1012. ":any_proto",
  1013. ":duration_proto",
  1014. ":field_mask_proto",
  1015. ":struct_proto",
  1016. ":timestamp_proto",
  1017. ":wrappers_proto",
  1018. ],
  1019. )
  1020. cc_proto_library(
  1021. name = "test_messages_proto2_proto_cc",
  1022. srcs = ["src/google/protobuf/test_messages_proto2.proto"],
  1023. )
  1024. cc_proto_library(
  1025. name = "test_messages_proto3_proto_cc",
  1026. srcs = ["src/google/protobuf/test_messages_proto3.proto"],
  1027. deps = [
  1028. ":cc_wkt_protos",
  1029. ],
  1030. )
  1031. proto_library(
  1032. name = "conformance_proto",
  1033. srcs = ["conformance/conformance.proto"],
  1034. visibility = ["//visibility:public"],
  1035. )
  1036. cc_proto_library(
  1037. name = "conformance_proto_cc",
  1038. srcs = ["conformance/conformance.proto"],
  1039. )
  1040. cc_library(
  1041. name = "jsoncpp",
  1042. srcs = ["conformance/third_party/jsoncpp/jsoncpp.cpp"],
  1043. hdrs = ["conformance/third_party/jsoncpp/json.h"],
  1044. includes = ["conformance"],
  1045. )
  1046. cc_library(
  1047. name = "conformance_test",
  1048. srcs = [
  1049. "conformance/conformance_test.cc",
  1050. "conformance/conformance_test_runner.cc",
  1051. ],
  1052. hdrs = [
  1053. "conformance/conformance_test.h",
  1054. ],
  1055. includes = [
  1056. "conformance",
  1057. "src",
  1058. ],
  1059. deps = [":conformance_proto_cc"],
  1060. )
  1061. cc_library(
  1062. name = "binary_json_conformance_suite",
  1063. srcs = ["conformance/binary_json_conformance_suite.cc"],
  1064. hdrs = ["conformance/binary_json_conformance_suite.h"],
  1065. deps = [
  1066. ":conformance_test",
  1067. ":jsoncpp",
  1068. ":test_messages_proto2_proto_cc",
  1069. ":test_messages_proto3_proto_cc",
  1070. ],
  1071. )
  1072. cc_library(
  1073. name = "text_format_conformance_suite",
  1074. srcs = ["conformance/text_format_conformance_suite.cc"],
  1075. hdrs = ["conformance/text_format_conformance_suite.h"],
  1076. deps = [
  1077. ":conformance_test",
  1078. ":test_messages_proto2_proto_cc",
  1079. ":test_messages_proto3_proto_cc",
  1080. ],
  1081. )
  1082. cc_binary(
  1083. name = "conformance_test_runner",
  1084. srcs = ["conformance/conformance_test_main.cc"],
  1085. visibility = ["//visibility:public"],
  1086. deps = [
  1087. ":binary_json_conformance_suite",
  1088. ":conformance_test",
  1089. ":text_format_conformance_suite",
  1090. ],
  1091. )
  1092. sh_test(
  1093. name = "build_files_updated_unittest",
  1094. srcs = [
  1095. "build_files_updated_unittest.sh",
  1096. ],
  1097. data = [
  1098. "BUILD",
  1099. "cmake/extract_includes.bat.in",
  1100. "cmake/libprotobuf.cmake",
  1101. "cmake/libprotobuf-lite.cmake",
  1102. "cmake/libprotoc.cmake",
  1103. "cmake/tests.cmake",
  1104. "src/Makefile.am",
  1105. "update_file_lists.sh",
  1106. ],
  1107. )