BUILD 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. # Bazel (http://bazel.io/) BUILD file for Protobuf.
  2. licenses(["notice"])
  3. ################################################################################
  4. # Protobuf Runtime Library
  5. ################################################################################
  6. COPTS = [
  7. "-DHAVE_PTHREAD",
  8. "-Wall",
  9. "-Wwrite-strings",
  10. "-Woverloaded-virtual",
  11. "-Wno-sign-compare",
  12. "-Wno-error=unused-function",
  13. ]
  14. # Bazel should provide portable link_opts for pthread.
  15. LINK_OPTS = ["-lpthread"]
  16. load(
  17. "protobuf",
  18. "cc_proto_library",
  19. "py_proto_library",
  20. "internal_copied_filegroup",
  21. "internal_protobuf_py_tests",
  22. )
  23. cc_library(
  24. name = "protobuf_lite",
  25. srcs = [
  26. # AUTOGEN(protobuf_lite_srcs)
  27. "src/google/protobuf/arena.cc",
  28. "src/google/protobuf/arenastring.cc",
  29. "src/google/protobuf/extension_set.cc",
  30. "src/google/protobuf/generated_message_util.cc",
  31. "src/google/protobuf/io/coded_stream.cc",
  32. "src/google/protobuf/io/zero_copy_stream.cc",
  33. "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
  34. "src/google/protobuf/message_lite.cc",
  35. "src/google/protobuf/repeated_field.cc",
  36. "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
  37. "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
  38. "src/google/protobuf/stubs/bytestream.cc",
  39. "src/google/protobuf/stubs/common.cc",
  40. "src/google/protobuf/stubs/int128.cc",
  41. "src/google/protobuf/stubs/once.cc",
  42. "src/google/protobuf/stubs/status.cc",
  43. "src/google/protobuf/stubs/statusor.cc",
  44. "src/google/protobuf/stubs/stringpiece.cc",
  45. "src/google/protobuf/stubs/stringprintf.cc",
  46. "src/google/protobuf/stubs/structurally_valid.cc",
  47. "src/google/protobuf/stubs/strutil.cc",
  48. "src/google/protobuf/stubs/time.cc",
  49. "src/google/protobuf/wire_format_lite.cc",
  50. ],
  51. copts = COPTS,
  52. includes = ["src/"],
  53. linkopts = LINK_OPTS,
  54. visibility = ["//visibility:public"],
  55. )
  56. cc_library(
  57. name = "protobuf",
  58. srcs = [
  59. # AUTOGEN(protobuf_srcs)
  60. "src/google/protobuf/any.cc",
  61. "src/google/protobuf/any.pb.cc",
  62. "src/google/protobuf/api.pb.cc",
  63. "src/google/protobuf/compiler/importer.cc",
  64. "src/google/protobuf/compiler/parser.cc",
  65. "src/google/protobuf/descriptor.cc",
  66. "src/google/protobuf/descriptor.pb.cc",
  67. "src/google/protobuf/descriptor_database.cc",
  68. "src/google/protobuf/duration.pb.cc",
  69. "src/google/protobuf/dynamic_message.cc",
  70. "src/google/protobuf/empty.pb.cc",
  71. "src/google/protobuf/extension_set_heavy.cc",
  72. "src/google/protobuf/field_mask.pb.cc",
  73. "src/google/protobuf/generated_message_reflection.cc",
  74. "src/google/protobuf/io/gzip_stream.cc",
  75. "src/google/protobuf/io/printer.cc",
  76. "src/google/protobuf/io/strtod.cc",
  77. "src/google/protobuf/io/tokenizer.cc",
  78. "src/google/protobuf/io/zero_copy_stream_impl.cc",
  79. "src/google/protobuf/map_field.cc",
  80. "src/google/protobuf/message.cc",
  81. "src/google/protobuf/reflection_ops.cc",
  82. "src/google/protobuf/service.cc",
  83. "src/google/protobuf/source_context.pb.cc",
  84. "src/google/protobuf/struct.pb.cc",
  85. "src/google/protobuf/stubs/mathlimits.cc",
  86. "src/google/protobuf/stubs/substitute.cc",
  87. "src/google/protobuf/text_format.cc",
  88. "src/google/protobuf/timestamp.pb.cc",
  89. "src/google/protobuf/type.pb.cc",
  90. "src/google/protobuf/unknown_field_set.cc",
  91. "src/google/protobuf/util/field_comparator.cc",
  92. "src/google/protobuf/util/field_mask_util.cc",
  93. "src/google/protobuf/util/internal/datapiece.cc",
  94. "src/google/protobuf/util/internal/default_value_objectwriter.cc",
  95. "src/google/protobuf/util/internal/error_listener.cc",
  96. "src/google/protobuf/util/internal/field_mask_utility.cc",
  97. "src/google/protobuf/util/internal/json_escaping.cc",
  98. "src/google/protobuf/util/internal/json_objectwriter.cc",
  99. "src/google/protobuf/util/internal/json_stream_parser.cc",
  100. "src/google/protobuf/util/internal/object_writer.cc",
  101. "src/google/protobuf/util/internal/protostream_objectsource.cc",
  102. "src/google/protobuf/util/internal/protostream_objectwriter.cc",
  103. "src/google/protobuf/util/internal/type_info.cc",
  104. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  105. "src/google/protobuf/util/internal/utility.cc",
  106. "src/google/protobuf/util/json_util.cc",
  107. "src/google/protobuf/util/message_differencer.cc",
  108. "src/google/protobuf/util/time_util.cc",
  109. "src/google/protobuf/util/type_resolver_util.cc",
  110. "src/google/protobuf/wire_format.cc",
  111. "src/google/protobuf/wrappers.pb.cc",
  112. ],
  113. copts = COPTS,
  114. includes = ["src/"],
  115. linkopts = LINK_OPTS,
  116. visibility = ["//visibility:public"],
  117. deps = [":protobuf_lite"],
  118. )
  119. objc_library(
  120. name = "protobuf_objc",
  121. hdrs = ["objectivec/GPBProtocolBuffers.h"],
  122. includes = ["objectivec"],
  123. non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
  124. visibility = ["//visibility:public"],
  125. )
  126. RELATIVE_WELL_KNOWN_PROTOS = [
  127. # AUTOGEN(well_known_protos)
  128. "google/protobuf/any.proto",
  129. "google/protobuf/api.proto",
  130. "google/protobuf/compiler/plugin.proto",
  131. "google/protobuf/descriptor.proto",
  132. "google/protobuf/duration.proto",
  133. "google/protobuf/empty.proto",
  134. "google/protobuf/field_mask.proto",
  135. "google/protobuf/source_context.proto",
  136. "google/protobuf/struct.proto",
  137. "google/protobuf/timestamp.proto",
  138. "google/protobuf/type.proto",
  139. "google/protobuf/wrappers.proto",
  140. ]
  141. WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
  142. cc_proto_library(
  143. name = "cc_wkt_protos",
  144. srcs = WELL_KNOWN_PROTOS,
  145. include = "src",
  146. cc_libs = [":protobuf"],
  147. internal_bootstrap_hack = 1,
  148. protoc = ":protoc",
  149. )
  150. ################################################################################
  151. # Protocol Buffers Compiler
  152. ################################################################################
  153. cc_library(
  154. name = "protoc_lib",
  155. srcs = [
  156. # AUTOGEN(protoc_lib_srcs)
  157. "src/google/protobuf/compiler/code_generator.cc",
  158. "src/google/protobuf/compiler/command_line_interface.cc",
  159. "src/google/protobuf/compiler/cpp/cpp_enum.cc",
  160. "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
  161. "src/google/protobuf/compiler/cpp/cpp_extension.cc",
  162. "src/google/protobuf/compiler/cpp/cpp_field.cc",
  163. "src/google/protobuf/compiler/cpp/cpp_file.cc",
  164. "src/google/protobuf/compiler/cpp/cpp_generator.cc",
  165. "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
  166. "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
  167. "src/google/protobuf/compiler/cpp/cpp_message.cc",
  168. "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
  169. "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
  170. "src/google/protobuf/compiler/cpp/cpp_service.cc",
  171. "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
  172. "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
  173. "src/google/protobuf/compiler/csharp/csharp_enum.cc",
  174. "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
  175. "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
  176. "src/google/protobuf/compiler/csharp/csharp_generator.cc",
  177. "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
  178. "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
  179. "src/google/protobuf/compiler/csharp/csharp_message.cc",
  180. "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
  181. "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
  182. "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
  183. "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
  184. "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
  185. "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
  186. "src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc",
  187. "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
  188. "src/google/protobuf/compiler/java/java_context.cc",
  189. "src/google/protobuf/compiler/java/java_doc_comment.cc",
  190. "src/google/protobuf/compiler/java/java_enum.cc",
  191. "src/google/protobuf/compiler/java/java_enum_field.cc",
  192. "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
  193. "src/google/protobuf/compiler/java/java_enum_lite.cc",
  194. "src/google/protobuf/compiler/java/java_extension.cc",
  195. "src/google/protobuf/compiler/java/java_field.cc",
  196. "src/google/protobuf/compiler/java/java_file.cc",
  197. "src/google/protobuf/compiler/java/java_generator.cc",
  198. "src/google/protobuf/compiler/java/java_generator_factory.cc",
  199. "src/google/protobuf/compiler/java/java_helpers.cc",
  200. "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
  201. "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
  202. "src/google/protobuf/compiler/java/java_map_field.cc",
  203. "src/google/protobuf/compiler/java/java_map_field_lite.cc",
  204. "src/google/protobuf/compiler/java/java_message.cc",
  205. "src/google/protobuf/compiler/java/java_message_builder.cc",
  206. "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
  207. "src/google/protobuf/compiler/java/java_message_field.cc",
  208. "src/google/protobuf/compiler/java/java_message_field_lite.cc",
  209. "src/google/protobuf/compiler/java/java_message_lite.cc",
  210. "src/google/protobuf/compiler/java/java_name_resolver.cc",
  211. "src/google/protobuf/compiler/java/java_primitive_field.cc",
  212. "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
  213. "src/google/protobuf/compiler/java/java_service.cc",
  214. "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
  215. "src/google/protobuf/compiler/java/java_string_field.cc",
  216. "src/google/protobuf/compiler/java/java_string_field_lite.cc",
  217. "src/google/protobuf/compiler/javanano/javanano_enum.cc",
  218. "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
  219. "src/google/protobuf/compiler/javanano/javanano_extension.cc",
  220. "src/google/protobuf/compiler/javanano/javanano_field.cc",
  221. "src/google/protobuf/compiler/javanano/javanano_file.cc",
  222. "src/google/protobuf/compiler/javanano/javanano_generator.cc",
  223. "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
  224. "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
  225. "src/google/protobuf/compiler/javanano/javanano_message.cc",
  226. "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
  227. "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
  228. "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
  229. "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
  230. "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
  231. "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
  232. "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
  233. "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
  234. "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
  235. "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
  236. "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
  237. "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
  238. "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
  239. "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
  240. "src/google/protobuf/compiler/plugin.cc",
  241. "src/google/protobuf/compiler/plugin.pb.cc",
  242. "src/google/protobuf/compiler/python/python_generator.cc",
  243. "src/google/protobuf/compiler/ruby/ruby_generator.cc",
  244. "src/google/protobuf/compiler/subprocess.cc",
  245. "src/google/protobuf/compiler/zip_writer.cc",
  246. ],
  247. copts = COPTS,
  248. includes = ["src/"],
  249. linkopts = LINK_OPTS,
  250. visibility = ["//visibility:public"],
  251. deps = [":protobuf"],
  252. )
  253. cc_binary(
  254. name = "protoc",
  255. srcs = ["src/google/protobuf/compiler/main.cc"],
  256. linkopts = LINK_OPTS,
  257. visibility = ["//visibility:public"],
  258. deps = [":protoc_lib"],
  259. )
  260. ################################################################################
  261. # Tests
  262. ################################################################################
  263. RELATIVE_LITE_TEST_PROTOS = [
  264. # AUTOGEN(lite_test_protos)
  265. "google/protobuf/map_lite_unittest.proto",
  266. "google/protobuf/unittest_import_lite.proto",
  267. "google/protobuf/unittest_import_public_lite.proto",
  268. "google/protobuf/unittest_lite.proto",
  269. "google/protobuf/unittest_no_arena_lite.proto",
  270. ]
  271. LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  272. RELATIVE_TEST_PROTOS = [
  273. # AUTOGEN(test_protos)
  274. "google/protobuf/any_test.proto",
  275. "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
  276. "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
  277. "google/protobuf/map_proto2_unittest.proto",
  278. "google/protobuf/map_unittest.proto",
  279. "google/protobuf/unittest.proto",
  280. "google/protobuf/unittest_arena.proto",
  281. "google/protobuf/unittest_custom_options.proto",
  282. "google/protobuf/unittest_drop_unknown_fields.proto",
  283. "google/protobuf/unittest_embed_optimize_for.proto",
  284. "google/protobuf/unittest_empty.proto",
  285. "google/protobuf/unittest_enormous_descriptor.proto",
  286. "google/protobuf/unittest_import.proto",
  287. "google/protobuf/unittest_import_public.proto",
  288. "google/protobuf/unittest_lite_imports_nonlite.proto",
  289. "google/protobuf/unittest_mset.proto",
  290. "google/protobuf/unittest_mset_wire_format.proto",
  291. "google/protobuf/unittest_no_arena.proto",
  292. "google/protobuf/unittest_no_arena_import.proto",
  293. "google/protobuf/unittest_no_field_presence.proto",
  294. "google/protobuf/unittest_no_generic_services.proto",
  295. "google/protobuf/unittest_optimize_for.proto",
  296. "google/protobuf/unittest_preserve_unknown_enum.proto",
  297. "google/protobuf/unittest_preserve_unknown_enum2.proto",
  298. "google/protobuf/unittest_proto3_arena.proto",
  299. "google/protobuf/unittest_well_known_types.proto",
  300. "google/protobuf/util/internal/testdata/anys.proto",
  301. "google/protobuf/util/internal/testdata/books.proto",
  302. "google/protobuf/util/internal/testdata/default_value.proto",
  303. "google/protobuf/util/internal/testdata/default_value_test.proto",
  304. "google/protobuf/util/internal/testdata/field_mask.proto",
  305. "google/protobuf/util/internal/testdata/maps.proto",
  306. "google/protobuf/util/internal/testdata/oneofs.proto",
  307. "google/protobuf/util/internal/testdata/struct.proto",
  308. "google/protobuf/util/internal/testdata/timestamp_duration.proto",
  309. "google/protobuf/util/json_format_proto3.proto",
  310. ]
  311. TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
  312. cc_proto_library(
  313. name = "cc_test_protos",
  314. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  315. include = "src",
  316. protoc = ":protoc",
  317. deps = [":cc_wkt_protos"],
  318. )
  319. COMMON_TEST_SRCS = [
  320. # AUTOGEN(common_test_srcs)
  321. "src/google/protobuf/arena_test_util.cc",
  322. "src/google/protobuf/map_test_util.cc",
  323. "src/google/protobuf/test_util.cc",
  324. "src/google/protobuf/testing/file.cc",
  325. "src/google/protobuf/testing/googletest.cc",
  326. ]
  327. cc_binary(
  328. name = "test_plugin",
  329. srcs = [
  330. # AUTOGEN(test_plugin_srcs)
  331. "src/google/protobuf/compiler/mock_code_generator.cc",
  332. "src/google/protobuf/compiler/test_plugin.cc",
  333. "src/google/protobuf/testing/file.cc",
  334. ],
  335. deps = [
  336. ":protobuf",
  337. ":protoc_lib",
  338. "//external:gtest",
  339. ],
  340. )
  341. cc_test(
  342. name = "protobuf_test",
  343. srcs = COMMON_TEST_SRCS + [
  344. # AUTOGEN(test_srcs)
  345. "src/google/protobuf/any_test.cc",
  346. "src/google/protobuf/arena_unittest.cc",
  347. "src/google/protobuf/arenastring_unittest.cc",
  348. "src/google/protobuf/compiler/command_line_interface_unittest.cc",
  349. "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
  350. "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
  351. "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
  352. "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
  353. "src/google/protobuf/compiler/importer_unittest.cc",
  354. "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
  355. "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
  356. "src/google/protobuf/compiler/mock_code_generator.cc",
  357. "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
  358. "src/google/protobuf/compiler/parser_unittest.cc",
  359. "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
  360. "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
  361. "src/google/protobuf/descriptor_database_unittest.cc",
  362. "src/google/protobuf/descriptor_unittest.cc",
  363. "src/google/protobuf/drop_unknown_fields_test.cc",
  364. "src/google/protobuf/dynamic_message_unittest.cc",
  365. "src/google/protobuf/extension_set_unittest.cc",
  366. "src/google/protobuf/generated_message_reflection_unittest.cc",
  367. "src/google/protobuf/io/coded_stream_unittest.cc",
  368. "src/google/protobuf/io/printer_unittest.cc",
  369. "src/google/protobuf/io/tokenizer_unittest.cc",
  370. "src/google/protobuf/io/zero_copy_stream_unittest.cc",
  371. "src/google/protobuf/map_field_test.cc",
  372. "src/google/protobuf/map_test.cc",
  373. "src/google/protobuf/message_unittest.cc",
  374. "src/google/protobuf/no_field_presence_test.cc",
  375. "src/google/protobuf/preserve_unknown_enum_test.cc",
  376. "src/google/protobuf/proto3_arena_unittest.cc",
  377. "src/google/protobuf/reflection_ops_unittest.cc",
  378. "src/google/protobuf/repeated_field_reflection_unittest.cc",
  379. "src/google/protobuf/repeated_field_unittest.cc",
  380. "src/google/protobuf/stubs/bytestream_unittest.cc",
  381. "src/google/protobuf/stubs/common_unittest.cc",
  382. "src/google/protobuf/stubs/int128_unittest.cc",
  383. "src/google/protobuf/stubs/once_unittest.cc",
  384. "src/google/protobuf/stubs/status_test.cc",
  385. "src/google/protobuf/stubs/statusor_test.cc",
  386. "src/google/protobuf/stubs/stringpiece_unittest.cc",
  387. "src/google/protobuf/stubs/stringprintf_unittest.cc",
  388. "src/google/protobuf/stubs/structurally_valid_unittest.cc",
  389. "src/google/protobuf/stubs/strutil_unittest.cc",
  390. "src/google/protobuf/stubs/template_util_unittest.cc",
  391. "src/google/protobuf/stubs/time_test.cc",
  392. "src/google/protobuf/stubs/type_traits_unittest.cc",
  393. "src/google/protobuf/text_format_unittest.cc",
  394. "src/google/protobuf/unknown_field_set_unittest.cc",
  395. "src/google/protobuf/util/field_comparator_test.cc",
  396. "src/google/protobuf/util/field_mask_util_test.cc",
  397. "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
  398. "src/google/protobuf/util/internal/json_objectwriter_test.cc",
  399. "src/google/protobuf/util/internal/json_stream_parser_test.cc",
  400. "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
  401. "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
  402. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  403. "src/google/protobuf/util/json_util_test.cc",
  404. "src/google/protobuf/util/time_util_test.cc",
  405. "src/google/protobuf/util/type_resolver_util_test.cc",
  406. "src/google/protobuf/well_known_types_unittest.cc",
  407. "src/google/protobuf/wire_format_unittest.cc",
  408. ],
  409. copts = COPTS,
  410. data = [
  411. ":test_plugin",
  412. ],
  413. includes = [
  414. "src/",
  415. ],
  416. linkopts = LINK_OPTS,
  417. deps = [
  418. ":cc_test_protos",
  419. ":protobuf",
  420. ":protoc_lib",
  421. "//external:gtest_main",
  422. ],
  423. )
  424. ################################################################################
  425. # Java support
  426. ################################################################################
  427. genrule(
  428. name = "generate_java_descriptor_proto",
  429. srcs = ["src/google/protobuf/descriptor.proto"],
  430. outs = ["com/google/protobuf/DescriptorProtos.java"],
  431. cmd = "$(location :protoc) --java_out=$(@D)/../../.. $<",
  432. tools = [":protoc"],
  433. )
  434. java_library(
  435. name = "protobuf_java",
  436. srcs = glob([
  437. "java/src/main/java/com/google/protobuf/*.java",
  438. ]) + [
  439. ":generate_java_descriptor_proto",
  440. ],
  441. visibility = ["//visibility:public"],
  442. )
  443. ################################################################################
  444. # Python support
  445. ################################################################################
  446. # Requires: six for python 2/3 compatibility. `pip install six`
  447. # Hack:
  448. # protoc generated files contain imports like:
  449. # "from google.protobuf.xxx import yyy"
  450. # However, the sources files of the python runtime are not directly under
  451. # "google/protobuf" (they are under python/google/protobuf). We workaround
  452. # this by copying runtime source files into the desired location to workaround
  453. # the import issue. Ideally py_library should support something similiar to the
  454. # "include" attribute in cc_library to inject the PYTHON_PATH for all libraries
  455. # that depend on the target.
  456. #
  457. # If you use python protobuf as a third_party library in your bazel managed
  458. # project, please import the whole package to //google/protobuf in your
  459. # project. Otherwise, bazel disallows generated files out of the current
  460. # package, thus we won't be able to copy protobuf runtime files into
  461. # //google/protobuf/.
  462. internal_copied_filegroup(
  463. name = "python_srcs",
  464. srcs = glob(
  465. [
  466. "python/google/protobuf/*.py",
  467. "python/google/protobuf/**/*.py",
  468. ],
  469. exclude = [
  470. "python/google/protobuf/internal/*_test.py",
  471. "python/google/protobuf/internal/test_util.py",
  472. ],
  473. ),
  474. include = "python",
  475. )
  476. py_proto_library(
  477. name = "protobuf_python",
  478. srcs = WELL_KNOWN_PROTOS,
  479. include = "src",
  480. protoc = ":protoc",
  481. py_extra_srcs = [":python_srcs"],
  482. visibility = ["//visibility:public"],
  483. )
  484. internal_copied_filegroup(
  485. name = "python_test_srcs",
  486. srcs = glob(
  487. [
  488. "python/google/protobuf/internal/*_test.py",
  489. "python/google/protobuf/internal/test_util.py",
  490. ],
  491. ),
  492. include = "python",
  493. )
  494. py_proto_library(
  495. name = "python_common_test_protos",
  496. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  497. include = "src",
  498. protoc = ":protoc",
  499. deps = [":protobuf_python"],
  500. )
  501. py_proto_library(
  502. name = "python_specific_test_protos",
  503. srcs = glob(["python/google/protobuf/internal/*.proto"]),
  504. include = "python",
  505. protoc = ":protoc",
  506. deps = [":python_common_test_protos"],
  507. )
  508. py_library(
  509. name = "python_tests",
  510. srcs = [":python_test_srcs"],
  511. deps = [
  512. ":python_common_test_protos",
  513. ":protobuf_python",
  514. ":python_specific_test_protos",
  515. ],
  516. )
  517. internal_protobuf_py_tests(
  518. name = "python_tests_batch",
  519. modules = [
  520. "descriptor_database_test",
  521. "descriptor_pool_test",
  522. "descriptor_test",
  523. "generator_test",
  524. "json_format_test",
  525. "message_factory_test",
  526. # "message_test", # failed due to testdata path
  527. "proto_builder_test",
  528. # "reflection_test", # failed due to testdata path
  529. "service_reflection_test",
  530. "symbol_database_test",
  531. "text_encoding_test",
  532. # "text_format_test", # failed due to testdata path
  533. "unknown_fields_test",
  534. "wire_format_test",
  535. ],
  536. deps = [":python_tests"],
  537. )