BUILD 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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_extension_lite.cc",
  251. "src/google/protobuf/compiler/java/java_field.cc",
  252. "src/google/protobuf/compiler/java/java_file.cc",
  253. "src/google/protobuf/compiler/java/java_generator.cc",
  254. "src/google/protobuf/compiler/java/java_generator_factory.cc",
  255. "src/google/protobuf/compiler/java/java_helpers.cc",
  256. "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
  257. "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
  258. "src/google/protobuf/compiler/java/java_map_field.cc",
  259. "src/google/protobuf/compiler/java/java_map_field_lite.cc",
  260. "src/google/protobuf/compiler/java/java_message.cc",
  261. "src/google/protobuf/compiler/java/java_message_builder.cc",
  262. "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
  263. "src/google/protobuf/compiler/java/java_message_field.cc",
  264. "src/google/protobuf/compiler/java/java_message_field_lite.cc",
  265. "src/google/protobuf/compiler/java/java_message_lite.cc",
  266. "src/google/protobuf/compiler/java/java_name_resolver.cc",
  267. "src/google/protobuf/compiler/java/java_primitive_field.cc",
  268. "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
  269. "src/google/protobuf/compiler/java/java_service.cc",
  270. "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
  271. "src/google/protobuf/compiler/java/java_string_field.cc",
  272. "src/google/protobuf/compiler/java/java_string_field_lite.cc",
  273. "src/google/protobuf/compiler/javanano/javanano_enum.cc",
  274. "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
  275. "src/google/protobuf/compiler/javanano/javanano_extension.cc",
  276. "src/google/protobuf/compiler/javanano/javanano_field.cc",
  277. "src/google/protobuf/compiler/javanano/javanano_file.cc",
  278. "src/google/protobuf/compiler/javanano/javanano_generator.cc",
  279. "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
  280. "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
  281. "src/google/protobuf/compiler/javanano/javanano_message.cc",
  282. "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
  283. "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
  284. "src/google/protobuf/compiler/js/js_generator.cc",
  285. "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
  286. "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
  287. "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
  288. "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
  289. "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
  290. "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
  291. "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
  292. "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
  293. "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
  294. "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
  295. "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
  296. "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
  297. "src/google/protobuf/compiler/plugin.cc",
  298. "src/google/protobuf/compiler/plugin.pb.cc",
  299. "src/google/protobuf/compiler/python/python_generator.cc",
  300. "src/google/protobuf/compiler/ruby/ruby_generator.cc",
  301. "src/google/protobuf/compiler/subprocess.cc",
  302. "src/google/protobuf/compiler/zip_writer.cc",
  303. ],
  304. copts = COPTS,
  305. includes = ["src/"],
  306. linkopts = LINK_OPTS,
  307. visibility = ["//visibility:public"],
  308. deps = [":protobuf"],
  309. )
  310. cc_binary(
  311. name = "protoc",
  312. srcs = ["src/google/protobuf/compiler/main.cc"],
  313. linkopts = LINK_OPTS,
  314. visibility = ["//visibility:public"],
  315. deps = [":protoc_lib"],
  316. )
  317. ################################################################################
  318. # Tests
  319. ################################################################################
  320. RELATIVE_LITE_TEST_PROTOS = [
  321. # AUTOGEN(lite_test_protos)
  322. "google/protobuf/map_lite_unittest.proto",
  323. "google/protobuf/unittest_import_lite.proto",
  324. "google/protobuf/unittest_import_public_lite.proto",
  325. "google/protobuf/unittest_lite.proto",
  326. "google/protobuf/unittest_no_arena_lite.proto",
  327. ]
  328. LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  329. RELATIVE_TEST_PROTOS = [
  330. # AUTOGEN(test_protos)
  331. "google/protobuf/any_test.proto",
  332. "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
  333. "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
  334. "google/protobuf/map_proto2_unittest.proto",
  335. "google/protobuf/map_unittest.proto",
  336. "google/protobuf/unittest.proto",
  337. "google/protobuf/unittest_arena.proto",
  338. "google/protobuf/unittest_custom_options.proto",
  339. "google/protobuf/unittest_drop_unknown_fields.proto",
  340. "google/protobuf/unittest_embed_optimize_for.proto",
  341. "google/protobuf/unittest_empty.proto",
  342. "google/protobuf/unittest_enormous_descriptor.proto",
  343. "google/protobuf/unittest_import.proto",
  344. "google/protobuf/unittest_import_public.proto",
  345. "google/protobuf/unittest_lite_imports_nonlite.proto",
  346. "google/protobuf/unittest_mset.proto",
  347. "google/protobuf/unittest_mset_wire_format.proto",
  348. "google/protobuf/unittest_no_arena.proto",
  349. "google/protobuf/unittest_no_arena_import.proto",
  350. "google/protobuf/unittest_no_field_presence.proto",
  351. "google/protobuf/unittest_no_generic_services.proto",
  352. "google/protobuf/unittest_optimize_for.proto",
  353. "google/protobuf/unittest_preserve_unknown_enum.proto",
  354. "google/protobuf/unittest_preserve_unknown_enum2.proto",
  355. "google/protobuf/unittest_proto3_arena.proto",
  356. "google/protobuf/unittest_proto3_arena_lite.proto",
  357. "google/protobuf/unittest_proto3_lite.proto",
  358. "google/protobuf/unittest_well_known_types.proto",
  359. "google/protobuf/util/internal/testdata/anys.proto",
  360. "google/protobuf/util/internal/testdata/books.proto",
  361. "google/protobuf/util/internal/testdata/default_value.proto",
  362. "google/protobuf/util/internal/testdata/default_value_test.proto",
  363. "google/protobuf/util/internal/testdata/field_mask.proto",
  364. "google/protobuf/util/internal/testdata/maps.proto",
  365. "google/protobuf/util/internal/testdata/oneofs.proto",
  366. "google/protobuf/util/internal/testdata/struct.proto",
  367. "google/protobuf/util/internal/testdata/timestamp_duration.proto",
  368. "google/protobuf/util/json_format_proto3.proto",
  369. "google/protobuf/util/message_differencer_unittest.proto",
  370. ]
  371. TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
  372. cc_proto_library(
  373. name = "cc_test_protos",
  374. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  375. include = "src",
  376. default_runtime = ":protobuf",
  377. protoc = ":protoc",
  378. deps = [":cc_wkt_protos"],
  379. )
  380. COMMON_TEST_SRCS = [
  381. # AUTOGEN(common_test_srcs)
  382. "src/google/protobuf/arena_test_util.cc",
  383. "src/google/protobuf/map_test_util.cc",
  384. "src/google/protobuf/test_util.cc",
  385. "src/google/protobuf/testing/file.cc",
  386. "src/google/protobuf/testing/googletest.cc",
  387. ]
  388. cc_binary(
  389. name = "test_plugin",
  390. srcs = [
  391. # AUTOGEN(test_plugin_srcs)
  392. "src/google/protobuf/compiler/mock_code_generator.cc",
  393. "src/google/protobuf/compiler/test_plugin.cc",
  394. "src/google/protobuf/testing/file.cc",
  395. ],
  396. deps = [
  397. ":protobuf",
  398. ":protoc_lib",
  399. "//external:gtest",
  400. ],
  401. )
  402. cc_test(
  403. name = "protobuf_test",
  404. srcs = COMMON_TEST_SRCS + [
  405. # AUTOGEN(test_srcs)
  406. "src/google/protobuf/any_test.cc",
  407. "src/google/protobuf/arena_unittest.cc",
  408. "src/google/protobuf/arenastring_unittest.cc",
  409. "src/google/protobuf/compiler/command_line_interface_unittest.cc",
  410. "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
  411. "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
  412. "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
  413. "src/google/protobuf/compiler/cpp/metadata_test.cc",
  414. "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
  415. "src/google/protobuf/compiler/importer_unittest.cc",
  416. "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
  417. "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
  418. "src/google/protobuf/compiler/mock_code_generator.cc",
  419. "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
  420. "src/google/protobuf/compiler/parser_unittest.cc",
  421. "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
  422. "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
  423. "src/google/protobuf/descriptor_database_unittest.cc",
  424. "src/google/protobuf/descriptor_unittest.cc",
  425. "src/google/protobuf/drop_unknown_fields_test.cc",
  426. "src/google/protobuf/dynamic_message_unittest.cc",
  427. "src/google/protobuf/extension_set_unittest.cc",
  428. "src/google/protobuf/generated_message_reflection_unittest.cc",
  429. "src/google/protobuf/io/coded_stream_unittest.cc",
  430. "src/google/protobuf/io/printer_unittest.cc",
  431. "src/google/protobuf/io/tokenizer_unittest.cc",
  432. "src/google/protobuf/io/zero_copy_stream_unittest.cc",
  433. "src/google/protobuf/map_field_test.cc",
  434. "src/google/protobuf/map_test.cc",
  435. "src/google/protobuf/message_unittest.cc",
  436. "src/google/protobuf/no_field_presence_test.cc",
  437. "src/google/protobuf/preserve_unknown_enum_test.cc",
  438. "src/google/protobuf/proto3_arena_lite_unittest.cc",
  439. "src/google/protobuf/proto3_arena_unittest.cc",
  440. "src/google/protobuf/proto3_lite_unittest.cc",
  441. "src/google/protobuf/reflection_ops_unittest.cc",
  442. "src/google/protobuf/repeated_field_reflection_unittest.cc",
  443. "src/google/protobuf/repeated_field_unittest.cc",
  444. "src/google/protobuf/stubs/bytestream_unittest.cc",
  445. "src/google/protobuf/stubs/common_unittest.cc",
  446. "src/google/protobuf/stubs/int128_unittest.cc",
  447. "src/google/protobuf/stubs/once_unittest.cc",
  448. "src/google/protobuf/stubs/status_test.cc",
  449. "src/google/protobuf/stubs/statusor_test.cc",
  450. "src/google/protobuf/stubs/stringpiece_unittest.cc",
  451. "src/google/protobuf/stubs/stringprintf_unittest.cc",
  452. "src/google/protobuf/stubs/structurally_valid_unittest.cc",
  453. "src/google/protobuf/stubs/strutil_unittest.cc",
  454. "src/google/protobuf/stubs/template_util_unittest.cc",
  455. "src/google/protobuf/stubs/time_test.cc",
  456. "src/google/protobuf/stubs/type_traits_unittest.cc",
  457. "src/google/protobuf/text_format_unittest.cc",
  458. "src/google/protobuf/unknown_field_set_unittest.cc",
  459. "src/google/protobuf/util/field_comparator_test.cc",
  460. "src/google/protobuf/util/field_mask_util_test.cc",
  461. "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
  462. "src/google/protobuf/util/internal/json_objectwriter_test.cc",
  463. "src/google/protobuf/util/internal/json_stream_parser_test.cc",
  464. "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
  465. "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
  466. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  467. "src/google/protobuf/util/json_util_test.cc",
  468. "src/google/protobuf/util/message_differencer_unittest.cc",
  469. "src/google/protobuf/util/time_util_test.cc",
  470. "src/google/protobuf/util/type_resolver_util_test.cc",
  471. "src/google/protobuf/well_known_types_unittest.cc",
  472. "src/google/protobuf/wire_format_unittest.cc",
  473. ],
  474. copts = COPTS,
  475. data = [
  476. ":test_plugin",
  477. ] + glob([
  478. "src/google/protobuf/**/*",
  479. ]),
  480. includes = [
  481. "src/",
  482. ],
  483. linkopts = LINK_OPTS,
  484. deps = [
  485. ":cc_test_protos",
  486. ":protobuf",
  487. ":protoc_lib",
  488. "//external:gtest_main",
  489. ],
  490. )
  491. ################################################################################
  492. # Java support
  493. ################################################################################
  494. internal_gen_well_known_protos_java(
  495. srcs = WELL_KNOWN_PROTOS,
  496. )
  497. java_library(
  498. name = "protobuf_java",
  499. srcs = glob([
  500. "java/core/src/main/java/com/google/protobuf/*.java",
  501. ]) + [
  502. ":gen_well_known_protos_java",
  503. ],
  504. visibility = ["//visibility:public"],
  505. )
  506. java_library(
  507. name = "protobuf_java_util",
  508. srcs = glob([
  509. "java/util/src/main/java/com/google/protobuf/util/*.java",
  510. ]),
  511. deps = [
  512. "protobuf_java",
  513. "//external:gson",
  514. "//external:guava",
  515. ],
  516. visibility = ["//visibility:public"],
  517. )
  518. ################################################################################
  519. # Python support
  520. ################################################################################
  521. py_library(
  522. name = "python_srcs",
  523. srcs = glob(
  524. [
  525. "python/google/protobuf/*.py",
  526. "python/google/protobuf/**/*.py",
  527. ],
  528. exclude = [
  529. "python/google/protobuf/internal/*_test.py",
  530. "python/google/protobuf/internal/test_util.py",
  531. ],
  532. ),
  533. srcs_version = "PY2AND3",
  534. imports = ["python"],
  535. )
  536. cc_binary(
  537. name = "internal/_api_implementation.so",
  538. srcs = ["python/google/protobuf/internal/api_implementation.cc"],
  539. copts = COPTS + [
  540. "-DPYTHON_PROTO2_CPP_IMPL_V2",
  541. ],
  542. linkshared = 1,
  543. linkstatic = 1,
  544. deps = select({
  545. "//conditions:default": [],
  546. ":use_fast_cpp_protos": ["//external:python_headers"],
  547. }),
  548. )
  549. cc_binary(
  550. name = "pyext/_message.so",
  551. srcs = glob([
  552. "python/google/protobuf/pyext/*.cc",
  553. "python/google/protobuf/pyext/*.h",
  554. ]),
  555. copts = COPTS + [
  556. "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
  557. ] + select({
  558. "//conditions:default": [],
  559. ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
  560. }),
  561. includes = [
  562. "python/",
  563. "src/",
  564. ],
  565. linkshared = 1,
  566. linkstatic = 1,
  567. deps = [
  568. ":protobuf",
  569. ] + select({
  570. "//conditions:default": [],
  571. ":use_fast_cpp_protos": ["//external:python_headers"],
  572. }),
  573. )
  574. config_setting(
  575. name = "use_fast_cpp_protos",
  576. values = {
  577. "define": "use_fast_cpp_protos=true",
  578. },
  579. )
  580. config_setting(
  581. name = "allow_oversize_protos",
  582. values = {
  583. "define": "allow_oversize_protos=true",
  584. },
  585. )
  586. py_proto_library(
  587. name = "protobuf_python",
  588. srcs = WELL_KNOWN_PROTOS,
  589. include = "src",
  590. data = select({
  591. "//conditions:default": [],
  592. ":use_fast_cpp_protos": [
  593. ":internal/_api_implementation.so",
  594. ":pyext/_message.so",
  595. ],
  596. }),
  597. default_runtime = "",
  598. protoc = ":protoc",
  599. py_libs = [
  600. ":python_srcs",
  601. "//external:six"
  602. ],
  603. srcs_version = "PY2AND3",
  604. visibility = ["//visibility:public"],
  605. )
  606. py_proto_library(
  607. name = "python_common_test_protos",
  608. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  609. include = "src",
  610. default_runtime = "",
  611. protoc = ":protoc",
  612. srcs_version = "PY2AND3",
  613. deps = [":protobuf_python"],
  614. )
  615. py_proto_library(
  616. name = "python_specific_test_protos",
  617. srcs = glob([
  618. "python/google/protobuf/internal/*.proto",
  619. "python/google/protobuf/internal/import_test_package/*.proto",
  620. ]),
  621. include = "python",
  622. default_runtime = ":protobuf_python",
  623. protoc = ":protoc",
  624. srcs_version = "PY2AND3",
  625. deps = [":python_common_test_protos"],
  626. )
  627. py_library(
  628. name = "python_tests",
  629. srcs = glob(
  630. [
  631. "python/google/protobuf/internal/*_test.py",
  632. "python/google/protobuf/internal/test_util.py",
  633. ],
  634. ),
  635. imports = ["python"],
  636. srcs_version = "PY2AND3",
  637. deps = [
  638. ":protobuf_python",
  639. ":python_common_test_protos",
  640. ":python_specific_test_protos",
  641. ],
  642. )
  643. internal_protobuf_py_tests(
  644. name = "python_tests_batch",
  645. data = glob([
  646. "src/google/protobuf/**/*",
  647. ]),
  648. modules = [
  649. "descriptor_database_test",
  650. "descriptor_pool_test",
  651. "descriptor_test",
  652. "generator_test",
  653. "json_format_test",
  654. "message_factory_test",
  655. "message_test",
  656. "proto_builder_test",
  657. "reflection_test",
  658. "service_reflection_test",
  659. "symbol_database_test",
  660. "text_encoding_test",
  661. "text_format_test",
  662. "unknown_fields_test",
  663. "wire_format_test",
  664. ],
  665. deps = [":python_tests"],
  666. )