BUILD 34 KB

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