BUILD 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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_gen_well_known_protos_java",
  21. "internal_protobuf_py_tests",
  22. )
  23. config_setting(
  24. name = "ios_armv7",
  25. values = {
  26. "ios_cpu": "armv7",
  27. },
  28. )
  29. config_setting(
  30. name = "ios_armv7s",
  31. values = {
  32. "ios_cpu": "armv7s",
  33. },
  34. )
  35. config_setting(
  36. name = "ios_arm64",
  37. values = {
  38. "ios_cpu": "arm64",
  39. },
  40. )
  41. IOS_ARM_COPTS = COPTS + [
  42. "-DOS_IOS",
  43. "-miphoneos-version-min=7.0",
  44. "-arch armv7",
  45. "-arch armv7s",
  46. "-arch arm64",
  47. "-D__thread=",
  48. "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/",
  49. ]
  50. cc_library(
  51. name = "protobuf_lite",
  52. srcs = [
  53. # AUTOGEN(protobuf_lite_srcs)
  54. "src/google/protobuf/arena.cc",
  55. "src/google/protobuf/arenastring.cc",
  56. "src/google/protobuf/extension_set.cc",
  57. "src/google/protobuf/generated_message_util.cc",
  58. "src/google/protobuf/io/coded_stream.cc",
  59. "src/google/protobuf/io/zero_copy_stream.cc",
  60. "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
  61. "src/google/protobuf/message_lite.cc",
  62. "src/google/protobuf/repeated_field.cc",
  63. "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
  64. "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
  65. "src/google/protobuf/stubs/bytestream.cc",
  66. "src/google/protobuf/stubs/common.cc",
  67. "src/google/protobuf/stubs/int128.cc",
  68. "src/google/protobuf/stubs/once.cc",
  69. "src/google/protobuf/stubs/status.cc",
  70. "src/google/protobuf/stubs/statusor.cc",
  71. "src/google/protobuf/stubs/stringpiece.cc",
  72. "src/google/protobuf/stubs/stringprintf.cc",
  73. "src/google/protobuf/stubs/structurally_valid.cc",
  74. "src/google/protobuf/stubs/strutil.cc",
  75. "src/google/protobuf/stubs/time.cc",
  76. "src/google/protobuf/wire_format_lite.cc",
  77. ],
  78. hdrs = glob(["src/google/protobuf/**/*.h"]),
  79. copts = select({
  80. ":ios_armv7": IOS_ARM_COPTS,
  81. ":ios_armv7s": IOS_ARM_COPTS,
  82. ":ios_arm64": IOS_ARM_COPTS,
  83. "//conditions:default": COPTS,
  84. }),
  85. includes = ["src/"],
  86. linkopts = LINK_OPTS,
  87. visibility = ["//visibility:public"],
  88. )
  89. cc_library(
  90. name = "protobuf",
  91. srcs = [
  92. # AUTOGEN(protobuf_srcs)
  93. "src/google/protobuf/any.cc",
  94. "src/google/protobuf/any.pb.cc",
  95. "src/google/protobuf/api.pb.cc",
  96. "src/google/protobuf/compiler/importer.cc",
  97. "src/google/protobuf/compiler/parser.cc",
  98. "src/google/protobuf/descriptor.cc",
  99. "src/google/protobuf/descriptor.pb.cc",
  100. "src/google/protobuf/descriptor_database.cc",
  101. "src/google/protobuf/duration.pb.cc",
  102. "src/google/protobuf/dynamic_message.cc",
  103. "src/google/protobuf/empty.pb.cc",
  104. "src/google/protobuf/extension_set_heavy.cc",
  105. "src/google/protobuf/field_mask.pb.cc",
  106. "src/google/protobuf/generated_message_reflection.cc",
  107. "src/google/protobuf/io/gzip_stream.cc",
  108. "src/google/protobuf/io/printer.cc",
  109. "src/google/protobuf/io/strtod.cc",
  110. "src/google/protobuf/io/tokenizer.cc",
  111. "src/google/protobuf/io/zero_copy_stream_impl.cc",
  112. "src/google/protobuf/map_field.cc",
  113. "src/google/protobuf/message.cc",
  114. "src/google/protobuf/reflection_ops.cc",
  115. "src/google/protobuf/service.cc",
  116. "src/google/protobuf/source_context.pb.cc",
  117. "src/google/protobuf/struct.pb.cc",
  118. "src/google/protobuf/stubs/mathlimits.cc",
  119. "src/google/protobuf/stubs/substitute.cc",
  120. "src/google/protobuf/text_format.cc",
  121. "src/google/protobuf/timestamp.pb.cc",
  122. "src/google/protobuf/type.pb.cc",
  123. "src/google/protobuf/unknown_field_set.cc",
  124. "src/google/protobuf/util/field_comparator.cc",
  125. "src/google/protobuf/util/field_mask_util.cc",
  126. "src/google/protobuf/util/internal/datapiece.cc",
  127. "src/google/protobuf/util/internal/default_value_objectwriter.cc",
  128. "src/google/protobuf/util/internal/error_listener.cc",
  129. "src/google/protobuf/util/internal/field_mask_utility.cc",
  130. "src/google/protobuf/util/internal/json_escaping.cc",
  131. "src/google/protobuf/util/internal/json_objectwriter.cc",
  132. "src/google/protobuf/util/internal/json_stream_parser.cc",
  133. "src/google/protobuf/util/internal/object_writer.cc",
  134. "src/google/protobuf/util/internal/proto_writer.cc",
  135. "src/google/protobuf/util/internal/protostream_objectsource.cc",
  136. "src/google/protobuf/util/internal/protostream_objectwriter.cc",
  137. "src/google/protobuf/util/internal/type_info.cc",
  138. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  139. "src/google/protobuf/util/internal/utility.cc",
  140. "src/google/protobuf/util/json_util.cc",
  141. "src/google/protobuf/util/message_differencer.cc",
  142. "src/google/protobuf/util/time_util.cc",
  143. "src/google/protobuf/util/type_resolver_util.cc",
  144. "src/google/protobuf/wire_format.cc",
  145. "src/google/protobuf/wrappers.pb.cc",
  146. ],
  147. hdrs = glob(["src/**/*.h"]),
  148. copts = select({
  149. ":ios_armv7": IOS_ARM_COPTS,
  150. ":ios_armv7s": IOS_ARM_COPTS,
  151. ":ios_arm64": IOS_ARM_COPTS,
  152. "//conditions:default": COPTS,
  153. }),
  154. includes = ["src/"],
  155. linkopts = LINK_OPTS,
  156. visibility = ["//visibility:public"],
  157. deps = [":protobuf_lite"],
  158. )
  159. objc_library(
  160. name = "protobuf_objc",
  161. hdrs = ["objectivec/GPBProtocolBuffers.h"],
  162. includes = ["objectivec"],
  163. non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
  164. visibility = ["//visibility:public"],
  165. )
  166. RELATIVE_WELL_KNOWN_PROTOS = [
  167. # AUTOGEN(well_known_protos)
  168. "google/protobuf/any.proto",
  169. "google/protobuf/api.proto",
  170. "google/protobuf/compiler/plugin.proto",
  171. "google/protobuf/descriptor.proto",
  172. "google/protobuf/duration.proto",
  173. "google/protobuf/empty.proto",
  174. "google/protobuf/field_mask.proto",
  175. "google/protobuf/source_context.proto",
  176. "google/protobuf/struct.proto",
  177. "google/protobuf/timestamp.proto",
  178. "google/protobuf/type.proto",
  179. "google/protobuf/wrappers.proto",
  180. ]
  181. WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
  182. filegroup(
  183. name = "well_known_protos",
  184. srcs = WELL_KNOWN_PROTOS,
  185. visibility = ["//visibility:public"],
  186. )
  187. cc_proto_library(
  188. name = "cc_wkt_protos",
  189. srcs = WELL_KNOWN_PROTOS,
  190. include = "src",
  191. default_runtime = ":protobuf",
  192. internal_bootstrap_hack = 1,
  193. protoc = ":protoc",
  194. visibility = ["//visibility:public"],
  195. )
  196. ################################################################################
  197. # Protocol Buffers Compiler
  198. ################################################################################
  199. cc_library(
  200. name = "protoc_lib",
  201. srcs = [
  202. # AUTOGEN(protoc_lib_srcs)
  203. "src/google/protobuf/compiler/code_generator.cc",
  204. "src/google/protobuf/compiler/command_line_interface.cc",
  205. "src/google/protobuf/compiler/cpp/cpp_enum.cc",
  206. "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
  207. "src/google/protobuf/compiler/cpp/cpp_extension.cc",
  208. "src/google/protobuf/compiler/cpp/cpp_field.cc",
  209. "src/google/protobuf/compiler/cpp/cpp_file.cc",
  210. "src/google/protobuf/compiler/cpp/cpp_generator.cc",
  211. "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
  212. "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
  213. "src/google/protobuf/compiler/cpp/cpp_message.cc",
  214. "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
  215. "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
  216. "src/google/protobuf/compiler/cpp/cpp_service.cc",
  217. "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
  218. "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
  219. "src/google/protobuf/compiler/csharp/csharp_enum.cc",
  220. "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
  221. "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
  222. "src/google/protobuf/compiler/csharp/csharp_generator.cc",
  223. "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
  224. "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
  225. "src/google/protobuf/compiler/csharp/csharp_message.cc",
  226. "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
  227. "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
  228. "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
  229. "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
  230. "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
  231. "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
  232. "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
  233. "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
  234. "src/google/protobuf/compiler/java/java_context.cc",
  235. "src/google/protobuf/compiler/java/java_doc_comment.cc",
  236. "src/google/protobuf/compiler/java/java_enum.cc",
  237. "src/google/protobuf/compiler/java/java_enum_field.cc",
  238. "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
  239. "src/google/protobuf/compiler/java/java_enum_lite.cc",
  240. "src/google/protobuf/compiler/java/java_extension.cc",
  241. "src/google/protobuf/compiler/java/java_field.cc",
  242. "src/google/protobuf/compiler/java/java_file.cc",
  243. "src/google/protobuf/compiler/java/java_generator.cc",
  244. "src/google/protobuf/compiler/java/java_generator_factory.cc",
  245. "src/google/protobuf/compiler/java/java_helpers.cc",
  246. "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
  247. "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
  248. "src/google/protobuf/compiler/java/java_map_field.cc",
  249. "src/google/protobuf/compiler/java/java_map_field_lite.cc",
  250. "src/google/protobuf/compiler/java/java_message.cc",
  251. "src/google/protobuf/compiler/java/java_message_builder.cc",
  252. "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
  253. "src/google/protobuf/compiler/java/java_message_field.cc",
  254. "src/google/protobuf/compiler/java/java_message_field_lite.cc",
  255. "src/google/protobuf/compiler/java/java_message_lite.cc",
  256. "src/google/protobuf/compiler/java/java_name_resolver.cc",
  257. "src/google/protobuf/compiler/java/java_primitive_field.cc",
  258. "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
  259. "src/google/protobuf/compiler/java/java_service.cc",
  260. "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
  261. "src/google/protobuf/compiler/java/java_string_field.cc",
  262. "src/google/protobuf/compiler/java/java_string_field_lite.cc",
  263. "src/google/protobuf/compiler/javanano/javanano_enum.cc",
  264. "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
  265. "src/google/protobuf/compiler/javanano/javanano_extension.cc",
  266. "src/google/protobuf/compiler/javanano/javanano_field.cc",
  267. "src/google/protobuf/compiler/javanano/javanano_file.cc",
  268. "src/google/protobuf/compiler/javanano/javanano_generator.cc",
  269. "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
  270. "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
  271. "src/google/protobuf/compiler/javanano/javanano_message.cc",
  272. "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
  273. "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
  274. "src/google/protobuf/compiler/js/js_generator.cc",
  275. "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
  276. "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
  277. "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
  278. "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
  279. "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
  280. "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
  281. "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
  282. "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
  283. "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
  284. "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
  285. "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
  286. "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
  287. "src/google/protobuf/compiler/plugin.cc",
  288. "src/google/protobuf/compiler/plugin.pb.cc",
  289. "src/google/protobuf/compiler/python/python_generator.cc",
  290. "src/google/protobuf/compiler/ruby/ruby_generator.cc",
  291. "src/google/protobuf/compiler/subprocess.cc",
  292. "src/google/protobuf/compiler/zip_writer.cc",
  293. ],
  294. copts = COPTS,
  295. includes = ["src/"],
  296. linkopts = LINK_OPTS,
  297. visibility = ["//visibility:public"],
  298. deps = [":protobuf"],
  299. )
  300. cc_binary(
  301. name = "protoc",
  302. srcs = ["src/google/protobuf/compiler/main.cc"],
  303. linkopts = LINK_OPTS,
  304. visibility = ["//visibility:public"],
  305. deps = [":protoc_lib"],
  306. )
  307. ################################################################################
  308. # Tests
  309. ################################################################################
  310. RELATIVE_LITE_TEST_PROTOS = [
  311. # AUTOGEN(lite_test_protos)
  312. "google/protobuf/map_lite_unittest.proto",
  313. "google/protobuf/unittest_import_lite.proto",
  314. "google/protobuf/unittest_import_public_lite.proto",
  315. "google/protobuf/unittest_lite.proto",
  316. "google/protobuf/unittest_no_arena_lite.proto",
  317. ]
  318. LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  319. RELATIVE_TEST_PROTOS = [
  320. # AUTOGEN(test_protos)
  321. "google/protobuf/any_test.proto",
  322. "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
  323. "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
  324. "google/protobuf/map_proto2_unittest.proto",
  325. "google/protobuf/map_unittest.proto",
  326. "google/protobuf/unittest.proto",
  327. "google/protobuf/unittest_arena.proto",
  328. "google/protobuf/unittest_custom_options.proto",
  329. "google/protobuf/unittest_drop_unknown_fields.proto",
  330. "google/protobuf/unittest_embed_optimize_for.proto",
  331. "google/protobuf/unittest_empty.proto",
  332. "google/protobuf/unittest_enormous_descriptor.proto",
  333. "google/protobuf/unittest_import.proto",
  334. "google/protobuf/unittest_import_public.proto",
  335. "google/protobuf/unittest_lite_imports_nonlite.proto",
  336. "google/protobuf/unittest_mset.proto",
  337. "google/protobuf/unittest_mset_wire_format.proto",
  338. "google/protobuf/unittest_no_arena.proto",
  339. "google/protobuf/unittest_no_arena_import.proto",
  340. "google/protobuf/unittest_no_field_presence.proto",
  341. "google/protobuf/unittest_no_generic_services.proto",
  342. "google/protobuf/unittest_optimize_for.proto",
  343. "google/protobuf/unittest_preserve_unknown_enum.proto",
  344. "google/protobuf/unittest_preserve_unknown_enum2.proto",
  345. "google/protobuf/unittest_proto3_arena.proto",
  346. "google/protobuf/unittest_well_known_types.proto",
  347. "google/protobuf/util/internal/testdata/anys.proto",
  348. "google/protobuf/util/internal/testdata/books.proto",
  349. "google/protobuf/util/internal/testdata/default_value.proto",
  350. "google/protobuf/util/internal/testdata/default_value_test.proto",
  351. "google/protobuf/util/internal/testdata/field_mask.proto",
  352. "google/protobuf/util/internal/testdata/maps.proto",
  353. "google/protobuf/util/internal/testdata/oneofs.proto",
  354. "google/protobuf/util/internal/testdata/struct.proto",
  355. "google/protobuf/util/internal/testdata/timestamp_duration.proto",
  356. "google/protobuf/util/json_format_proto3.proto",
  357. "google/protobuf/util/message_differencer_unittest.proto",
  358. ]
  359. TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
  360. cc_proto_library(
  361. name = "cc_test_protos",
  362. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  363. include = "src",
  364. default_runtime = ":protobuf",
  365. protoc = ":protoc",
  366. deps = [":cc_wkt_protos"],
  367. )
  368. COMMON_TEST_SRCS = [
  369. # AUTOGEN(common_test_srcs)
  370. "src/google/protobuf/arena_test_util.cc",
  371. "src/google/protobuf/map_test_util.cc",
  372. "src/google/protobuf/test_util.cc",
  373. "src/google/protobuf/testing/file.cc",
  374. "src/google/protobuf/testing/googletest.cc",
  375. ]
  376. cc_binary(
  377. name = "test_plugin",
  378. srcs = [
  379. # AUTOGEN(test_plugin_srcs)
  380. "src/google/protobuf/compiler/mock_code_generator.cc",
  381. "src/google/protobuf/compiler/test_plugin.cc",
  382. "src/google/protobuf/testing/file.cc",
  383. ],
  384. deps = [
  385. ":protobuf",
  386. ":protoc_lib",
  387. "//external:gtest",
  388. ],
  389. )
  390. cc_test(
  391. name = "protobuf_test",
  392. srcs = COMMON_TEST_SRCS + [
  393. # AUTOGEN(test_srcs)
  394. "src/google/protobuf/any_test.cc",
  395. "src/google/protobuf/arena_unittest.cc",
  396. "src/google/protobuf/arenastring_unittest.cc",
  397. "src/google/protobuf/compiler/command_line_interface_unittest.cc",
  398. "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
  399. "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
  400. "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
  401. "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
  402. "src/google/protobuf/compiler/importer_unittest.cc",
  403. "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
  404. "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
  405. "src/google/protobuf/compiler/mock_code_generator.cc",
  406. "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
  407. "src/google/protobuf/compiler/parser_unittest.cc",
  408. "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
  409. "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
  410. "src/google/protobuf/descriptor_database_unittest.cc",
  411. "src/google/protobuf/descriptor_unittest.cc",
  412. "src/google/protobuf/drop_unknown_fields_test.cc",
  413. "src/google/protobuf/dynamic_message_unittest.cc",
  414. "src/google/protobuf/extension_set_unittest.cc",
  415. "src/google/protobuf/generated_message_reflection_unittest.cc",
  416. "src/google/protobuf/io/coded_stream_unittest.cc",
  417. "src/google/protobuf/io/printer_unittest.cc",
  418. "src/google/protobuf/io/tokenizer_unittest.cc",
  419. "src/google/protobuf/io/zero_copy_stream_unittest.cc",
  420. "src/google/protobuf/map_field_test.cc",
  421. "src/google/protobuf/map_test.cc",
  422. "src/google/protobuf/message_unittest.cc",
  423. "src/google/protobuf/no_field_presence_test.cc",
  424. "src/google/protobuf/preserve_unknown_enum_test.cc",
  425. "src/google/protobuf/proto3_arena_unittest.cc",
  426. "src/google/protobuf/reflection_ops_unittest.cc",
  427. "src/google/protobuf/repeated_field_reflection_unittest.cc",
  428. "src/google/protobuf/repeated_field_unittest.cc",
  429. "src/google/protobuf/stubs/bytestream_unittest.cc",
  430. "src/google/protobuf/stubs/common_unittest.cc",
  431. "src/google/protobuf/stubs/int128_unittest.cc",
  432. "src/google/protobuf/stubs/once_unittest.cc",
  433. "src/google/protobuf/stubs/status_test.cc",
  434. "src/google/protobuf/stubs/statusor_test.cc",
  435. "src/google/protobuf/stubs/stringpiece_unittest.cc",
  436. "src/google/protobuf/stubs/stringprintf_unittest.cc",
  437. "src/google/protobuf/stubs/structurally_valid_unittest.cc",
  438. "src/google/protobuf/stubs/strutil_unittest.cc",
  439. "src/google/protobuf/stubs/template_util_unittest.cc",
  440. "src/google/protobuf/stubs/time_test.cc",
  441. "src/google/protobuf/stubs/type_traits_unittest.cc",
  442. "src/google/protobuf/text_format_unittest.cc",
  443. "src/google/protobuf/unknown_field_set_unittest.cc",
  444. "src/google/protobuf/util/field_comparator_test.cc",
  445. "src/google/protobuf/util/field_mask_util_test.cc",
  446. "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
  447. "src/google/protobuf/util/internal/json_objectwriter_test.cc",
  448. "src/google/protobuf/util/internal/json_stream_parser_test.cc",
  449. "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
  450. "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
  451. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  452. "src/google/protobuf/util/json_util_test.cc",
  453. "src/google/protobuf/util/message_differencer_unittest.cc",
  454. "src/google/protobuf/util/time_util_test.cc",
  455. "src/google/protobuf/util/type_resolver_util_test.cc",
  456. "src/google/protobuf/well_known_types_unittest.cc",
  457. "src/google/protobuf/wire_format_unittest.cc",
  458. ],
  459. copts = COPTS,
  460. data = [
  461. ":test_plugin",
  462. ] + glob([
  463. "src/google/protobuf/**/*",
  464. ]),
  465. includes = [
  466. "src/",
  467. ],
  468. linkopts = LINK_OPTS,
  469. deps = [
  470. ":cc_test_protos",
  471. ":protobuf",
  472. ":protoc_lib",
  473. "//external:gtest_main",
  474. ],
  475. )
  476. ################################################################################
  477. # Java support
  478. ################################################################################
  479. internal_gen_well_known_protos_java(
  480. srcs = WELL_KNOWN_PROTOS,
  481. )
  482. java_library(
  483. name = "protobuf_java",
  484. srcs = glob([
  485. "java/core/src/main/java/com/google/protobuf/*.java",
  486. ]) + [
  487. ":gen_well_known_protos_java",
  488. ],
  489. visibility = ["//visibility:public"],
  490. )
  491. java_library(
  492. name = "protobuf_java_util",
  493. srcs = glob([
  494. "java/util/src/main/java/com/google/protobuf/util/*.java",
  495. ]),
  496. deps = [
  497. "protobuf_java",
  498. "//external:gson",
  499. "//external:guava",
  500. ],
  501. visibility = ["//visibility:public"],
  502. )
  503. ################################################################################
  504. # Python support
  505. ################################################################################
  506. py_library(
  507. name = "python_srcs",
  508. srcs = glob(
  509. [
  510. "python/google/protobuf/*.py",
  511. "python/google/protobuf/**/*.py",
  512. ],
  513. exclude = [
  514. "python/google/protobuf/internal/*_test.py",
  515. "python/google/protobuf/internal/test_util.py",
  516. ],
  517. ),
  518. imports = ["python"],
  519. )
  520. cc_binary(
  521. name = "internal/_api_implementation.so",
  522. srcs = ["python/google/protobuf/internal/api_implementation.cc"],
  523. copts = COPTS + [
  524. "-DPYTHON_PROTO2_CPP_IMPL_V2",
  525. ],
  526. linkshared = 1,
  527. linkstatic = 1,
  528. deps = select({
  529. "//conditions:default": [],
  530. ":use_fast_cpp_protos": ["//external:python_headers"],
  531. }),
  532. )
  533. cc_binary(
  534. name = "pyext/_message.so",
  535. srcs = glob([
  536. "python/google/protobuf/pyext/*.cc",
  537. "python/google/protobuf/pyext/*.h",
  538. ]),
  539. copts = COPTS + [
  540. "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
  541. ] + select({
  542. "//conditions:default": [],
  543. ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
  544. }),
  545. includes = [
  546. "python/",
  547. "src/",
  548. ],
  549. linkshared = 1,
  550. linkstatic = 1,
  551. deps = [
  552. ":protobuf",
  553. ] + select({
  554. "//conditions:default": [],
  555. ":use_fast_cpp_protos": ["//external:python_headers"],
  556. }),
  557. )
  558. config_setting(
  559. name = "use_fast_cpp_protos",
  560. values = {
  561. "define": "use_fast_cpp_protos=true",
  562. },
  563. )
  564. config_setting(
  565. name = "allow_oversize_protos",
  566. values = {
  567. "define": "allow_oversize_protos=true",
  568. },
  569. )
  570. py_proto_library(
  571. name = "protobuf_python",
  572. srcs = WELL_KNOWN_PROTOS,
  573. include = "src",
  574. data = select({
  575. "//conditions:default": [],
  576. ":use_fast_cpp_protos": [
  577. ":internal/_api_implementation.so",
  578. ":pyext/_message.so",
  579. ],
  580. }),
  581. default_runtime = "",
  582. protoc = ":protoc",
  583. py_libs = [
  584. ":python_srcs",
  585. "//external:six"
  586. ],
  587. srcs_version = "PY2AND3",
  588. visibility = ["//visibility:public"],
  589. )
  590. py_proto_library(
  591. name = "python_common_test_protos",
  592. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  593. include = "src",
  594. default_runtime = "",
  595. protoc = ":protoc",
  596. deps = [":protobuf_python"],
  597. )
  598. py_proto_library(
  599. name = "python_specific_test_protos",
  600. srcs = glob([
  601. "python/google/protobuf/internal/*.proto",
  602. "python/google/protobuf/internal/import_test_package/*.proto",
  603. ]),
  604. include = "python",
  605. default_runtime = ":protobuf_python",
  606. protoc = ":protoc",
  607. deps = [":python_common_test_protos"],
  608. )
  609. py_library(
  610. name = "python_tests",
  611. srcs = glob(
  612. [
  613. "python/google/protobuf/internal/*_test.py",
  614. "python/google/protobuf/internal/test_util.py",
  615. ],
  616. ),
  617. imports = ["python"],
  618. srcs_version = "PY2AND3",
  619. deps = [
  620. ":protobuf_python",
  621. ":python_common_test_protos",
  622. ":python_specific_test_protos",
  623. ],
  624. )
  625. internal_protobuf_py_tests(
  626. name = "python_tests_batch",
  627. data = glob([
  628. "src/google/protobuf/**/*",
  629. ]),
  630. modules = [
  631. "descriptor_database_test",
  632. "descriptor_pool_test",
  633. "descriptor_test",
  634. "generator_test",
  635. "json_format_test",
  636. "message_factory_test",
  637. "message_test",
  638. "proto_builder_test",
  639. "reflection_test",
  640. "service_reflection_test",
  641. "symbol_database_test",
  642. "text_encoding_test",
  643. "text_format_test",
  644. "unknown_fields_test",
  645. "wire_format_test",
  646. ],
  647. deps = [":python_tests"],
  648. )