BUILD 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  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/plugin.cc",
  300. "src/google/protobuf/compiler/plugin.pb.cc",
  301. "src/google/protobuf/compiler/python/python_generator.cc",
  302. "src/google/protobuf/compiler/ruby/ruby_generator.cc",
  303. "src/google/protobuf/compiler/subprocess.cc",
  304. "src/google/protobuf/compiler/zip_writer.cc",
  305. ],
  306. copts = COPTS,
  307. includes = ["src/"],
  308. linkopts = LINK_OPTS,
  309. visibility = ["//visibility:public"],
  310. deps = [":protobuf"],
  311. )
  312. cc_binary(
  313. name = "protoc",
  314. srcs = ["src/google/protobuf/compiler/main.cc"],
  315. linkopts = LINK_OPTS,
  316. visibility = ["//visibility:public"],
  317. deps = [":protoc_lib"],
  318. )
  319. ################################################################################
  320. # Tests
  321. ################################################################################
  322. RELATIVE_LITE_TEST_PROTOS = [
  323. # AUTOGEN(lite_test_protos)
  324. "google/protobuf/map_lite_unittest.proto",
  325. "google/protobuf/unittest_import_lite.proto",
  326. "google/protobuf/unittest_import_public_lite.proto",
  327. "google/protobuf/unittest_lite.proto",
  328. "google/protobuf/unittest_no_arena_lite.proto",
  329. ]
  330. LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  331. RELATIVE_TEST_PROTOS = [
  332. # AUTOGEN(test_protos)
  333. "google/protobuf/any_test.proto",
  334. "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
  335. "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
  336. "google/protobuf/map_proto2_unittest.proto",
  337. "google/protobuf/map_unittest.proto",
  338. "google/protobuf/unittest.proto",
  339. "google/protobuf/unittest_arena.proto",
  340. "google/protobuf/unittest_custom_options.proto",
  341. "google/protobuf/unittest_drop_unknown_fields.proto",
  342. "google/protobuf/unittest_embed_optimize_for.proto",
  343. "google/protobuf/unittest_empty.proto",
  344. "google/protobuf/unittest_enormous_descriptor.proto",
  345. "google/protobuf/unittest_import.proto",
  346. "google/protobuf/unittest_import_public.proto",
  347. "google/protobuf/unittest_lite_imports_nonlite.proto",
  348. "google/protobuf/unittest_mset.proto",
  349. "google/protobuf/unittest_mset_wire_format.proto",
  350. "google/protobuf/unittest_no_arena.proto",
  351. "google/protobuf/unittest_no_arena_import.proto",
  352. "google/protobuf/unittest_no_field_presence.proto",
  353. "google/protobuf/unittest_no_generic_services.proto",
  354. "google/protobuf/unittest_optimize_for.proto",
  355. "google/protobuf/unittest_preserve_unknown_enum.proto",
  356. "google/protobuf/unittest_preserve_unknown_enum2.proto",
  357. "google/protobuf/unittest_proto3_arena.proto",
  358. "google/protobuf/unittest_proto3_arena_lite.proto",
  359. "google/protobuf/unittest_proto3_lite.proto",
  360. "google/protobuf/unittest_well_known_types.proto",
  361. "google/protobuf/util/internal/testdata/anys.proto",
  362. "google/protobuf/util/internal/testdata/books.proto",
  363. "google/protobuf/util/internal/testdata/default_value.proto",
  364. "google/protobuf/util/internal/testdata/default_value_test.proto",
  365. "google/protobuf/util/internal/testdata/field_mask.proto",
  366. "google/protobuf/util/internal/testdata/maps.proto",
  367. "google/protobuf/util/internal/testdata/oneofs.proto",
  368. "google/protobuf/util/internal/testdata/struct.proto",
  369. "google/protobuf/util/internal/testdata/timestamp_duration.proto",
  370. "google/protobuf/util/json_format_proto3.proto",
  371. "google/protobuf/util/message_differencer_unittest.proto",
  372. ]
  373. TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
  374. cc_proto_library(
  375. name = "cc_test_protos",
  376. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  377. include = "src",
  378. default_runtime = ":protobuf",
  379. protoc = ":protoc",
  380. deps = [":cc_wkt_protos"],
  381. )
  382. COMMON_TEST_SRCS = [
  383. # AUTOGEN(common_test_srcs)
  384. "src/google/protobuf/arena_test_util.cc",
  385. "src/google/protobuf/map_test_util.cc",
  386. "src/google/protobuf/test_util.cc",
  387. "src/google/protobuf/testing/file.cc",
  388. "src/google/protobuf/testing/googletest.cc",
  389. ]
  390. cc_binary(
  391. name = "test_plugin",
  392. srcs = [
  393. # AUTOGEN(test_plugin_srcs)
  394. "src/google/protobuf/compiler/mock_code_generator.cc",
  395. "src/google/protobuf/compiler/test_plugin.cc",
  396. "src/google/protobuf/testing/file.cc",
  397. ],
  398. deps = [
  399. ":protobuf",
  400. ":protoc_lib",
  401. "//external:gtest",
  402. ],
  403. )
  404. cc_test(
  405. name = "protobuf_test",
  406. srcs = COMMON_TEST_SRCS + [
  407. # AUTOGEN(test_srcs)
  408. "src/google/protobuf/any_test.cc",
  409. "src/google/protobuf/arena_unittest.cc",
  410. "src/google/protobuf/arenastring_unittest.cc",
  411. "src/google/protobuf/compiler/command_line_interface_unittest.cc",
  412. "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
  413. "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
  414. "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
  415. "src/google/protobuf/compiler/cpp/metadata_test.cc",
  416. "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
  417. "src/google/protobuf/compiler/importer_unittest.cc",
  418. "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
  419. "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
  420. "src/google/protobuf/compiler/mock_code_generator.cc",
  421. "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
  422. "src/google/protobuf/compiler/parser_unittest.cc",
  423. "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
  424. "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
  425. "src/google/protobuf/descriptor_database_unittest.cc",
  426. "src/google/protobuf/descriptor_unittest.cc",
  427. "src/google/protobuf/drop_unknown_fields_test.cc",
  428. "src/google/protobuf/dynamic_message_unittest.cc",
  429. "src/google/protobuf/extension_set_unittest.cc",
  430. "src/google/protobuf/generated_message_reflection_unittest.cc",
  431. "src/google/protobuf/io/coded_stream_unittest.cc",
  432. "src/google/protobuf/io/printer_unittest.cc",
  433. "src/google/protobuf/io/tokenizer_unittest.cc",
  434. "src/google/protobuf/io/zero_copy_stream_unittest.cc",
  435. "src/google/protobuf/map_field_test.cc",
  436. "src/google/protobuf/map_test.cc",
  437. "src/google/protobuf/message_unittest.cc",
  438. "src/google/protobuf/no_field_presence_test.cc",
  439. "src/google/protobuf/preserve_unknown_enum_test.cc",
  440. "src/google/protobuf/proto3_arena_lite_unittest.cc",
  441. "src/google/protobuf/proto3_arena_unittest.cc",
  442. "src/google/protobuf/proto3_lite_unittest.cc",
  443. "src/google/protobuf/reflection_ops_unittest.cc",
  444. "src/google/protobuf/repeated_field_reflection_unittest.cc",
  445. "src/google/protobuf/repeated_field_unittest.cc",
  446. "src/google/protobuf/stubs/bytestream_unittest.cc",
  447. "src/google/protobuf/stubs/common_unittest.cc",
  448. "src/google/protobuf/stubs/int128_unittest.cc",
  449. "src/google/protobuf/stubs/once_unittest.cc",
  450. "src/google/protobuf/stubs/status_test.cc",
  451. "src/google/protobuf/stubs/statusor_test.cc",
  452. "src/google/protobuf/stubs/stringpiece_unittest.cc",
  453. "src/google/protobuf/stubs/stringprintf_unittest.cc",
  454. "src/google/protobuf/stubs/structurally_valid_unittest.cc",
  455. "src/google/protobuf/stubs/strutil_unittest.cc",
  456. "src/google/protobuf/stubs/template_util_unittest.cc",
  457. "src/google/protobuf/stubs/time_test.cc",
  458. "src/google/protobuf/stubs/type_traits_unittest.cc",
  459. "src/google/protobuf/text_format_unittest.cc",
  460. "src/google/protobuf/unknown_field_set_unittest.cc",
  461. "src/google/protobuf/util/field_comparator_test.cc",
  462. "src/google/protobuf/util/field_mask_util_test.cc",
  463. "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
  464. "src/google/protobuf/util/internal/json_objectwriter_test.cc",
  465. "src/google/protobuf/util/internal/json_stream_parser_test.cc",
  466. "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
  467. "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
  468. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  469. "src/google/protobuf/util/json_util_test.cc",
  470. "src/google/protobuf/util/message_differencer_unittest.cc",
  471. "src/google/protobuf/util/time_util_test.cc",
  472. "src/google/protobuf/util/type_resolver_util_test.cc",
  473. "src/google/protobuf/well_known_types_unittest.cc",
  474. "src/google/protobuf/wire_format_unittest.cc",
  475. ],
  476. copts = COPTS,
  477. data = [
  478. ":test_plugin",
  479. ] + glob([
  480. "src/google/protobuf/**/*",
  481. ]),
  482. includes = [
  483. "src/",
  484. ],
  485. linkopts = LINK_OPTS,
  486. deps = [
  487. ":cc_test_protos",
  488. ":protobuf",
  489. ":protoc_lib",
  490. "//external:gtest_main",
  491. ],
  492. )
  493. ################################################################################
  494. # Java support
  495. ################################################################################
  496. internal_gen_well_known_protos_java(
  497. srcs = WELL_KNOWN_PROTOS,
  498. )
  499. java_library(
  500. name = "protobuf_java",
  501. srcs = glob([
  502. "java/core/src/main/java/com/google/protobuf/*.java",
  503. ]) + [
  504. ":gen_well_known_protos_java",
  505. ],
  506. visibility = ["//visibility:public"],
  507. )
  508. java_library(
  509. name = "protobuf_java_util",
  510. srcs = glob([
  511. "java/util/src/main/java/com/google/protobuf/util/*.java",
  512. ]),
  513. deps = [
  514. "protobuf_java",
  515. "//external:gson",
  516. "//external:guava",
  517. ],
  518. visibility = ["//visibility:public"],
  519. )
  520. ################################################################################
  521. # Python support
  522. ################################################################################
  523. py_library(
  524. name = "python_srcs",
  525. srcs = glob(
  526. [
  527. "python/google/protobuf/*.py",
  528. "python/google/protobuf/**/*.py",
  529. ],
  530. exclude = [
  531. "python/google/protobuf/__init__.py",
  532. "python/google/protobuf/**/__init__.py",
  533. "python/google/protobuf/internal/*_test.py",
  534. "python/google/protobuf/internal/test_util.py",
  535. ],
  536. ),
  537. srcs_version = "PY2AND3",
  538. imports = ["python"],
  539. )
  540. cc_binary(
  541. name = "internal/_api_implementation.so",
  542. srcs = ["python/google/protobuf/internal/api_implementation.cc"],
  543. copts = COPTS + [
  544. "-DPYTHON_PROTO2_CPP_IMPL_V2",
  545. ],
  546. linkshared = 1,
  547. linkstatic = 1,
  548. deps = select({
  549. "//conditions:default": [],
  550. ":use_fast_cpp_protos": ["//external:python_headers"],
  551. }),
  552. )
  553. cc_binary(
  554. name = "pyext/_message.so",
  555. srcs = glob([
  556. "python/google/protobuf/pyext/*.cc",
  557. "python/google/protobuf/pyext/*.h",
  558. ]),
  559. copts = COPTS + [
  560. "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
  561. ] + select({
  562. "//conditions:default": [],
  563. ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
  564. }),
  565. includes = [
  566. "python/",
  567. "src/",
  568. ],
  569. linkshared = 1,
  570. linkstatic = 1,
  571. deps = [
  572. ":protobuf",
  573. ] + select({
  574. "//conditions:default": [],
  575. ":use_fast_cpp_protos": ["//external:python_headers"],
  576. }),
  577. )
  578. config_setting(
  579. name = "use_fast_cpp_protos",
  580. values = {
  581. "define": "use_fast_cpp_protos=true",
  582. },
  583. )
  584. config_setting(
  585. name = "allow_oversize_protos",
  586. values = {
  587. "define": "allow_oversize_protos=true",
  588. },
  589. )
  590. # Copy the builtin proto files from src/google/protobuf to
  591. # python/google/protobuf. This way, the generated Python sources will be in the
  592. # same directory as the Python runtime sources. This is necessary for the
  593. # modules to be imported correctly since they are all part of the same Python
  594. # package.
  595. internal_copied_filegroup(
  596. name = "protos_python",
  597. srcs = WELL_KNOWN_PROTOS,
  598. strip_prefix = "src",
  599. dest = "python",
  600. )
  601. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  602. # which case we can simply add :protos_python in srcs.
  603. COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
  604. py_proto_library(
  605. name = "protobuf_python",
  606. srcs = COPIED_WELL_KNOWN_PROTOS,
  607. include = "python",
  608. data = select({
  609. "//conditions:default": [],
  610. ":use_fast_cpp_protos": [
  611. ":internal/_api_implementation.so",
  612. ":pyext/_message.so",
  613. ],
  614. }),
  615. default_runtime = "",
  616. protoc = ":protoc",
  617. py_libs = [
  618. ":python_srcs",
  619. "//external:six"
  620. ],
  621. srcs_version = "PY2AND3",
  622. visibility = ["//visibility:public"],
  623. )
  624. # Copy the test proto files from src/google/protobuf to
  625. # python/google/protobuf. This way, the generated Python sources will be in the
  626. # same directory as the Python runtime sources. This is necessary for the
  627. # modules to be imported correctly by the tests since they are all part of the
  628. # same Python package.
  629. internal_copied_filegroup(
  630. name = "protos_python_test",
  631. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  632. strip_prefix = "src",
  633. dest = "python",
  634. )
  635. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  636. # which case we can simply add :protos_python_test in srcs.
  637. COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  638. COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
  639. py_proto_library(
  640. name = "python_common_test_protos",
  641. srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
  642. include = "python",
  643. default_runtime = "",
  644. protoc = ":protoc",
  645. srcs_version = "PY2AND3",
  646. deps = [":protobuf_python"],
  647. )
  648. py_proto_library(
  649. name = "python_specific_test_protos",
  650. srcs = glob([
  651. "python/google/protobuf/internal/*.proto",
  652. "python/google/protobuf/internal/import_test_package/*.proto",
  653. ]),
  654. include = "python",
  655. default_runtime = ":protobuf_python",
  656. protoc = ":protoc",
  657. srcs_version = "PY2AND3",
  658. deps = [":python_common_test_protos"],
  659. )
  660. py_library(
  661. name = "python_tests",
  662. srcs = glob(
  663. [
  664. "python/google/protobuf/internal/*_test.py",
  665. "python/google/protobuf/internal/test_util.py",
  666. "python/google/protobuf/internal/import_test_package/__init__.py",
  667. ],
  668. ),
  669. imports = ["python"],
  670. srcs_version = "PY2AND3",
  671. deps = [
  672. ":protobuf_python",
  673. ":python_common_test_protos",
  674. ":python_specific_test_protos",
  675. ],
  676. )
  677. internal_protobuf_py_tests(
  678. name = "python_tests_batch",
  679. data = glob([
  680. "src/google/protobuf/**/*",
  681. ]),
  682. modules = [
  683. "descriptor_database_test",
  684. "descriptor_pool_test",
  685. "descriptor_test",
  686. "generator_test",
  687. "json_format_test",
  688. "message_factory_test",
  689. "message_test",
  690. "proto_builder_test",
  691. "reflection_test",
  692. "service_reflection_test",
  693. "symbol_database_test",
  694. "text_encoding_test",
  695. "text_format_test",
  696. "unknown_fields_test",
  697. "wire_format_test",
  698. ],
  699. deps = [":python_tests"],
  700. )