BUILD 28 KB

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