BUILD 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  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-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", "-lm"],
  25. })
  26. load(
  27. ":protobuf.bzl",
  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. # This provides just the header files for use in projects that need to build
  171. # shared libraries for dynamic loading. This target is available until Bazel
  172. # adds native support for such use cases.
  173. # TODO(keveman): Remove this target once the support gets added to Bazel.
  174. cc_library(
  175. name = "protobuf_headers",
  176. hdrs = glob(["src/**/*.h"]),
  177. includes = ["src/"],
  178. visibility = ["//visibility:public"],
  179. )
  180. objc_library(
  181. name = "protobuf_objc",
  182. hdrs = ["objectivec/GPBProtocolBuffers.h"],
  183. includes = ["objectivec"],
  184. non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
  185. visibility = ["//visibility:public"],
  186. )
  187. RELATIVE_WELL_KNOWN_PROTOS = [
  188. # AUTOGEN(well_known_protos)
  189. "google/protobuf/any.proto",
  190. "google/protobuf/api.proto",
  191. "google/protobuf/compiler/plugin.proto",
  192. "google/protobuf/descriptor.proto",
  193. "google/protobuf/duration.proto",
  194. "google/protobuf/empty.proto",
  195. "google/protobuf/field_mask.proto",
  196. "google/protobuf/source_context.proto",
  197. "google/protobuf/struct.proto",
  198. "google/protobuf/timestamp.proto",
  199. "google/protobuf/type.proto",
  200. "google/protobuf/wrappers.proto",
  201. ]
  202. WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
  203. filegroup(
  204. name = "well_known_protos",
  205. srcs = WELL_KNOWN_PROTOS,
  206. visibility = ["//visibility:public"],
  207. )
  208. cc_proto_library(
  209. name = "cc_wkt_protos",
  210. srcs = WELL_KNOWN_PROTOS,
  211. include = "src",
  212. default_runtime = ":protobuf",
  213. internal_bootstrap_hack = 1,
  214. protoc = ":protoc",
  215. visibility = ["//visibility:public"],
  216. )
  217. ################################################################################
  218. # Protocol Buffers Compiler
  219. ################################################################################
  220. cc_binary(
  221. name = "js_embed",
  222. srcs = ["src/google/protobuf/compiler/js/embed.cc"],
  223. visibility = ["//visibility:public"],
  224. )
  225. genrule(
  226. name = "generate_js_well_known_types_embed",
  227. srcs = [
  228. "src/google/protobuf/compiler/js/well_known_types/any.js",
  229. "src/google/protobuf/compiler/js/well_known_types/struct.js",
  230. "src/google/protobuf/compiler/js/well_known_types/timestamp.js",
  231. ],
  232. outs = ["src/google/protobuf/compiler/js/well_known_types_embed.cc"],
  233. cmd = "$(location :js_embed) $(SRCS) > $@",
  234. tools = [":js_embed"],
  235. )
  236. cc_library(
  237. name = "protoc_lib",
  238. srcs = [
  239. # AUTOGEN(protoc_lib_srcs)
  240. "src/google/protobuf/compiler/code_generator.cc",
  241. "src/google/protobuf/compiler/command_line_interface.cc",
  242. "src/google/protobuf/compiler/cpp/cpp_enum.cc",
  243. "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
  244. "src/google/protobuf/compiler/cpp/cpp_extension.cc",
  245. "src/google/protobuf/compiler/cpp/cpp_field.cc",
  246. "src/google/protobuf/compiler/cpp/cpp_file.cc",
  247. "src/google/protobuf/compiler/cpp/cpp_generator.cc",
  248. "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
  249. "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
  250. "src/google/protobuf/compiler/cpp/cpp_message.cc",
  251. "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
  252. "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
  253. "src/google/protobuf/compiler/cpp/cpp_service.cc",
  254. "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
  255. "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
  256. "src/google/protobuf/compiler/csharp/csharp_enum.cc",
  257. "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
  258. "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
  259. "src/google/protobuf/compiler/csharp/csharp_generator.cc",
  260. "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
  261. "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
  262. "src/google/protobuf/compiler/csharp/csharp_message.cc",
  263. "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
  264. "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
  265. "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
  266. "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
  267. "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
  268. "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
  269. "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
  270. "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
  271. "src/google/protobuf/compiler/java/java_context.cc",
  272. "src/google/protobuf/compiler/java/java_doc_comment.cc",
  273. "src/google/protobuf/compiler/java/java_enum.cc",
  274. "src/google/protobuf/compiler/java/java_enum_field.cc",
  275. "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
  276. "src/google/protobuf/compiler/java/java_enum_lite.cc",
  277. "src/google/protobuf/compiler/java/java_extension.cc",
  278. "src/google/protobuf/compiler/java/java_extension_lite.cc",
  279. "src/google/protobuf/compiler/java/java_field.cc",
  280. "src/google/protobuf/compiler/java/java_file.cc",
  281. "src/google/protobuf/compiler/java/java_generator.cc",
  282. "src/google/protobuf/compiler/java/java_generator_factory.cc",
  283. "src/google/protobuf/compiler/java/java_helpers.cc",
  284. "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
  285. "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
  286. "src/google/protobuf/compiler/java/java_map_field.cc",
  287. "src/google/protobuf/compiler/java/java_map_field_lite.cc",
  288. "src/google/protobuf/compiler/java/java_message.cc",
  289. "src/google/protobuf/compiler/java/java_message_builder.cc",
  290. "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
  291. "src/google/protobuf/compiler/java/java_message_field.cc",
  292. "src/google/protobuf/compiler/java/java_message_field_lite.cc",
  293. "src/google/protobuf/compiler/java/java_message_lite.cc",
  294. "src/google/protobuf/compiler/java/java_name_resolver.cc",
  295. "src/google/protobuf/compiler/java/java_primitive_field.cc",
  296. "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
  297. "src/google/protobuf/compiler/java/java_service.cc",
  298. "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
  299. "src/google/protobuf/compiler/java/java_string_field.cc",
  300. "src/google/protobuf/compiler/java/java_string_field_lite.cc",
  301. "src/google/protobuf/compiler/javanano/javanano_enum.cc",
  302. "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
  303. "src/google/protobuf/compiler/javanano/javanano_extension.cc",
  304. "src/google/protobuf/compiler/javanano/javanano_field.cc",
  305. "src/google/protobuf/compiler/javanano/javanano_file.cc",
  306. "src/google/protobuf/compiler/javanano/javanano_generator.cc",
  307. "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
  308. "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
  309. "src/google/protobuf/compiler/javanano/javanano_message.cc",
  310. "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
  311. "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
  312. "src/google/protobuf/compiler/js/js_generator.cc",
  313. "src/google/protobuf/compiler/js/well_known_types_embed.cc",
  314. "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
  315. "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
  316. "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
  317. "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
  318. "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
  319. "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
  320. "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
  321. "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
  322. "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
  323. "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
  324. "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
  325. "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
  326. "src/google/protobuf/compiler/php/php_generator.cc",
  327. "src/google/protobuf/compiler/plugin.cc",
  328. "src/google/protobuf/compiler/plugin.pb.cc",
  329. "src/google/protobuf/compiler/python/python_generator.cc",
  330. "src/google/protobuf/compiler/ruby/ruby_generator.cc",
  331. "src/google/protobuf/compiler/subprocess.cc",
  332. "src/google/protobuf/compiler/zip_writer.cc",
  333. ],
  334. copts = COPTS,
  335. includes = ["src/"],
  336. linkopts = LINK_OPTS,
  337. visibility = ["//visibility:public"],
  338. deps = [":protobuf"],
  339. )
  340. cc_binary(
  341. name = "protoc",
  342. srcs = ["src/google/protobuf/compiler/main.cc"],
  343. linkopts = LINK_OPTS,
  344. visibility = ["//visibility:public"],
  345. deps = [":protoc_lib"],
  346. )
  347. ################################################################################
  348. # Tests
  349. ################################################################################
  350. RELATIVE_LITE_TEST_PROTOS = [
  351. # AUTOGEN(lite_test_protos)
  352. "google/protobuf/map_lite_unittest.proto",
  353. "google/protobuf/unittest_import_lite.proto",
  354. "google/protobuf/unittest_import_public_lite.proto",
  355. "google/protobuf/unittest_lite.proto",
  356. "google/protobuf/unittest_no_arena_lite.proto",
  357. ]
  358. LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  359. RELATIVE_TEST_PROTOS = [
  360. # AUTOGEN(test_protos)
  361. "google/protobuf/any_test.proto",
  362. "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
  363. "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
  364. "google/protobuf/map_proto2_unittest.proto",
  365. "google/protobuf/map_unittest.proto",
  366. "google/protobuf/unittest.proto",
  367. "google/protobuf/unittest_arena.proto",
  368. "google/protobuf/unittest_custom_options.proto",
  369. "google/protobuf/unittest_drop_unknown_fields.proto",
  370. "google/protobuf/unittest_embed_optimize_for.proto",
  371. "google/protobuf/unittest_empty.proto",
  372. "google/protobuf/unittest_enormous_descriptor.proto",
  373. "google/protobuf/unittest_import.proto",
  374. "google/protobuf/unittest_import_public.proto",
  375. "google/protobuf/unittest_lite_imports_nonlite.proto",
  376. "google/protobuf/unittest_mset.proto",
  377. "google/protobuf/unittest_mset_wire_format.proto",
  378. "google/protobuf/unittest_no_arena.proto",
  379. "google/protobuf/unittest_no_arena_import.proto",
  380. "google/protobuf/unittest_no_field_presence.proto",
  381. "google/protobuf/unittest_no_generic_services.proto",
  382. "google/protobuf/unittest_optimize_for.proto",
  383. "google/protobuf/unittest_preserve_unknown_enum.proto",
  384. "google/protobuf/unittest_preserve_unknown_enum2.proto",
  385. "google/protobuf/unittest_proto3_arena.proto",
  386. "google/protobuf/unittest_proto3_arena_lite.proto",
  387. "google/protobuf/unittest_proto3_lite.proto",
  388. "google/protobuf/unittest_well_known_types.proto",
  389. "google/protobuf/util/internal/testdata/anys.proto",
  390. "google/protobuf/util/internal/testdata/books.proto",
  391. "google/protobuf/util/internal/testdata/default_value.proto",
  392. "google/protobuf/util/internal/testdata/default_value_test.proto",
  393. "google/protobuf/util/internal/testdata/field_mask.proto",
  394. "google/protobuf/util/internal/testdata/maps.proto",
  395. "google/protobuf/util/internal/testdata/oneofs.proto",
  396. "google/protobuf/util/internal/testdata/proto3.proto",
  397. "google/protobuf/util/internal/testdata/struct.proto",
  398. "google/protobuf/util/internal/testdata/timestamp_duration.proto",
  399. "google/protobuf/util/internal/testdata/wrappers.proto",
  400. "google/protobuf/util/json_format_proto3.proto",
  401. "google/protobuf/util/message_differencer_unittest.proto",
  402. ]
  403. TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
  404. cc_proto_library(
  405. name = "cc_test_protos",
  406. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  407. include = "src",
  408. default_runtime = ":protobuf",
  409. protoc = ":protoc",
  410. deps = [":cc_wkt_protos"],
  411. )
  412. COMMON_TEST_SRCS = [
  413. # AUTOGEN(common_test_srcs)
  414. "src/google/protobuf/arena_test_util.cc",
  415. "src/google/protobuf/map_test_util.cc",
  416. "src/google/protobuf/test_util.cc",
  417. "src/google/protobuf/testing/file.cc",
  418. "src/google/protobuf/testing/googletest.cc",
  419. ]
  420. cc_binary(
  421. name = "test_plugin",
  422. srcs = [
  423. # AUTOGEN(test_plugin_srcs)
  424. "src/google/protobuf/compiler/mock_code_generator.cc",
  425. "src/google/protobuf/compiler/test_plugin.cc",
  426. "src/google/protobuf/testing/file.cc",
  427. ],
  428. deps = [
  429. ":protobuf",
  430. ":protoc_lib",
  431. "//external:gtest",
  432. ],
  433. )
  434. cc_test(
  435. name = "protobuf_test",
  436. srcs = COMMON_TEST_SRCS + [
  437. # AUTOGEN(test_srcs)
  438. "src/google/protobuf/any_test.cc",
  439. "src/google/protobuf/arena_unittest.cc",
  440. "src/google/protobuf/arenastring_unittest.cc",
  441. "src/google/protobuf/compiler/command_line_interface_unittest.cc",
  442. "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
  443. "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
  444. "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
  445. "src/google/protobuf/compiler/cpp/metadata_test.cc",
  446. "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
  447. "src/google/protobuf/compiler/importer_unittest.cc",
  448. "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
  449. "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
  450. "src/google/protobuf/compiler/mock_code_generator.cc",
  451. "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
  452. "src/google/protobuf/compiler/parser_unittest.cc",
  453. "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
  454. "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
  455. "src/google/protobuf/descriptor_database_unittest.cc",
  456. "src/google/protobuf/descriptor_unittest.cc",
  457. "src/google/protobuf/drop_unknown_fields_test.cc",
  458. "src/google/protobuf/dynamic_message_unittest.cc",
  459. "src/google/protobuf/extension_set_unittest.cc",
  460. "src/google/protobuf/generated_message_reflection_unittest.cc",
  461. "src/google/protobuf/io/coded_stream_unittest.cc",
  462. "src/google/protobuf/io/printer_unittest.cc",
  463. "src/google/protobuf/io/tokenizer_unittest.cc",
  464. "src/google/protobuf/io/zero_copy_stream_unittest.cc",
  465. "src/google/protobuf/map_field_test.cc",
  466. "src/google/protobuf/map_test.cc",
  467. "src/google/protobuf/message_unittest.cc",
  468. "src/google/protobuf/no_field_presence_test.cc",
  469. "src/google/protobuf/preserve_unknown_enum_test.cc",
  470. "src/google/protobuf/proto3_arena_lite_unittest.cc",
  471. "src/google/protobuf/proto3_arena_unittest.cc",
  472. "src/google/protobuf/proto3_lite_unittest.cc",
  473. "src/google/protobuf/reflection_ops_unittest.cc",
  474. "src/google/protobuf/repeated_field_reflection_unittest.cc",
  475. "src/google/protobuf/repeated_field_unittest.cc",
  476. "src/google/protobuf/stubs/bytestream_unittest.cc",
  477. "src/google/protobuf/stubs/common_unittest.cc",
  478. "src/google/protobuf/stubs/int128_unittest.cc",
  479. "src/google/protobuf/stubs/once_unittest.cc",
  480. "src/google/protobuf/stubs/status_test.cc",
  481. "src/google/protobuf/stubs/statusor_test.cc",
  482. "src/google/protobuf/stubs/stringpiece_unittest.cc",
  483. "src/google/protobuf/stubs/stringprintf_unittest.cc",
  484. "src/google/protobuf/stubs/structurally_valid_unittest.cc",
  485. "src/google/protobuf/stubs/strutil_unittest.cc",
  486. "src/google/protobuf/stubs/template_util_unittest.cc",
  487. "src/google/protobuf/stubs/time_test.cc",
  488. "src/google/protobuf/stubs/type_traits_unittest.cc",
  489. "src/google/protobuf/text_format_unittest.cc",
  490. "src/google/protobuf/unknown_field_set_unittest.cc",
  491. "src/google/protobuf/util/field_comparator_test.cc",
  492. "src/google/protobuf/util/field_mask_util_test.cc",
  493. "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
  494. "src/google/protobuf/util/internal/json_objectwriter_test.cc",
  495. "src/google/protobuf/util/internal/json_stream_parser_test.cc",
  496. "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
  497. "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
  498. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  499. "src/google/protobuf/util/json_util_test.cc",
  500. "src/google/protobuf/util/message_differencer_unittest.cc",
  501. "src/google/protobuf/util/time_util_test.cc",
  502. "src/google/protobuf/util/type_resolver_util_test.cc",
  503. "src/google/protobuf/well_known_types_unittest.cc",
  504. "src/google/protobuf/wire_format_unittest.cc",
  505. ],
  506. copts = COPTS,
  507. data = [
  508. ":test_plugin",
  509. ] + glob([
  510. "src/google/protobuf/**/*",
  511. ]),
  512. includes = [
  513. "src/",
  514. ],
  515. linkopts = LINK_OPTS,
  516. deps = [
  517. ":cc_test_protos",
  518. ":protobuf",
  519. ":protoc_lib",
  520. "//external:gtest_main",
  521. ],
  522. )
  523. ################################################################################
  524. # Java support
  525. ################################################################################
  526. internal_gen_well_known_protos_java(
  527. srcs = WELL_KNOWN_PROTOS,
  528. )
  529. java_library(
  530. name = "protobuf_java",
  531. srcs = glob([
  532. "java/core/src/main/java/com/google/protobuf/*.java",
  533. ]) + [
  534. ":gen_well_known_protos_java",
  535. ],
  536. visibility = ["//visibility:public"],
  537. )
  538. java_library(
  539. name = "protobuf_java_util",
  540. srcs = glob([
  541. "java/util/src/main/java/com/google/protobuf/util/*.java",
  542. ]),
  543. visibility = ["//visibility:public"],
  544. deps = [
  545. "protobuf_java",
  546. "//external:gson",
  547. "//external:guava",
  548. ],
  549. )
  550. ################################################################################
  551. # Python support
  552. ################################################################################
  553. py_library(
  554. name = "python_srcs",
  555. srcs = glob(
  556. [
  557. "python/google/protobuf/*.py",
  558. "python/google/protobuf/**/*.py",
  559. ],
  560. exclude = [
  561. "python/google/protobuf/__init__.py",
  562. "python/google/protobuf/**/__init__.py",
  563. "python/google/protobuf/internal/*_test.py",
  564. "python/google/protobuf/internal/test_util.py",
  565. ],
  566. ),
  567. imports = ["python"],
  568. srcs_version = "PY2AND3",
  569. )
  570. cc_binary(
  571. name = "python/google/protobuf/internal/_api_implementation.so",
  572. srcs = ["python/google/protobuf/internal/api_implementation.cc"],
  573. copts = COPTS + [
  574. "-DPYTHON_PROTO2_CPP_IMPL_V2",
  575. ],
  576. linkshared = 1,
  577. linkstatic = 1,
  578. deps = select({
  579. "//conditions:default": [],
  580. ":use_fast_cpp_protos": ["//external:python_headers"],
  581. }),
  582. )
  583. cc_binary(
  584. name = "python/google/protobuf/pyext/_message.so",
  585. srcs = glob([
  586. "python/google/protobuf/pyext/*.cc",
  587. "python/google/protobuf/pyext/*.h",
  588. ]),
  589. copts = COPTS + [
  590. "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
  591. ] + select({
  592. "//conditions:default": [],
  593. ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
  594. }),
  595. includes = [
  596. "python/",
  597. "src/",
  598. ],
  599. linkshared = 1,
  600. linkstatic = 1,
  601. deps = [
  602. ":protobuf",
  603. ] + select({
  604. "//conditions:default": [],
  605. ":use_fast_cpp_protos": ["//external:python_headers"],
  606. }),
  607. )
  608. config_setting(
  609. name = "use_fast_cpp_protos",
  610. values = {
  611. "define": "use_fast_cpp_protos=true",
  612. },
  613. )
  614. config_setting(
  615. name = "allow_oversize_protos",
  616. values = {
  617. "define": "allow_oversize_protos=true",
  618. },
  619. )
  620. # Copy the builtin proto files from src/google/protobuf to
  621. # python/google/protobuf. This way, the generated Python sources will be in the
  622. # same directory as the Python runtime sources. This is necessary for the
  623. # modules to be imported correctly since they are all part of the same Python
  624. # package.
  625. internal_copied_filegroup(
  626. name = "protos_python",
  627. srcs = WELL_KNOWN_PROTOS,
  628. dest = "python",
  629. strip_prefix = "src",
  630. )
  631. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  632. # which case we can simply add :protos_python in srcs.
  633. COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
  634. py_proto_library(
  635. name = "protobuf_python",
  636. srcs = COPIED_WELL_KNOWN_PROTOS,
  637. include = "python",
  638. data = select({
  639. "//conditions:default": [],
  640. ":use_fast_cpp_protos": [
  641. ":python/google/protobuf/internal/_api_implementation.so",
  642. ":python/google/protobuf/pyext/_message.so",
  643. ],
  644. }),
  645. default_runtime = "",
  646. protoc = ":protoc",
  647. py_libs = [
  648. ":python_srcs",
  649. "//external:six",
  650. ],
  651. srcs_version = "PY2AND3",
  652. visibility = ["//visibility:public"],
  653. )
  654. # Copy the test proto files from src/google/protobuf to
  655. # python/google/protobuf. This way, the generated Python sources will be in the
  656. # same directory as the Python runtime sources. This is necessary for the
  657. # modules to be imported correctly by the tests since they are all part of the
  658. # same Python package.
  659. internal_copied_filegroup(
  660. name = "protos_python_test",
  661. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  662. dest = "python",
  663. strip_prefix = "src",
  664. )
  665. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  666. # which case we can simply add :protos_python_test in srcs.
  667. COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  668. COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
  669. py_proto_library(
  670. name = "python_common_test_protos",
  671. srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
  672. include = "python",
  673. default_runtime = "",
  674. protoc = ":protoc",
  675. srcs_version = "PY2AND3",
  676. deps = [":protobuf_python"],
  677. )
  678. py_proto_library(
  679. name = "python_specific_test_protos",
  680. srcs = glob([
  681. "python/google/protobuf/internal/*.proto",
  682. "python/google/protobuf/internal/import_test_package/*.proto",
  683. ]),
  684. include = "python",
  685. default_runtime = ":protobuf_python",
  686. protoc = ":protoc",
  687. srcs_version = "PY2AND3",
  688. deps = [":python_common_test_protos"],
  689. )
  690. py_library(
  691. name = "python_tests",
  692. srcs = glob(
  693. [
  694. "python/google/protobuf/internal/*_test.py",
  695. "python/google/protobuf/internal/test_util.py",
  696. "python/google/protobuf/internal/import_test_package/__init__.py",
  697. ],
  698. ),
  699. imports = ["python"],
  700. srcs_version = "PY2AND3",
  701. deps = [
  702. ":protobuf_python",
  703. ":python_common_test_protos",
  704. ":python_specific_test_protos",
  705. ],
  706. )
  707. internal_protobuf_py_tests(
  708. name = "python_tests_batch",
  709. data = glob([
  710. "src/google/protobuf/**/*",
  711. ]),
  712. modules = [
  713. "descriptor_database_test",
  714. "descriptor_pool_test",
  715. "descriptor_test",
  716. "generator_test",
  717. "json_format_test",
  718. "message_factory_test",
  719. "message_test",
  720. "proto_builder_test",
  721. "reflection_test",
  722. "service_reflection_test",
  723. "symbol_database_test",
  724. "text_encoding_test",
  725. "text_format_test",
  726. "unknown_fields_test",
  727. "wire_format_test",
  728. ],
  729. deps = [":python_tests"],
  730. )
  731. proto_lang_toolchain(
  732. name = "cc_toolchain",
  733. command_line = "--cpp_out=$(OUT)",
  734. runtime = ":protobuf",
  735. visibility = ["//visibility:public"],
  736. )
  737. proto_lang_toolchain(
  738. name = "java_toolchain",
  739. command_line = "--java_out=$(OUT)",
  740. runtime = ":protobuf_java",
  741. visibility = ["//visibility:public"],
  742. )