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