BUILD 26 KB

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