BUILD 42 KB

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