BUILD 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. # Bazel (http://bazel.io/) BUILD file for Protobuf.
  2. licenses(["notice"])
  3. COPTS = [
  4. "-DHAVE_PTHREAD",
  5. "-Wall",
  6. "-Wwrite-strings",
  7. "-Woverloaded-virtual",
  8. "-Wno-sign-compare",
  9. "-Wno-error=unused-function",
  10. ]
  11. # Bazel should provide portable link_opts for pthread.
  12. LINK_OPTS = ["-lpthread"]
  13. cc_library(
  14. name = "protobuf_lite",
  15. srcs = [
  16. # AUTOGEN(protobuf_lite_srcs)
  17. "src/google/protobuf/arena.cc",
  18. "src/google/protobuf/arenastring.cc",
  19. "src/google/protobuf/extension_set.cc",
  20. "src/google/protobuf/generated_message_util.cc",
  21. "src/google/protobuf/io/coded_stream.cc",
  22. "src/google/protobuf/io/zero_copy_stream.cc",
  23. "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
  24. "src/google/protobuf/message_lite.cc",
  25. "src/google/protobuf/repeated_field.cc",
  26. "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
  27. "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
  28. "src/google/protobuf/stubs/bytestream.cc",
  29. "src/google/protobuf/stubs/common.cc",
  30. "src/google/protobuf/stubs/once.cc",
  31. "src/google/protobuf/stubs/status.cc",
  32. "src/google/protobuf/stubs/statusor.cc",
  33. "src/google/protobuf/stubs/stringpiece.cc",
  34. "src/google/protobuf/stubs/stringprintf.cc",
  35. "src/google/protobuf/stubs/strutil.cc",
  36. "src/google/protobuf/stubs/time.cc",
  37. "src/google/protobuf/wire_format_lite.cc",
  38. ],
  39. copts = COPTS,
  40. includes = ["src/"],
  41. linkopts = LINK_OPTS,
  42. visibility = ["//visibility:public"],
  43. )
  44. cc_library(
  45. name = "protobuf",
  46. srcs = [
  47. # AUTOGEN(protobuf_srcs)
  48. "src/google/protobuf/any.cc",
  49. "src/google/protobuf/any.pb.cc",
  50. "src/google/protobuf/api.pb.cc",
  51. "src/google/protobuf/compiler/importer.cc",
  52. "src/google/protobuf/compiler/parser.cc",
  53. "src/google/protobuf/descriptor.cc",
  54. "src/google/protobuf/descriptor.pb.cc",
  55. "src/google/protobuf/descriptor_database.cc",
  56. "src/google/protobuf/duration.pb.cc",
  57. "src/google/protobuf/dynamic_message.cc",
  58. "src/google/protobuf/empty.pb.cc",
  59. "src/google/protobuf/extension_set_heavy.cc",
  60. "src/google/protobuf/field_mask.pb.cc",
  61. "src/google/protobuf/generated_message_reflection.cc",
  62. "src/google/protobuf/io/gzip_stream.cc",
  63. "src/google/protobuf/io/printer.cc",
  64. "src/google/protobuf/io/strtod.cc",
  65. "src/google/protobuf/io/tokenizer.cc",
  66. "src/google/protobuf/io/zero_copy_stream_impl.cc",
  67. "src/google/protobuf/map_field.cc",
  68. "src/google/protobuf/message.cc",
  69. "src/google/protobuf/reflection_ops.cc",
  70. "src/google/protobuf/service.cc",
  71. "src/google/protobuf/source_context.pb.cc",
  72. "src/google/protobuf/struct.pb.cc",
  73. "src/google/protobuf/stubs/mathlimits.cc",
  74. "src/google/protobuf/stubs/structurally_valid.cc",
  75. "src/google/protobuf/stubs/substitute.cc",
  76. "src/google/protobuf/text_format.cc",
  77. "src/google/protobuf/timestamp.pb.cc",
  78. "src/google/protobuf/type.pb.cc",
  79. "src/google/protobuf/unknown_field_set.cc",
  80. "src/google/protobuf/util/field_comparator.cc",
  81. "src/google/protobuf/util/internal/datapiece.cc",
  82. "src/google/protobuf/util/internal/default_value_objectwriter.cc",
  83. "src/google/protobuf/util/internal/error_listener.cc",
  84. "src/google/protobuf/util/internal/field_mask_utility.cc",
  85. "src/google/protobuf/util/internal/json_escaping.cc",
  86. "src/google/protobuf/util/internal/json_objectwriter.cc",
  87. "src/google/protobuf/util/internal/json_stream_parser.cc",
  88. "src/google/protobuf/util/internal/object_writer.cc",
  89. "src/google/protobuf/util/internal/protostream_objectsource.cc",
  90. "src/google/protobuf/util/internal/protostream_objectwriter.cc",
  91. "src/google/protobuf/util/internal/type_info.cc",
  92. "src/google/protobuf/util/internal/type_info_test_helper.cc",
  93. "src/google/protobuf/util/internal/utility.cc",
  94. "src/google/protobuf/util/json_util.cc",
  95. "src/google/protobuf/util/message_differencer.cc",
  96. "src/google/protobuf/util/type_resolver_util.cc",
  97. "src/google/protobuf/wire_format.cc",
  98. "src/google/protobuf/wrappers.pb.cc",
  99. ],
  100. copts = COPTS,
  101. includes = ["src/"],
  102. linkopts = LINK_OPTS,
  103. visibility = ["//visibility:public"],
  104. deps = [":protobuf_lite"],
  105. )
  106. cc_library(
  107. name = "protoc_lib",
  108. srcs = [
  109. # AUTOGEN(protoc_lib_srcs)
  110. "src/google/protobuf/compiler/code_generator.cc",
  111. "src/google/protobuf/compiler/command_line_interface.cc",
  112. "src/google/protobuf/compiler/cpp/cpp_enum.cc",
  113. "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
  114. "src/google/protobuf/compiler/cpp/cpp_extension.cc",
  115. "src/google/protobuf/compiler/cpp/cpp_field.cc",
  116. "src/google/protobuf/compiler/cpp/cpp_file.cc",
  117. "src/google/protobuf/compiler/cpp/cpp_generator.cc",
  118. "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
  119. "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
  120. "src/google/protobuf/compiler/cpp/cpp_message.cc",
  121. "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
  122. "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
  123. "src/google/protobuf/compiler/cpp/cpp_service.cc",
  124. "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
  125. "src/google/protobuf/compiler/csharp/csharp_enum.cc",
  126. "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
  127. "src/google/protobuf/compiler/csharp/csharp_extension.cc",
  128. "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
  129. "src/google/protobuf/compiler/csharp/csharp_generator.cc",
  130. "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
  131. "src/google/protobuf/compiler/csharp/csharp_message.cc",
  132. "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
  133. "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
  134. "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
  135. "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
  136. "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
  137. "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
  138. "src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc",
  139. "src/google/protobuf/compiler/csharp/csharp_writer.cc",
  140. "src/google/protobuf/compiler/java/java_context.cc",
  141. "src/google/protobuf/compiler/java/java_doc_comment.cc",
  142. "src/google/protobuf/compiler/java/java_enum.cc",
  143. "src/google/protobuf/compiler/java/java_enum_field.cc",
  144. "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
  145. "src/google/protobuf/compiler/java/java_extension.cc",
  146. "src/google/protobuf/compiler/java/java_field.cc",
  147. "src/google/protobuf/compiler/java/java_file.cc",
  148. "src/google/protobuf/compiler/java/java_generator.cc",
  149. "src/google/protobuf/compiler/java/java_generator_factory.cc",
  150. "src/google/protobuf/compiler/java/java_helpers.cc",
  151. "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
  152. "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
  153. "src/google/protobuf/compiler/java/java_map_field.cc",
  154. "src/google/protobuf/compiler/java/java_map_field_lite.cc",
  155. "src/google/protobuf/compiler/java/java_message.cc",
  156. "src/google/protobuf/compiler/java/java_message_builder.cc",
  157. "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
  158. "src/google/protobuf/compiler/java/java_message_field.cc",
  159. "src/google/protobuf/compiler/java/java_message_field_lite.cc",
  160. "src/google/protobuf/compiler/java/java_message_lite.cc",
  161. "src/google/protobuf/compiler/java/java_name_resolver.cc",
  162. "src/google/protobuf/compiler/java/java_primitive_field.cc",
  163. "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
  164. "src/google/protobuf/compiler/java/java_service.cc",
  165. "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
  166. "src/google/protobuf/compiler/java/java_string_field.cc",
  167. "src/google/protobuf/compiler/java/java_string_field_lite.cc",
  168. "src/google/protobuf/compiler/javanano/javanano_enum.cc",
  169. "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
  170. "src/google/protobuf/compiler/javanano/javanano_extension.cc",
  171. "src/google/protobuf/compiler/javanano/javanano_field.cc",
  172. "src/google/protobuf/compiler/javanano/javanano_file.cc",
  173. "src/google/protobuf/compiler/javanano/javanano_generator.cc",
  174. "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
  175. "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
  176. "src/google/protobuf/compiler/javanano/javanano_message.cc",
  177. "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
  178. "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
  179. "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
  180. "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
  181. "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
  182. "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
  183. "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
  184. "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
  185. "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
  186. "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
  187. "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
  188. "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
  189. "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
  190. "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
  191. "src/google/protobuf/compiler/plugin.cc",
  192. "src/google/protobuf/compiler/plugin.pb.cc",
  193. "src/google/protobuf/compiler/python/python_generator.cc",
  194. "src/google/protobuf/compiler/ruby/ruby_generator.cc",
  195. "src/google/protobuf/compiler/subprocess.cc",
  196. "src/google/protobuf/compiler/zip_writer.cc",
  197. ],
  198. copts = COPTS,
  199. includes = ["src/"],
  200. linkopts = LINK_OPTS,
  201. visibility = ["//visibility:public"],
  202. deps = [":protobuf"],
  203. )
  204. cc_binary(
  205. name = "protoc",
  206. srcs = ["src/google/protobuf/compiler/main.cc"],
  207. linkopts = LINK_OPTS,
  208. visibility = ["//visibility:public"],
  209. deps = [":protoc_lib"],
  210. )
  211. WELL_KNOWN_PROTOS = [
  212. # AUTOGEN(well_known_protos)
  213. "google/protobuf/any.proto",
  214. "google/protobuf/api.proto",
  215. "google/protobuf/compiler/plugin.proto",
  216. "google/protobuf/descriptor.proto",
  217. "google/protobuf/duration.proto",
  218. "google/protobuf/empty.proto",
  219. "google/protobuf/field_mask.proto",
  220. "google/protobuf/source_context.proto",
  221. "google/protobuf/struct.proto",
  222. "google/protobuf/timestamp.proto",
  223. "google/protobuf/type.proto",
  224. "google/protobuf/wrappers.proto",
  225. ]
  226. ################################################################################
  227. # Tests
  228. ################################################################################
  229. LITE_TEST_PROTOS = [
  230. # AUTOGEN(lite_test_protos)
  231. "google/protobuf/map_lite_unittest.proto",
  232. "google/protobuf/unittest_import_lite.proto",
  233. "google/protobuf/unittest_import_public_lite.proto",
  234. "google/protobuf/unittest_lite.proto",
  235. ]
  236. TEST_PROTOS = [
  237. # AUTOGEN(test_protos)
  238. "google/protobuf/any_test.proto",
  239. "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
  240. "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
  241. "google/protobuf/map_proto2_unittest.proto",
  242. "google/protobuf/map_unittest.proto",
  243. "google/protobuf/unittest.proto",
  244. "google/protobuf/unittest_arena.proto",
  245. "google/protobuf/unittest_custom_options.proto",
  246. "google/protobuf/unittest_drop_unknown_fields.proto",
  247. "google/protobuf/unittest_embed_optimize_for.proto",
  248. "google/protobuf/unittest_empty.proto",
  249. "google/protobuf/unittest_enormous_descriptor.proto",
  250. "google/protobuf/unittest_import.proto",
  251. "google/protobuf/unittest_import_public.proto",
  252. "google/protobuf/unittest_lite_imports_nonlite.proto",
  253. "google/protobuf/unittest_mset.proto",
  254. "google/protobuf/unittest_no_arena.proto",
  255. "google/protobuf/unittest_no_arena_import.proto",
  256. "google/protobuf/unittest_no_field_presence.proto",
  257. "google/protobuf/unittest_no_generic_services.proto",
  258. "google/protobuf/unittest_optimize_for.proto",
  259. "google/protobuf/unittest_preserve_unknown_enum.proto",
  260. "google/protobuf/unittest_preserve_unknown_enum2.proto",
  261. "google/protobuf/unittest_proto3_arena.proto",
  262. "google/protobuf/unittest_well_known_types.proto",
  263. "google/protobuf/util/internal/testdata/anys.proto",
  264. "google/protobuf/util/internal/testdata/books.proto",
  265. "google/protobuf/util/internal/testdata/default_value.proto",
  266. "google/protobuf/util/internal/testdata/default_value_test.proto",
  267. "google/protobuf/util/internal/testdata/field_mask.proto",
  268. "google/protobuf/util/internal/testdata/maps.proto",
  269. "google/protobuf/util/internal/testdata/struct.proto",
  270. "google/protobuf/util/internal/testdata/timestamp_duration.proto",
  271. "google/protobuf/util/json_format_proto3.proto",
  272. ]
  273. PROTOS = LITE_TEST_PROTOS + TEST_PROTOS
  274. INPUTS = PROTOS + WELL_KNOWN_PROTOS
  275. genrule(
  276. name = "gen_test_protos",
  277. srcs = ["src/" + x for x in INPUTS],
  278. outs = ["src/" + x[:-5] + "pb.h" for x in PROTOS] +
  279. ["src/" + x[:-5] + "pb.cc" for x in PROTOS],
  280. cmd =
  281. "$(location :protoc) --cpp_out=$(@D)/src" +
  282. "".join([" -I" + x + "=$(location src/" + x + ")" for x in INPUTS]) +
  283. "".join([" $(location src/" + x + ")" for x in PROTOS]),
  284. tools = [":protoc"],
  285. )
  286. COMMON_TEST_SRCS = [
  287. # AUTOGEN(common_test_srcs)
  288. "src/google/protobuf/arena_test_util.cc",
  289. "src/google/protobuf/map_test_util.cc",
  290. "src/google/protobuf/test_util.cc",
  291. "src/google/protobuf/testing/file.cc",
  292. "src/google/protobuf/testing/googletest.cc",
  293. ]
  294. # TODO(liujisi): Add gtest dependency and enable tests.
  295. # cc_test(
  296. # name = "protobuf_test",
  297. # srcs = OUTPUTS + COMMON_TEST_SRCS + [
  298. # "src/google/protobuf/any_test.cc",
  299. # "src/google/protobuf/arena_unittest.cc",
  300. # "src/google/protobuf/arenastring_unittest.cc",
  301. # "src/google/protobuf/compiler/command_line_interface_unittest.cc",
  302. # "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
  303. # "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
  304. # "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
  305. # "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
  306. # "src/google/protobuf/compiler/importer_unittest.cc",
  307. # "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
  308. # "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
  309. # "src/google/protobuf/compiler/mock_code_generator.cc",
  310. # "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
  311. # "src/google/protobuf/compiler/parser_unittest.cc",
  312. # "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
  313. # "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
  314. # "src/google/protobuf/descriptor_database_unittest.cc",
  315. # "src/google/protobuf/descriptor_unittest.cc",
  316. # "src/google/protobuf/drop_unknown_fields_test.cc",
  317. # "src/google/protobuf/dynamic_message_unittest.cc",
  318. # "src/google/protobuf/extension_set_unittest.cc",
  319. # "src/google/protobuf/generated_message_reflection_unittest.cc",
  320. # "src/google/protobuf/io/coded_stream_unittest.cc",
  321. # "src/google/protobuf/io/printer_unittest.cc",
  322. # "src/google/protobuf/io/tokenizer_unittest.cc",
  323. # "src/google/protobuf/io/zero_copy_stream_unittest.cc",
  324. # "src/google/protobuf/map_field_test.cc",
  325. # "src/google/protobuf/map_test.cc",
  326. # "src/google/protobuf/message_unittest.cc",
  327. # "src/google/protobuf/no_field_presence_test.cc",
  328. # "src/google/protobuf/preserve_unknown_enum_test.cc",
  329. # "src/google/protobuf/proto3_arena_unittest.cc",
  330. # "src/google/protobuf/reflection_ops_unittest.cc",
  331. # "src/google/protobuf/repeated_field_reflection_unittest.cc",
  332. # "src/google/protobuf/repeated_field_unittest.cc",
  333. # "src/google/protobuf/stubs/bytestream_unittest.cc",
  334. # "src/google/protobuf/stubs/common_unittest.cc",
  335. # "src/google/protobuf/stubs/once_unittest.cc",
  336. # "src/google/protobuf/stubs/status_test.cc",
  337. # "src/google/protobuf/stubs/statusor_test.cc",
  338. # "src/google/protobuf/stubs/stringpiece_unittest.cc",
  339. # "src/google/protobuf/stubs/stringprintf_unittest.cc",
  340. # "src/google/protobuf/stubs/structurally_valid_unittest.cc",
  341. # "src/google/protobuf/stubs/strutil_unittest.cc",
  342. # "src/google/protobuf/stubs/template_util_unittest.cc",
  343. # "src/google/protobuf/stubs/time_test.cc",
  344. # "src/google/protobuf/stubs/type_traits_unittest.cc",
  345. # "src/google/protobuf/text_format_unittest.cc",
  346. # "src/google/protobuf/unknown_field_set_unittest.cc",
  347. # "src/google/protobuf/util/field_comparator_test.cc",
  348. # "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
  349. # "src/google/protobuf/util/internal/json_objectwriter_test.cc",
  350. # "src/google/protobuf/util/internal/json_stream_parser_test.cc",
  351. # "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
  352. # "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
  353. # "src/google/protobuf/util/internal/type_info_test_helper.cc",
  354. # "src/google/protobuf/util/json_util_test.cc",
  355. # "src/google/protobuf/util/type_resolver_util_test.cc",
  356. # "src/google/protobuf/well_known_types_unittest.cc",
  357. # "src/google/protobuf/wire_format_unittest.cc",
  358. # ],
  359. # copts = COPTS,
  360. # includes = [
  361. # "src/",
  362. # ],
  363. # linkopts = LINK_OPTS,
  364. # deps = [
  365. # ":protobuf",
  366. # ":protoc_lib",
  367. # ],
  368. # )