BUILD 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. # Bazel (http://bazel.io/) BUILD file for Protobuf.
  2. licenses(["notice"])
  3. exports_files(["LICENSE"])
  4. ################################################################################
  5. # Protobuf Runtime Library
  6. ################################################################################
  7. WIN_COPTS = [
  8. "/DHAVE_PTHREAD",
  9. "/wd4018", # -Wno-sign-compare
  10. "/wd4514", # -Wno-unused-function
  11. ]
  12. COPTS = select({
  13. ":windows" : WIN_COPTS,
  14. ":windows_msvc" : WIN_COPTS,
  15. "//conditions:default": [
  16. "-DHAVE_PTHREAD",
  17. "-Wall",
  18. "-Wwrite-strings",
  19. "-Woverloaded-virtual",
  20. "-Wno-sign-compare",
  21. "-Wno-unused-function",
  22. ],
  23. })
  24. config_setting(
  25. name = "windows",
  26. values = { "cpu": "x64_windows" },
  27. )
  28. config_setting(
  29. name = "windows_msvc",
  30. values = { "cpu": "x64_windows_msvc" },
  31. )
  32. config_setting(
  33. name = "android",
  34. values = {
  35. "crosstool_top": "//external:android/crosstool",
  36. },
  37. )
  38. # Android builds do not need to link in a separate pthread library.
  39. LINK_OPTS = select({
  40. ":android": [],
  41. "//conditions:default": ["-lpthread", "-lm"],
  42. })
  43. load(
  44. ":protobuf.bzl",
  45. "cc_proto_library",
  46. "py_proto_library",
  47. "internal_copied_filegroup",
  48. "internal_gen_well_known_protos_java",
  49. "internal_protobuf_py_tests",
  50. )
  51. cc_library(
  52. name = "protobuf_lite",
  53. srcs = [
  54. # AUTOGEN(protobuf_lite_srcs)
  55. "src/google/protobuf/arena.cc",
  56. "src/google/protobuf/arenastring.cc",
  57. "src/google/protobuf/extension_set.cc",
  58. "src/google/protobuf/generated_message_table_driven_lite.cc",
  59. "src/google/protobuf/generated_message_util.cc",
  60. "src/google/protobuf/io/coded_stream.cc",
  61. "src/google/protobuf/io/zero_copy_stream.cc",
  62. "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
  63. "src/google/protobuf/message_lite.cc",
  64. "src/google/protobuf/repeated_field.cc",
  65. "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
  66. "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
  67. "src/google/protobuf/stubs/bytestream.cc",
  68. "src/google/protobuf/stubs/common.cc",
  69. "src/google/protobuf/stubs/int128.cc",
  70. "src/google/protobuf/stubs/io_win32.cc",
  71. "src/google/protobuf/stubs/once.cc",
  72. "src/google/protobuf/stubs/status.cc",
  73. "src/google/protobuf/stubs/statusor.cc",
  74. "src/google/protobuf/stubs/stringpiece.cc",
  75. "src/google/protobuf/stubs/stringprintf.cc",
  76. "src/google/protobuf/stubs/structurally_valid.cc",
  77. "src/google/protobuf/stubs/strutil.cc",
  78. "src/google/protobuf/stubs/time.cc",
  79. "src/google/protobuf/wire_format_lite.cc",
  80. ],
  81. hdrs = glob(["src/google/protobuf/**/*.h"]),
  82. copts = COPTS,
  83. includes = ["src/"],
  84. linkopts = LINK_OPTS,
  85. visibility = ["//visibility:public"],
  86. )
  87. cc_library(
  88. name = "protobuf",
  89. srcs = [
  90. # AUTOGEN(protobuf_srcs)
  91. "src/google/protobuf/any.cc",
  92. "src/google/protobuf/any.pb.cc",
  93. "src/google/protobuf/api.pb.cc",
  94. "src/google/protobuf/compiler/importer.cc",
  95. "src/google/protobuf/compiler/parser.cc",
  96. "src/google/protobuf/descriptor.cc",
  97. "src/google/protobuf/descriptor.pb.cc",
  98. "src/google/protobuf/descriptor_database.cc",
  99. "src/google/protobuf/duration.pb.cc",
  100. "src/google/protobuf/dynamic_message.cc",
  101. "src/google/protobuf/empty.pb.cc",
  102. "src/google/protobuf/extension_set_heavy.cc",
  103. "src/google/protobuf/field_mask.pb.cc",
  104. "src/google/protobuf/generated_message_reflection.cc",
  105. "src/google/protobuf/generated_message_table_driven.cc",
  106. "src/google/protobuf/io/gzip_stream.cc",
  107. "src/google/protobuf/io/printer.cc",
  108. "src/google/protobuf/io/strtod.cc",
  109. "src/google/protobuf/io/tokenizer.cc",
  110. "src/google/protobuf/io/zero_copy_stream_impl.cc",
  111. "src/google/protobuf/map_field.cc",
  112. "src/google/protobuf/message.cc",
  113. "src/google/protobuf/reflection_ops.cc",
  114. "src/google/protobuf/service.cc",
  115. "src/google/protobuf/source_context.pb.cc",
  116. "src/google/protobuf/struct.pb.cc",
  117. "src/google/protobuf/stubs/mathlimits.cc",
  118. "src/google/protobuf/stubs/substitute.cc",
  119. "src/google/protobuf/text_format.cc",
  120. "src/google/protobuf/timestamp.pb.cc",
  121. "src/google/protobuf/type.pb.cc",
  122. "src/google/protobuf/unknown_field_set.cc",
  123. "src/google/protobuf/util/delimited_message_util.cc",
  124. "src/google/protobuf/util/field_comparator.cc",
  125. "src/google/protobuf/util/field_mask_util.cc",
  126. "src/google/protobuf/util/internal/datapiece.cc",
  127. "src/google/protobuf/util/internal/default_value_objectwriter.cc",
  128. "src/google/protobuf/util/internal/error_listener.cc",
  129. "src/google/protobuf/util/internal/field_mask_utility.cc",
  130. "src/google/protobuf/util/internal/json_escaping.cc",
  131. "src/google/protobuf/util/internal/json_objectwriter.cc",
  132. "src/google/protobuf/util/internal/json_stream_parser.cc",
  133. "src/google/protobuf/util/internal/object_writer.cc",
  134. "src/google/protobuf/util/internal/proto_writer.cc",
  135. "src/google/protobuf/util/internal/protostream_objectsource.cc",
  136. "src/google/protobuf/util/internal/protostream_objectwriter.cc",
  137. "src/google/protobuf/util/internal/type_info.cc",
  138. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  139. "src/google/protobuf/util/internal/utility.cc",
  140. "src/google/protobuf/util/json_util.cc",
  141. "src/google/protobuf/util/message_differencer.cc",
  142. "src/google/protobuf/util/time_util.cc",
  143. "src/google/protobuf/util/type_resolver_util.cc",
  144. "src/google/protobuf/wire_format.cc",
  145. "src/google/protobuf/wrappers.pb.cc",
  146. ],
  147. hdrs = glob(["src/**/*.h"]),
  148. copts = COPTS,
  149. includes = ["src/"],
  150. linkopts = LINK_OPTS,
  151. visibility = ["//visibility:public"],
  152. deps = [":protobuf_lite"],
  153. )
  154. # This provides just the header files for use in projects that need to build
  155. # shared libraries for dynamic loading. This target is available until Bazel
  156. # adds native support for such use cases.
  157. # TODO(keveman): Remove this target once the support gets added to Bazel.
  158. cc_library(
  159. name = "protobuf_headers",
  160. hdrs = glob(["src/**/*.h"]),
  161. includes = ["src/"],
  162. visibility = ["//visibility:public"],
  163. )
  164. objc_library(
  165. name = "protobuf_objc",
  166. hdrs = ["objectivec/GPBProtocolBuffers.h"],
  167. includes = ["objectivec"],
  168. non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
  169. visibility = ["//visibility:public"],
  170. )
  171. RELATIVE_WELL_KNOWN_PROTOS = [
  172. # AUTOGEN(well_known_protos)
  173. "google/protobuf/any.proto",
  174. "google/protobuf/api.proto",
  175. "google/protobuf/compiler/plugin.proto",
  176. "google/protobuf/descriptor.proto",
  177. "google/protobuf/duration.proto",
  178. "google/protobuf/empty.proto",
  179. "google/protobuf/field_mask.proto",
  180. "google/protobuf/source_context.proto",
  181. "google/protobuf/struct.proto",
  182. "google/protobuf/timestamp.proto",
  183. "google/protobuf/type.proto",
  184. "google/protobuf/wrappers.proto",
  185. ]
  186. WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
  187. filegroup(
  188. name = "well_known_protos",
  189. srcs = WELL_KNOWN_PROTOS,
  190. visibility = ["//visibility:public"],
  191. )
  192. cc_proto_library(
  193. name = "cc_wkt_protos",
  194. srcs = WELL_KNOWN_PROTOS,
  195. include = "src",
  196. default_runtime = ":protobuf",
  197. internal_bootstrap_hack = 1,
  198. protoc = ":protoc",
  199. visibility = ["//visibility:public"],
  200. )
  201. ################################################################################
  202. # Protocol Buffers Compiler
  203. ################################################################################
  204. cc_binary(
  205. name = "js_embed",
  206. srcs = ["src/google/protobuf/compiler/js/embed.cc"],
  207. visibility = ["//visibility:public"],
  208. )
  209. genrule(
  210. name = "generate_js_well_known_types_embed",
  211. srcs = [
  212. "src/google/protobuf/compiler/js/well_known_types/any.js",
  213. "src/google/protobuf/compiler/js/well_known_types/struct.js",
  214. "src/google/protobuf/compiler/js/well_known_types/timestamp.js",
  215. ],
  216. outs = ["src/google/protobuf/compiler/js/well_known_types_embed.cc"],
  217. cmd = "$(location :js_embed) $(SRCS) > $@",
  218. tools = [":js_embed"],
  219. )
  220. cc_library(
  221. name = "protoc_lib",
  222. srcs = [
  223. # AUTOGEN(protoc_lib_srcs)
  224. "src/google/protobuf/compiler/code_generator.cc",
  225. "src/google/protobuf/compiler/command_line_interface.cc",
  226. "src/google/protobuf/compiler/cpp/cpp_enum.cc",
  227. "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
  228. "src/google/protobuf/compiler/cpp/cpp_extension.cc",
  229. "src/google/protobuf/compiler/cpp/cpp_field.cc",
  230. "src/google/protobuf/compiler/cpp/cpp_file.cc",
  231. "src/google/protobuf/compiler/cpp/cpp_generator.cc",
  232. "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
  233. "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
  234. "src/google/protobuf/compiler/cpp/cpp_message.cc",
  235. "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
  236. "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
  237. "src/google/protobuf/compiler/cpp/cpp_service.cc",
  238. "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
  239. "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
  240. "src/google/protobuf/compiler/csharp/csharp_enum.cc",
  241. "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
  242. "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
  243. "src/google/protobuf/compiler/csharp/csharp_generator.cc",
  244. "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
  245. "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
  246. "src/google/protobuf/compiler/csharp/csharp_message.cc",
  247. "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
  248. "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
  249. "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
  250. "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
  251. "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
  252. "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
  253. "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
  254. "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
  255. "src/google/protobuf/compiler/java/java_context.cc",
  256. "src/google/protobuf/compiler/java/java_doc_comment.cc",
  257. "src/google/protobuf/compiler/java/java_enum.cc",
  258. "src/google/protobuf/compiler/java/java_enum_field.cc",
  259. "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
  260. "src/google/protobuf/compiler/java/java_enum_lite.cc",
  261. "src/google/protobuf/compiler/java/java_extension.cc",
  262. "src/google/protobuf/compiler/java/java_extension_lite.cc",
  263. "src/google/protobuf/compiler/java/java_field.cc",
  264. "src/google/protobuf/compiler/java/java_file.cc",
  265. "src/google/protobuf/compiler/java/java_generator.cc",
  266. "src/google/protobuf/compiler/java/java_generator_factory.cc",
  267. "src/google/protobuf/compiler/java/java_helpers.cc",
  268. "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
  269. "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
  270. "src/google/protobuf/compiler/java/java_map_field.cc",
  271. "src/google/protobuf/compiler/java/java_map_field_lite.cc",
  272. "src/google/protobuf/compiler/java/java_message.cc",
  273. "src/google/protobuf/compiler/java/java_message_builder.cc",
  274. "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
  275. "src/google/protobuf/compiler/java/java_message_field.cc",
  276. "src/google/protobuf/compiler/java/java_message_field_lite.cc",
  277. "src/google/protobuf/compiler/java/java_message_lite.cc",
  278. "src/google/protobuf/compiler/java/java_name_resolver.cc",
  279. "src/google/protobuf/compiler/java/java_primitive_field.cc",
  280. "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
  281. "src/google/protobuf/compiler/java/java_service.cc",
  282. "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
  283. "src/google/protobuf/compiler/java/java_string_field.cc",
  284. "src/google/protobuf/compiler/java/java_string_field_lite.cc",
  285. "src/google/protobuf/compiler/javanano/javanano_enum.cc",
  286. "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
  287. "src/google/protobuf/compiler/javanano/javanano_extension.cc",
  288. "src/google/protobuf/compiler/javanano/javanano_field.cc",
  289. "src/google/protobuf/compiler/javanano/javanano_file.cc",
  290. "src/google/protobuf/compiler/javanano/javanano_generator.cc",
  291. "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
  292. "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
  293. "src/google/protobuf/compiler/javanano/javanano_message.cc",
  294. "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
  295. "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
  296. "src/google/protobuf/compiler/js/js_generator.cc",
  297. "src/google/protobuf/compiler/js/well_known_types_embed.cc",
  298. "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
  299. "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
  300. "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
  301. "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
  302. "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
  303. "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
  304. "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
  305. "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
  306. "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
  307. "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
  308. "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
  309. "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
  310. "src/google/protobuf/compiler/php/php_generator.cc",
  311. "src/google/protobuf/compiler/plugin.cc",
  312. "src/google/protobuf/compiler/plugin.pb.cc",
  313. "src/google/protobuf/compiler/python/python_generator.cc",
  314. "src/google/protobuf/compiler/ruby/ruby_generator.cc",
  315. "src/google/protobuf/compiler/subprocess.cc",
  316. "src/google/protobuf/compiler/zip_writer.cc",
  317. ],
  318. copts = COPTS,
  319. includes = ["src/"],
  320. linkopts = LINK_OPTS,
  321. visibility = ["//visibility:public"],
  322. deps = [":protobuf"],
  323. )
  324. cc_binary(
  325. name = "protoc",
  326. srcs = ["src/google/protobuf/compiler/main.cc"],
  327. linkopts = LINK_OPTS,
  328. visibility = ["//visibility:public"],
  329. deps = [":protoc_lib"],
  330. )
  331. ################################################################################
  332. # Tests
  333. ################################################################################
  334. RELATIVE_LITE_TEST_PROTOS = [
  335. # AUTOGEN(lite_test_protos)
  336. "google/protobuf/map_lite_unittest.proto",
  337. "google/protobuf/unittest_import_lite.proto",
  338. "google/protobuf/unittest_import_public_lite.proto",
  339. "google/protobuf/unittest_lite.proto",
  340. "google/protobuf/unittest_no_arena_lite.proto",
  341. ]
  342. LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  343. RELATIVE_TEST_PROTOS = [
  344. # AUTOGEN(test_protos)
  345. "google/protobuf/any_test.proto",
  346. "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
  347. "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
  348. "google/protobuf/map_proto2_unittest.proto",
  349. "google/protobuf/map_unittest.proto",
  350. "google/protobuf/unittest.proto",
  351. "google/protobuf/unittest_arena.proto",
  352. "google/protobuf/unittest_custom_options.proto",
  353. "google/protobuf/unittest_drop_unknown_fields.proto",
  354. "google/protobuf/unittest_embed_optimize_for.proto",
  355. "google/protobuf/unittest_empty.proto",
  356. "google/protobuf/unittest_enormous_descriptor.proto",
  357. "google/protobuf/unittest_import.proto",
  358. "google/protobuf/unittest_import_public.proto",
  359. "google/protobuf/unittest_lazy_dependencies.proto",
  360. "google/protobuf/unittest_lazy_dependencies_custom_option.proto",
  361. "google/protobuf/unittest_lazy_dependencies_enum.proto",
  362. "google/protobuf/unittest_lite_imports_nonlite.proto",
  363. "google/protobuf/unittest_mset.proto",
  364. "google/protobuf/unittest_mset_wire_format.proto",
  365. "google/protobuf/unittest_no_arena.proto",
  366. "google/protobuf/unittest_no_arena_import.proto",
  367. "google/protobuf/unittest_no_field_presence.proto",
  368. "google/protobuf/unittest_no_generic_services.proto",
  369. "google/protobuf/unittest_optimize_for.proto",
  370. "google/protobuf/unittest_preserve_unknown_enum.proto",
  371. "google/protobuf/unittest_preserve_unknown_enum2.proto",
  372. "google/protobuf/unittest_proto3_arena.proto",
  373. "google/protobuf/unittest_proto3_arena_lite.proto",
  374. "google/protobuf/unittest_proto3_lite.proto",
  375. "google/protobuf/unittest_well_known_types.proto",
  376. "google/protobuf/util/internal/testdata/anys.proto",
  377. "google/protobuf/util/internal/testdata/books.proto",
  378. "google/protobuf/util/internal/testdata/default_value.proto",
  379. "google/protobuf/util/internal/testdata/default_value_test.proto",
  380. "google/protobuf/util/internal/testdata/field_mask.proto",
  381. "google/protobuf/util/internal/testdata/maps.proto",
  382. "google/protobuf/util/internal/testdata/oneofs.proto",
  383. "google/protobuf/util/internal/testdata/proto3.proto",
  384. "google/protobuf/util/internal/testdata/struct.proto",
  385. "google/protobuf/util/internal/testdata/timestamp_duration.proto",
  386. "google/protobuf/util/internal/testdata/wrappers.proto",
  387. "google/protobuf/util/json_format_proto3.proto",
  388. "google/protobuf/util/message_differencer_unittest.proto",
  389. ]
  390. TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
  391. cc_proto_library(
  392. name = "cc_test_protos",
  393. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  394. include = "src",
  395. default_runtime = ":protobuf",
  396. protoc = ":protoc",
  397. deps = [":cc_wkt_protos"],
  398. )
  399. COMMON_TEST_SRCS = [
  400. # AUTOGEN(common_test_srcs)
  401. "src/google/protobuf/arena_test_util.cc",
  402. "src/google/protobuf/map_test_util.cc",
  403. "src/google/protobuf/test_util.cc",
  404. "src/google/protobuf/testing/file.cc",
  405. "src/google/protobuf/testing/googletest.cc",
  406. ]
  407. cc_binary(
  408. name = "test_plugin",
  409. srcs = [
  410. # AUTOGEN(test_plugin_srcs)
  411. "src/google/protobuf/compiler/mock_code_generator.cc",
  412. "src/google/protobuf/compiler/test_plugin.cc",
  413. "src/google/protobuf/testing/file.cc",
  414. ],
  415. deps = [
  416. ":protobuf",
  417. ":protoc_lib",
  418. "//external:gtest",
  419. ],
  420. )
  421. cc_test(
  422. name = "win32_test",
  423. srcs = ["src/google/protobuf/stubs/io_win32_unittest.cc"],
  424. deps = [
  425. ":protobuf_lite",
  426. "//external:gtest_main",
  427. ],
  428. tags = ["manual", "windows"],
  429. )
  430. cc_test(
  431. name = "protobuf_test",
  432. srcs = COMMON_TEST_SRCS + [
  433. # AUTOGEN(test_srcs)
  434. "src/google/protobuf/any_test.cc",
  435. "src/google/protobuf/arena_unittest.cc",
  436. "src/google/protobuf/arenastring_unittest.cc",
  437. "src/google/protobuf/compiler/command_line_interface_unittest.cc",
  438. "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
  439. "src/google/protobuf/compiler/cpp/cpp_move_unittest.cc",
  440. "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
  441. "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
  442. "src/google/protobuf/compiler/cpp/metadata_test.cc",
  443. "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc",
  444. "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
  445. "src/google/protobuf/compiler/importer_unittest.cc",
  446. "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
  447. "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
  448. "src/google/protobuf/compiler/mock_code_generator.cc",
  449. "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
  450. "src/google/protobuf/compiler/parser_unittest.cc",
  451. "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
  452. "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
  453. "src/google/protobuf/descriptor_database_unittest.cc",
  454. "src/google/protobuf/descriptor_unittest.cc",
  455. "src/google/protobuf/drop_unknown_fields_test.cc",
  456. "src/google/protobuf/dynamic_message_unittest.cc",
  457. "src/google/protobuf/extension_set_unittest.cc",
  458. "src/google/protobuf/generated_message_reflection_unittest.cc",
  459. "src/google/protobuf/io/coded_stream_unittest.cc",
  460. "src/google/protobuf/io/printer_unittest.cc",
  461. "src/google/protobuf/io/tokenizer_unittest.cc",
  462. "src/google/protobuf/io/zero_copy_stream_unittest.cc",
  463. "src/google/protobuf/map_field_test.cc",
  464. "src/google/protobuf/map_test.cc",
  465. "src/google/protobuf/message_unittest.cc",
  466. "src/google/protobuf/no_field_presence_test.cc",
  467. "src/google/protobuf/preserve_unknown_enum_test.cc",
  468. "src/google/protobuf/proto3_arena_lite_unittest.cc",
  469. "src/google/protobuf/proto3_arena_unittest.cc",
  470. "src/google/protobuf/proto3_lite_unittest.cc",
  471. "src/google/protobuf/reflection_ops_unittest.cc",
  472. "src/google/protobuf/repeated_field_reflection_unittest.cc",
  473. "src/google/protobuf/repeated_field_unittest.cc",
  474. "src/google/protobuf/stubs/bytestream_unittest.cc",
  475. "src/google/protobuf/stubs/common_unittest.cc",
  476. "src/google/protobuf/stubs/int128_unittest.cc",
  477. "src/google/protobuf/stubs/io_win32_unittest.cc",
  478. "src/google/protobuf/stubs/once_unittest.cc",
  479. "src/google/protobuf/stubs/status_test.cc",
  480. "src/google/protobuf/stubs/statusor_test.cc",
  481. "src/google/protobuf/stubs/stringpiece_unittest.cc",
  482. "src/google/protobuf/stubs/stringprintf_unittest.cc",
  483. "src/google/protobuf/stubs/structurally_valid_unittest.cc",
  484. "src/google/protobuf/stubs/strutil_unittest.cc",
  485. "src/google/protobuf/stubs/template_util_unittest.cc",
  486. "src/google/protobuf/stubs/time_test.cc",
  487. "src/google/protobuf/stubs/type_traits_unittest.cc",
  488. "src/google/protobuf/text_format_unittest.cc",
  489. "src/google/protobuf/unknown_field_set_unittest.cc",
  490. "src/google/protobuf/util/delimited_message_util_test.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. # Files for csharp_bootstrap_unittest.cc.
  512. "conformance/**/*",
  513. "csharp/src/**/*",
  514. "examples/**/*",
  515. ]),
  516. includes = [
  517. "src/",
  518. ],
  519. linkopts = LINK_OPTS,
  520. deps = [
  521. ":cc_test_protos",
  522. ":protobuf",
  523. ":protoc_lib",
  524. "//external:gtest_main",
  525. ],
  526. )
  527. ################################################################################
  528. # Java support
  529. ################################################################################
  530. internal_gen_well_known_protos_java(
  531. srcs = WELL_KNOWN_PROTOS,
  532. )
  533. java_library(
  534. name = "protobuf_java",
  535. srcs = glob([
  536. "java/core/src/main/java/com/google/protobuf/*.java",
  537. ]) + [
  538. ":gen_well_known_protos_java",
  539. ],
  540. javacopts = ["-source 6", "-target 6"],
  541. visibility = ["//visibility:public"],
  542. )
  543. java_library(
  544. name = "protobuf_java_util",
  545. srcs = glob([
  546. "java/util/src/main/java/com/google/protobuf/util/*.java",
  547. ]),
  548. javacopts = ["-source 6", "-target 6"],
  549. visibility = ["//visibility:public"],
  550. deps = [
  551. "protobuf_java",
  552. "//external:gson",
  553. "//external:guava",
  554. ],
  555. )
  556. ################################################################################
  557. # Python support
  558. ################################################################################
  559. py_library(
  560. name = "python_srcs",
  561. srcs = glob(
  562. [
  563. "python/google/protobuf/*.py",
  564. "python/google/protobuf/**/*.py",
  565. ],
  566. exclude = [
  567. "python/google/protobuf/__init__.py",
  568. "python/google/protobuf/**/__init__.py",
  569. "python/google/protobuf/internal/*_test.py",
  570. "python/google/protobuf/internal/test_util.py",
  571. ],
  572. ),
  573. imports = ["python"],
  574. srcs_version = "PY2AND3",
  575. )
  576. cc_binary(
  577. name = "python/google/protobuf/internal/_api_implementation.so",
  578. srcs = ["python/google/protobuf/internal/api_implementation.cc"],
  579. copts = COPTS + [
  580. "-DPYTHON_PROTO2_CPP_IMPL_V2",
  581. ],
  582. linkshared = 1,
  583. linkstatic = 1,
  584. deps = select({
  585. "//conditions:default": [],
  586. ":use_fast_cpp_protos": ["//external:python_headers"],
  587. }),
  588. )
  589. cc_binary(
  590. name = "python/google/protobuf/pyext/_message.so",
  591. srcs = glob([
  592. "python/google/protobuf/pyext/*.cc",
  593. "python/google/protobuf/pyext/*.h",
  594. ]),
  595. copts = COPTS + [
  596. "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
  597. ] + select({
  598. "//conditions:default": [],
  599. ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
  600. }),
  601. includes = [
  602. "python/",
  603. "src/",
  604. ],
  605. linkshared = 1,
  606. linkstatic = 1,
  607. deps = [
  608. ":protobuf",
  609. ] + select({
  610. "//conditions:default": [],
  611. ":use_fast_cpp_protos": ["//external:python_headers"],
  612. }),
  613. )
  614. config_setting(
  615. name = "use_fast_cpp_protos",
  616. values = {
  617. "define": "use_fast_cpp_protos=true",
  618. },
  619. )
  620. config_setting(
  621. name = "allow_oversize_protos",
  622. values = {
  623. "define": "allow_oversize_protos=true",
  624. },
  625. )
  626. # Copy the builtin proto files from src/google/protobuf to
  627. # python/google/protobuf. This way, the generated Python sources will be in the
  628. # same directory as the Python runtime sources. This is necessary for the
  629. # modules to be imported correctly since they are all part of the same Python
  630. # package.
  631. internal_copied_filegroup(
  632. name = "protos_python",
  633. srcs = WELL_KNOWN_PROTOS,
  634. dest = "python",
  635. strip_prefix = "src",
  636. )
  637. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  638. # which case we can simply add :protos_python in srcs.
  639. COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
  640. py_proto_library(
  641. name = "protobuf_python",
  642. srcs = COPIED_WELL_KNOWN_PROTOS,
  643. include = "python",
  644. data = select({
  645. "//conditions:default": [],
  646. ":use_fast_cpp_protos": [
  647. ":python/google/protobuf/internal/_api_implementation.so",
  648. ":python/google/protobuf/pyext/_message.so",
  649. ],
  650. }),
  651. default_runtime = "",
  652. protoc = ":protoc",
  653. py_libs = [
  654. ":python_srcs",
  655. "//external:six",
  656. ],
  657. srcs_version = "PY2AND3",
  658. visibility = ["//visibility:public"],
  659. )
  660. # Copy the test proto files from src/google/protobuf to
  661. # python/google/protobuf. This way, the generated Python sources will be in the
  662. # same directory as the Python runtime sources. This is necessary for the
  663. # modules to be imported correctly by the tests since they are all part of the
  664. # same Python package.
  665. internal_copied_filegroup(
  666. name = "protos_python_test",
  667. srcs = LITE_TEST_PROTOS + TEST_PROTOS,
  668. dest = "python",
  669. strip_prefix = "src",
  670. )
  671. # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
  672. # which case we can simply add :protos_python_test in srcs.
  673. COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
  674. COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
  675. py_proto_library(
  676. name = "python_common_test_protos",
  677. srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
  678. include = "python",
  679. default_runtime = "",
  680. protoc = ":protoc",
  681. srcs_version = "PY2AND3",
  682. deps = [":protobuf_python"],
  683. )
  684. py_proto_library(
  685. name = "python_specific_test_protos",
  686. srcs = glob([
  687. "python/google/protobuf/internal/*.proto",
  688. "python/google/protobuf/internal/import_test_package/*.proto",
  689. ]),
  690. include = "python",
  691. default_runtime = ":protobuf_python",
  692. protoc = ":protoc",
  693. srcs_version = "PY2AND3",
  694. deps = [":python_common_test_protos"],
  695. )
  696. py_library(
  697. name = "python_tests",
  698. srcs = glob(
  699. [
  700. "python/google/protobuf/internal/*_test.py",
  701. "python/google/protobuf/internal/test_util.py",
  702. "python/google/protobuf/internal/import_test_package/__init__.py",
  703. ],
  704. ),
  705. imports = ["python"],
  706. srcs_version = "PY2AND3",
  707. deps = [
  708. ":protobuf_python",
  709. ":python_common_test_protos",
  710. ":python_specific_test_protos",
  711. ],
  712. )
  713. internal_protobuf_py_tests(
  714. name = "python_tests_batch",
  715. data = glob([
  716. "src/google/protobuf/**/*",
  717. ]),
  718. modules = [
  719. "descriptor_database_test",
  720. "descriptor_pool_test",
  721. "descriptor_test",
  722. "generator_test",
  723. "json_format_test",
  724. "message_factory_test",
  725. "message_test",
  726. "proto_builder_test",
  727. "reflection_test",
  728. "service_reflection_test",
  729. "symbol_database_test",
  730. "text_encoding_test",
  731. "text_format_test",
  732. "unknown_fields_test",
  733. "wire_format_test",
  734. ],
  735. deps = [":python_tests"],
  736. )
  737. proto_lang_toolchain(
  738. name = "cc_toolchain",
  739. command_line = "--cpp_out=$(OUT)",
  740. runtime = ":protobuf",
  741. visibility = ["//visibility:public"],
  742. )
  743. proto_lang_toolchain(
  744. name = "java_toolchain",
  745. command_line = "--java_out=$(OUT)",
  746. runtime = ":protobuf_java",
  747. visibility = ["//visibility:public"],
  748. )
  749. OBJC_HDRS = [
  750. "objectivec/GPBArray.h",
  751. "objectivec/GPBBootstrap.h",
  752. "objectivec/GPBCodedInputStream.h",
  753. "objectivec/GPBCodedOutputStream.h",
  754. "objectivec/GPBDescriptor.h",
  755. "objectivec/GPBDictionary.h",
  756. "objectivec/GPBExtensionInternals.h",
  757. "objectivec/GPBExtensionRegistry.h",
  758. "objectivec/GPBMessage.h",
  759. "objectivec/GPBProtocolBuffers.h",
  760. "objectivec/GPBProtocolBuffers_RuntimeSupport.h",
  761. "objectivec/GPBRootObject.h",
  762. "objectivec/GPBRuntimeTypes.h",
  763. "objectivec/GPBUnknownField.h",
  764. "objectivec/GPBUnknownFieldSet.h",
  765. "objectivec/GPBUtilities.h",
  766. "objectivec/GPBWellKnownTypes.h",
  767. "objectivec/GPBWireFormat.h",
  768. "objectivec/google/protobuf/Any.pbobjc.h",
  769. "objectivec/google/protobuf/Api.pbobjc.h",
  770. "objectivec/google/protobuf/Duration.pbobjc.h",
  771. "objectivec/google/protobuf/Empty.pbobjc.h",
  772. "objectivec/google/protobuf/FieldMask.pbobjc.h",
  773. "objectivec/google/protobuf/SourceContext.pbobjc.h",
  774. "objectivec/google/protobuf/Struct.pbobjc.h",
  775. "objectivec/google/protobuf/Timestamp.pbobjc.h",
  776. "objectivec/google/protobuf/Type.pbobjc.h",
  777. "objectivec/google/protobuf/Wrappers.pbobjc.h",
  778. ]
  779. OBJC_PRIVATE_HDRS = [
  780. "objectivec/GPBArray_PackagePrivate.h",
  781. "objectivec/GPBCodedInputStream_PackagePrivate.h",
  782. "objectivec/GPBCodedOutputStream_PackagePrivate.h",
  783. "objectivec/GPBDescriptor_PackagePrivate.h",
  784. "objectivec/GPBDictionary_PackagePrivate.h",
  785. "objectivec/GPBMessage_PackagePrivate.h",
  786. "objectivec/GPBRootObject_PackagePrivate.h",
  787. "objectivec/GPBUnknownFieldSet_PackagePrivate.h",
  788. "objectivec/GPBUnknownField_PackagePrivate.h",
  789. "objectivec/GPBUtilities_PackagePrivate.h",
  790. ]
  791. OBJC_SRCS = [
  792. "objectivec/GPBArray.m",
  793. "objectivec/GPBCodedInputStream.m",
  794. "objectivec/GPBCodedOutputStream.m",
  795. "objectivec/GPBDescriptor.m",
  796. "objectivec/GPBDictionary.m",
  797. "objectivec/GPBExtensionInternals.m",
  798. "objectivec/GPBExtensionRegistry.m",
  799. "objectivec/GPBMessage.m",
  800. "objectivec/GPBRootObject.m",
  801. "objectivec/GPBUnknownField.m",
  802. "objectivec/GPBUnknownFieldSet.m",
  803. "objectivec/GPBUtilities.m",
  804. "objectivec/GPBWellKnownTypes.m",
  805. "objectivec/GPBWireFormat.m",
  806. "objectivec/google/protobuf/Any.pbobjc.m",
  807. "objectivec/google/protobuf/Api.pbobjc.m",
  808. "objectivec/google/protobuf/Duration.pbobjc.m",
  809. "objectivec/google/protobuf/Empty.pbobjc.m",
  810. "objectivec/google/protobuf/FieldMask.pbobjc.m",
  811. "objectivec/google/protobuf/SourceContext.pbobjc.m",
  812. "objectivec/google/protobuf/Struct.pbobjc.m",
  813. "objectivec/google/protobuf/Timestamp.pbobjc.m",
  814. "objectivec/google/protobuf/Type.pbobjc.m",
  815. "objectivec/google/protobuf/Wrappers.pbobjc.m",
  816. ]
  817. objc_library(
  818. name = "objectivec",
  819. hdrs = OBJC_HDRS + OBJC_PRIVATE_HDRS,
  820. includes = [
  821. "objectivec",
  822. ],
  823. non_arc_srcs = OBJC_SRCS,
  824. visibility = ["//visibility:public"],
  825. )