BUILD 28 KB

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