BUILD 35 KB

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