OLD | NEW |
1 # Bazel (http://bazel.io/) BUILD file for Protobuf. | 1 # Bazel (http://bazel.io/) BUILD file for Protobuf. |
2 | 2 |
3 licenses(["notice"]) | 3 licenses(["notice"]) |
4 | 4 |
5 ################################################################################ | 5 ################################################################################ |
6 # Protobuf Runtime Library | 6 # Protobuf Runtime Library |
7 ################################################################################ | 7 ################################################################################ |
8 | 8 |
9 COPTS = [ | 9 COPTS = [ |
10 "-DHAVE_PTHREAD", | 10 "-DHAVE_PTHREAD", |
11 "-Wall", | 11 "-Wall", |
12 "-Wwrite-strings", | 12 "-Wwrite-strings", |
13 "-Woverloaded-virtual", | 13 "-Woverloaded-virtual", |
14 "-Wno-sign-compare", | 14 "-Wno-sign-compare", |
15 "-Wno-error=unused-function", | 15 "-Wno-error=unused-function", |
16 ] | 16 ] |
17 | 17 |
18 # Bazel should provide portable link_opts for pthread. | 18 config_setting( |
19 LINK_OPTS = ["-lpthread"] | 19 name = "android", |
| 20 values = { |
| 21 "crosstool_top": "//external:android/crosstool", |
| 22 }, |
| 23 ) |
| 24 |
| 25 # Android builds do not need to link in a separate pthread library. |
| 26 LINK_OPTS = select({ |
| 27 ":android": [], |
| 28 "//conditions:default": ["-lpthread"], |
| 29 }) |
20 | 30 |
21 load( | 31 load( |
22 "protobuf", | 32 "protobuf", |
23 "cc_proto_library", | 33 "cc_proto_library", |
24 "py_proto_library", | 34 "py_proto_library", |
25 "internal_copied_filegroup", | 35 "internal_gen_well_known_protos_java", |
26 "internal_protobuf_py_tests", | 36 "internal_protobuf_py_tests", |
27 ) | 37 ) |
28 | 38 |
| 39 config_setting( |
| 40 name = "ios_armv7", |
| 41 values = { |
| 42 "ios_cpu": "armv7", |
| 43 }, |
| 44 ) |
| 45 |
| 46 config_setting( |
| 47 name = "ios_armv7s", |
| 48 values = { |
| 49 "ios_cpu": "armv7s", |
| 50 }, |
| 51 ) |
| 52 |
| 53 config_setting( |
| 54 name = "ios_arm64", |
| 55 values = { |
| 56 "ios_cpu": "arm64", |
| 57 }, |
| 58 ) |
| 59 |
| 60 IOS_ARM_COPTS = COPTS + [ |
| 61 "-DOS_IOS", |
| 62 "-miphoneos-version-min=7.0", |
| 63 "-arch armv7", |
| 64 "-arch armv7s", |
| 65 "-arch arm64", |
| 66 "-D__thread=", |
| 67 "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.pla
tform/Developer/SDKs/iPhoneOS9.2.sdk/", |
| 68 ] |
| 69 |
29 cc_library( | 70 cc_library( |
30 name = "protobuf_lite", | 71 name = "protobuf_lite", |
31 srcs = [ | 72 srcs = [ |
32 # AUTOGEN(protobuf_lite_srcs) | 73 # AUTOGEN(protobuf_lite_srcs) |
33 "src/google/protobuf/arena.cc", | 74 "src/google/protobuf/arena.cc", |
34 "src/google/protobuf/arenastring.cc", | 75 "src/google/protobuf/arenastring.cc", |
35 "src/google/protobuf/extension_set.cc", | 76 "src/google/protobuf/extension_set.cc", |
36 "src/google/protobuf/generated_message_util.cc", | 77 "src/google/protobuf/generated_message_util.cc", |
37 "src/google/protobuf/io/coded_stream.cc", | 78 "src/google/protobuf/io/coded_stream.cc", |
38 "src/google/protobuf/io/zero_copy_stream.cc", | 79 "src/google/protobuf/io/zero_copy_stream.cc", |
39 "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", | 80 "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", |
40 "src/google/protobuf/message_lite.cc", | 81 "src/google/protobuf/message_lite.cc", |
41 "src/google/protobuf/repeated_field.cc", | 82 "src/google/protobuf/repeated_field.cc", |
42 "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc", | 83 "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc", |
43 "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc", | 84 "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc", |
44 "src/google/protobuf/stubs/bytestream.cc", | 85 "src/google/protobuf/stubs/bytestream.cc", |
45 "src/google/protobuf/stubs/common.cc", | 86 "src/google/protobuf/stubs/common.cc", |
46 "src/google/protobuf/stubs/int128.cc", | 87 "src/google/protobuf/stubs/int128.cc", |
47 "src/google/protobuf/stubs/once.cc", | 88 "src/google/protobuf/stubs/once.cc", |
48 "src/google/protobuf/stubs/status.cc", | 89 "src/google/protobuf/stubs/status.cc", |
49 "src/google/protobuf/stubs/statusor.cc", | 90 "src/google/protobuf/stubs/statusor.cc", |
50 "src/google/protobuf/stubs/stringpiece.cc", | 91 "src/google/protobuf/stubs/stringpiece.cc", |
51 "src/google/protobuf/stubs/stringprintf.cc", | 92 "src/google/protobuf/stubs/stringprintf.cc", |
52 "src/google/protobuf/stubs/structurally_valid.cc", | 93 "src/google/protobuf/stubs/structurally_valid.cc", |
53 "src/google/protobuf/stubs/strutil.cc", | 94 "src/google/protobuf/stubs/strutil.cc", |
54 "src/google/protobuf/stubs/time.cc", | 95 "src/google/protobuf/stubs/time.cc", |
55 "src/google/protobuf/wire_format_lite.cc", | 96 "src/google/protobuf/wire_format_lite.cc", |
56 ], | 97 ], |
57 hdrs = glob(["src/google/protobuf/**/*.h"]), | 98 hdrs = glob(["src/google/protobuf/**/*.h"]), |
58 copts = COPTS, | 99 copts = select({ |
| 100 ":ios_armv7": IOS_ARM_COPTS, |
| 101 ":ios_armv7s": IOS_ARM_COPTS, |
| 102 ":ios_arm64": IOS_ARM_COPTS, |
| 103 "//conditions:default": COPTS, |
| 104 }), |
59 includes = ["src/"], | 105 includes = ["src/"], |
60 linkopts = LINK_OPTS, | 106 linkopts = LINK_OPTS, |
61 visibility = ["//visibility:public"], | 107 visibility = ["//visibility:public"], |
62 ) | 108 ) |
63 | 109 |
64 cc_library( | 110 cc_library( |
65 name = "protobuf", | 111 name = "protobuf", |
66 srcs = [ | 112 srcs = [ |
67 # AUTOGEN(protobuf_srcs) | 113 # AUTOGEN(protobuf_srcs) |
68 "src/google/protobuf/any.cc", | 114 "src/google/protobuf/any.cc", |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 "src/google/protobuf/util/internal/type_info_test_helper.cc", | 159 "src/google/protobuf/util/internal/type_info_test_helper.cc", |
114 "src/google/protobuf/util/internal/utility.cc", | 160 "src/google/protobuf/util/internal/utility.cc", |
115 "src/google/protobuf/util/json_util.cc", | 161 "src/google/protobuf/util/json_util.cc", |
116 "src/google/protobuf/util/message_differencer.cc", | 162 "src/google/protobuf/util/message_differencer.cc", |
117 "src/google/protobuf/util/time_util.cc", | 163 "src/google/protobuf/util/time_util.cc", |
118 "src/google/protobuf/util/type_resolver_util.cc", | 164 "src/google/protobuf/util/type_resolver_util.cc", |
119 "src/google/protobuf/wire_format.cc", | 165 "src/google/protobuf/wire_format.cc", |
120 "src/google/protobuf/wrappers.pb.cc", | 166 "src/google/protobuf/wrappers.pb.cc", |
121 ], | 167 ], |
122 hdrs = glob(["src/**/*.h"]), | 168 hdrs = glob(["src/**/*.h"]), |
123 copts = COPTS, | 169 copts = select({ |
| 170 ":ios_armv7": IOS_ARM_COPTS, |
| 171 ":ios_armv7s": IOS_ARM_COPTS, |
| 172 ":ios_arm64": IOS_ARM_COPTS, |
| 173 "//conditions:default": COPTS, |
| 174 }), |
124 includes = ["src/"], | 175 includes = ["src/"], |
125 linkopts = LINK_OPTS, | 176 linkopts = LINK_OPTS, |
126 visibility = ["//visibility:public"], | 177 visibility = ["//visibility:public"], |
127 deps = [":protobuf_lite"], | 178 deps = [":protobuf_lite"], |
128 ) | 179 ) |
129 | 180 |
130 objc_library( | 181 objc_library( |
131 name = "protobuf_objc", | 182 name = "protobuf_objc", |
132 hdrs = ["objectivec/GPBProtocolBuffers.h"], | 183 hdrs = ["objectivec/GPBProtocolBuffers.h"], |
133 includes = ["objectivec"], | 184 includes = ["objectivec"], |
(...skipping 12 matching lines...) Expand all Loading... |
146 "google/protobuf/field_mask.proto", | 197 "google/protobuf/field_mask.proto", |
147 "google/protobuf/source_context.proto", | 198 "google/protobuf/source_context.proto", |
148 "google/protobuf/struct.proto", | 199 "google/protobuf/struct.proto", |
149 "google/protobuf/timestamp.proto", | 200 "google/protobuf/timestamp.proto", |
150 "google/protobuf/type.proto", | 201 "google/protobuf/type.proto", |
151 "google/protobuf/wrappers.proto", | 202 "google/protobuf/wrappers.proto", |
152 ] | 203 ] |
153 | 204 |
154 WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] | 205 WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] |
155 | 206 |
| 207 filegroup( |
| 208 name = "well_known_protos", |
| 209 srcs = WELL_KNOWN_PROTOS, |
| 210 visibility = ["//visibility:public"], |
| 211 ) |
| 212 |
156 cc_proto_library( | 213 cc_proto_library( |
157 name = "cc_wkt_protos", | 214 name = "cc_wkt_protos", |
158 srcs = WELL_KNOWN_PROTOS, | 215 srcs = WELL_KNOWN_PROTOS, |
159 include = "src", | 216 include = "src", |
160 default_runtime = ":protobuf", | 217 default_runtime = ":protobuf", |
161 internal_bootstrap_hack = 1, | 218 internal_bootstrap_hack = 1, |
162 protoc = ":protoc", | 219 protoc = ":protoc", |
163 visibility = ["//visibility:public"], | 220 visibility = ["//visibility:public"], |
164 ) | 221 ) |
165 | 222 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc"
, | 259 "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc"
, |
203 "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc", | 260 "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc", |
204 "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc", | 261 "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc", |
205 "src/google/protobuf/compiler/java/java_context.cc", | 262 "src/google/protobuf/compiler/java/java_context.cc", |
206 "src/google/protobuf/compiler/java/java_doc_comment.cc", | 263 "src/google/protobuf/compiler/java/java_doc_comment.cc", |
207 "src/google/protobuf/compiler/java/java_enum.cc", | 264 "src/google/protobuf/compiler/java/java_enum.cc", |
208 "src/google/protobuf/compiler/java/java_enum_field.cc", | 265 "src/google/protobuf/compiler/java/java_enum_field.cc", |
209 "src/google/protobuf/compiler/java/java_enum_field_lite.cc", | 266 "src/google/protobuf/compiler/java/java_enum_field_lite.cc", |
210 "src/google/protobuf/compiler/java/java_enum_lite.cc", | 267 "src/google/protobuf/compiler/java/java_enum_lite.cc", |
211 "src/google/protobuf/compiler/java/java_extension.cc", | 268 "src/google/protobuf/compiler/java/java_extension.cc", |
| 269 "src/google/protobuf/compiler/java/java_extension_lite.cc", |
212 "src/google/protobuf/compiler/java/java_field.cc", | 270 "src/google/protobuf/compiler/java/java_field.cc", |
213 "src/google/protobuf/compiler/java/java_file.cc", | 271 "src/google/protobuf/compiler/java/java_file.cc", |
214 "src/google/protobuf/compiler/java/java_generator.cc", | 272 "src/google/protobuf/compiler/java/java_generator.cc", |
215 "src/google/protobuf/compiler/java/java_generator_factory.cc", | 273 "src/google/protobuf/compiler/java/java_generator_factory.cc", |
216 "src/google/protobuf/compiler/java/java_helpers.cc", | 274 "src/google/protobuf/compiler/java/java_helpers.cc", |
217 "src/google/protobuf/compiler/java/java_lazy_message_field.cc", | 275 "src/google/protobuf/compiler/java/java_lazy_message_field.cc", |
218 "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc", | 276 "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc", |
219 "src/google/protobuf/compiler/java/java_map_field.cc", | 277 "src/google/protobuf/compiler/java/java_map_field.cc", |
220 "src/google/protobuf/compiler/java/java_map_field_lite.cc", | 278 "src/google/protobuf/compiler/java/java_map_field_lite.cc", |
221 "src/google/protobuf/compiler/java/java_message.cc", | 279 "src/google/protobuf/compiler/java/java_message.cc", |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 "google/protobuf/unittest_mset.proto", | 370 "google/protobuf/unittest_mset.proto", |
313 "google/protobuf/unittest_mset_wire_format.proto", | 371 "google/protobuf/unittest_mset_wire_format.proto", |
314 "google/protobuf/unittest_no_arena.proto", | 372 "google/protobuf/unittest_no_arena.proto", |
315 "google/protobuf/unittest_no_arena_import.proto", | 373 "google/protobuf/unittest_no_arena_import.proto", |
316 "google/protobuf/unittest_no_field_presence.proto", | 374 "google/protobuf/unittest_no_field_presence.proto", |
317 "google/protobuf/unittest_no_generic_services.proto", | 375 "google/protobuf/unittest_no_generic_services.proto", |
318 "google/protobuf/unittest_optimize_for.proto", | 376 "google/protobuf/unittest_optimize_for.proto", |
319 "google/protobuf/unittest_preserve_unknown_enum.proto", | 377 "google/protobuf/unittest_preserve_unknown_enum.proto", |
320 "google/protobuf/unittest_preserve_unknown_enum2.proto", | 378 "google/protobuf/unittest_preserve_unknown_enum2.proto", |
321 "google/protobuf/unittest_proto3_arena.proto", | 379 "google/protobuf/unittest_proto3_arena.proto", |
| 380 "google/protobuf/unittest_proto3_arena_lite.proto", |
| 381 "google/protobuf/unittest_proto3_lite.proto", |
322 "google/protobuf/unittest_well_known_types.proto", | 382 "google/protobuf/unittest_well_known_types.proto", |
323 "google/protobuf/util/internal/testdata/anys.proto", | 383 "google/protobuf/util/internal/testdata/anys.proto", |
324 "google/protobuf/util/internal/testdata/books.proto", | 384 "google/protobuf/util/internal/testdata/books.proto", |
325 "google/protobuf/util/internal/testdata/default_value.proto", | 385 "google/protobuf/util/internal/testdata/default_value.proto", |
326 "google/protobuf/util/internal/testdata/default_value_test.proto", | 386 "google/protobuf/util/internal/testdata/default_value_test.proto", |
327 "google/protobuf/util/internal/testdata/field_mask.proto", | 387 "google/protobuf/util/internal/testdata/field_mask.proto", |
328 "google/protobuf/util/internal/testdata/maps.proto", | 388 "google/protobuf/util/internal/testdata/maps.proto", |
329 "google/protobuf/util/internal/testdata/oneofs.proto", | 389 "google/protobuf/util/internal/testdata/oneofs.proto", |
330 "google/protobuf/util/internal/testdata/struct.proto", | 390 "google/protobuf/util/internal/testdata/struct.proto", |
331 "google/protobuf/util/internal/testdata/timestamp_duration.proto", | 391 "google/protobuf/util/internal/testdata/timestamp_duration.proto", |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 name = "protobuf_test", | 432 name = "protobuf_test", |
373 srcs = COMMON_TEST_SRCS + [ | 433 srcs = COMMON_TEST_SRCS + [ |
374 # AUTOGEN(test_srcs) | 434 # AUTOGEN(test_srcs) |
375 "src/google/protobuf/any_test.cc", | 435 "src/google/protobuf/any_test.cc", |
376 "src/google/protobuf/arena_unittest.cc", | 436 "src/google/protobuf/arena_unittest.cc", |
377 "src/google/protobuf/arenastring_unittest.cc", | 437 "src/google/protobuf/arenastring_unittest.cc", |
378 "src/google/protobuf/compiler/command_line_interface_unittest.cc", | 438 "src/google/protobuf/compiler/command_line_interface_unittest.cc", |
379 "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc", | 439 "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc", |
380 "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc", | 440 "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc", |
381 "src/google/protobuf/compiler/cpp/cpp_unittest.cc", | 441 "src/google/protobuf/compiler/cpp/cpp_unittest.cc", |
| 442 "src/google/protobuf/compiler/cpp/metadata_test.cc", |
382 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc", | 443 "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc", |
383 "src/google/protobuf/compiler/importer_unittest.cc", | 444 "src/google/protobuf/compiler/importer_unittest.cc", |
384 "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc", | 445 "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc", |
385 "src/google/protobuf/compiler/java/java_plugin_unittest.cc", | 446 "src/google/protobuf/compiler/java/java_plugin_unittest.cc", |
386 "src/google/protobuf/compiler/mock_code_generator.cc", | 447 "src/google/protobuf/compiler/mock_code_generator.cc", |
387 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc"
, | 448 "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc"
, |
388 "src/google/protobuf/compiler/parser_unittest.cc", | 449 "src/google/protobuf/compiler/parser_unittest.cc", |
389 "src/google/protobuf/compiler/python/python_plugin_unittest.cc", | 450 "src/google/protobuf/compiler/python/python_plugin_unittest.cc", |
390 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc", | 451 "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc", |
391 "src/google/protobuf/descriptor_database_unittest.cc", | 452 "src/google/protobuf/descriptor_database_unittest.cc", |
392 "src/google/protobuf/descriptor_unittest.cc", | 453 "src/google/protobuf/descriptor_unittest.cc", |
393 "src/google/protobuf/drop_unknown_fields_test.cc", | 454 "src/google/protobuf/drop_unknown_fields_test.cc", |
394 "src/google/protobuf/dynamic_message_unittest.cc", | 455 "src/google/protobuf/dynamic_message_unittest.cc", |
395 "src/google/protobuf/extension_set_unittest.cc", | 456 "src/google/protobuf/extension_set_unittest.cc", |
396 "src/google/protobuf/generated_message_reflection_unittest.cc", | 457 "src/google/protobuf/generated_message_reflection_unittest.cc", |
397 "src/google/protobuf/io/coded_stream_unittest.cc", | 458 "src/google/protobuf/io/coded_stream_unittest.cc", |
398 "src/google/protobuf/io/printer_unittest.cc", | 459 "src/google/protobuf/io/printer_unittest.cc", |
399 "src/google/protobuf/io/tokenizer_unittest.cc", | 460 "src/google/protobuf/io/tokenizer_unittest.cc", |
400 "src/google/protobuf/io/zero_copy_stream_unittest.cc", | 461 "src/google/protobuf/io/zero_copy_stream_unittest.cc", |
401 "src/google/protobuf/map_field_test.cc", | 462 "src/google/protobuf/map_field_test.cc", |
402 "src/google/protobuf/map_test.cc", | 463 "src/google/protobuf/map_test.cc", |
403 "src/google/protobuf/message_unittest.cc", | 464 "src/google/protobuf/message_unittest.cc", |
404 "src/google/protobuf/no_field_presence_test.cc", | 465 "src/google/protobuf/no_field_presence_test.cc", |
405 "src/google/protobuf/preserve_unknown_enum_test.cc", | 466 "src/google/protobuf/preserve_unknown_enum_test.cc", |
| 467 "src/google/protobuf/proto3_arena_lite_unittest.cc", |
406 "src/google/protobuf/proto3_arena_unittest.cc", | 468 "src/google/protobuf/proto3_arena_unittest.cc", |
| 469 "src/google/protobuf/proto3_lite_unittest.cc", |
407 "src/google/protobuf/reflection_ops_unittest.cc", | 470 "src/google/protobuf/reflection_ops_unittest.cc", |
408 "src/google/protobuf/repeated_field_reflection_unittest.cc", | 471 "src/google/protobuf/repeated_field_reflection_unittest.cc", |
409 "src/google/protobuf/repeated_field_unittest.cc", | 472 "src/google/protobuf/repeated_field_unittest.cc", |
410 "src/google/protobuf/stubs/bytestream_unittest.cc", | 473 "src/google/protobuf/stubs/bytestream_unittest.cc", |
411 "src/google/protobuf/stubs/common_unittest.cc", | 474 "src/google/protobuf/stubs/common_unittest.cc", |
412 "src/google/protobuf/stubs/int128_unittest.cc", | 475 "src/google/protobuf/stubs/int128_unittest.cc", |
413 "src/google/protobuf/stubs/once_unittest.cc", | 476 "src/google/protobuf/stubs/once_unittest.cc", |
414 "src/google/protobuf/stubs/status_test.cc", | 477 "src/google/protobuf/stubs/status_test.cc", |
415 "src/google/protobuf/stubs/statusor_test.cc", | 478 "src/google/protobuf/stubs/statusor_test.cc", |
416 "src/google/protobuf/stubs/stringpiece_unittest.cc", | 479 "src/google/protobuf/stubs/stringpiece_unittest.cc", |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 ":cc_test_protos", | 514 ":cc_test_protos", |
452 ":protobuf", | 515 ":protobuf", |
453 ":protoc_lib", | 516 ":protoc_lib", |
454 "//external:gtest_main", | 517 "//external:gtest_main", |
455 ], | 518 ], |
456 ) | 519 ) |
457 | 520 |
458 ################################################################################ | 521 ################################################################################ |
459 # Java support | 522 # Java support |
460 ################################################################################ | 523 ################################################################################ |
461 genrule( | 524 internal_gen_well_known_protos_java( |
462 name = "generate_java_descriptor_proto", | 525 srcs = WELL_KNOWN_PROTOS, |
463 srcs = ["src/google/protobuf/descriptor.proto"], | |
464 outs = ["com/google/protobuf/DescriptorProtos.java"], | |
465 cmd = "$(location :protoc) --java_out=$(@D)/../../.. $<", | |
466 tools = [":protoc"], | |
467 ) | 526 ) |
468 | 527 |
469 java_library( | 528 java_library( |
470 name = "protobuf_java", | 529 name = "protobuf_java", |
471 srcs = glob([ | 530 srcs = glob([ |
472 "java/src/main/java/com/google/protobuf/*.java", | 531 "java/core/src/main/java/com/google/protobuf/*.java", |
473 ]) + [ | 532 ]) + [ |
474 ":generate_java_descriptor_proto", | 533 ":gen_well_known_protos_java", |
475 ], | 534 ], |
476 visibility = ["//visibility:public"], | 535 visibility = ["//visibility:public"], |
477 ) | 536 ) |
| 537 |
| 538 java_library( |
| 539 name = "protobuf_java_util", |
| 540 srcs = glob([ |
| 541 "java/util/src/main/java/com/google/protobuf/util/*.java", |
| 542 ]), |
| 543 deps = [ |
| 544 "protobuf_java", |
| 545 "//external:gson", |
| 546 "//external:guava", |
| 547 ], |
| 548 visibility = ["//visibility:public"], |
| 549 ) |
478 | 550 |
479 ################################################################################ | 551 ################################################################################ |
480 # Python support | 552 # Python support |
481 ################################################################################ | 553 ################################################################################ |
482 | 554 |
483 # Hack: | 555 py_library( |
484 # protoc generated files contain imports like: | |
485 # "from google.protobuf.xxx import yyy" | |
486 # However, the sources files of the python runtime are not directly under | |
487 # "google/protobuf" (they are under python/google/protobuf). We workaround | |
488 # this by copying runtime source files into the desired location to workaround | |
489 # the import issue. Ideally py_library should support something similiar to the | |
490 # "include" attribute in cc_library to inject the PYTHON_PATH for all libraries | |
491 # that depend on the target. | |
492 # | |
493 # If you use python protobuf as a third_party library in your bazel managed | |
494 # project: | |
495 # 1) Please import the whole package to //google/protobuf in your | |
496 # project. Otherwise, bazel disallows generated files out of the current | |
497 # package, thus we won't be able to copy protobuf runtime files into | |
498 # //google/protobuf/. | |
499 # 2) The runtime also requires "six" for Python2/3 compatibility, please see the | |
500 # WORKSPACE file and bind "six" to your workspace as well. | |
501 internal_copied_filegroup( | |
502 name = "python_srcs", | 556 name = "python_srcs", |
503 srcs = glob( | 557 srcs = glob( |
504 [ | 558 [ |
505 "python/google/protobuf/*.py", | 559 "python/google/protobuf/*.py", |
506 "python/google/protobuf/**/*.py", | 560 "python/google/protobuf/**/*.py", |
507 ], | 561 ], |
508 exclude = [ | 562 exclude = [ |
509 "python/google/protobuf/internal/*_test.py", | 563 "python/google/protobuf/internal/*_test.py", |
510 "python/google/protobuf/internal/test_util.py", | 564 "python/google/protobuf/internal/test_util.py", |
511 ], | 565 ], |
512 ), | 566 ), |
513 include = "python", | 567 srcs_version = "PY2AND3", |
| 568 imports = ["python"], |
514 ) | 569 ) |
515 | 570 |
516 cc_binary( | 571 cc_binary( |
517 name = "internal/_api_implementation.so", | 572 name = "internal/_api_implementation.so", |
518 srcs = ["python/google/protobuf/internal/api_implementation.cc"], | 573 srcs = ["python/google/protobuf/internal/api_implementation.cc"], |
519 copts = COPTS + [ | 574 copts = COPTS + [ |
520 "-DPYTHON_PROTO2_CPP_IMPL_V2", | 575 "-DPYTHON_PROTO2_CPP_IMPL_V2", |
521 ], | 576 ], |
522 linkshared = 1, | 577 linkshared = 1, |
523 linkstatic = 1, | 578 linkstatic = 1, |
524 deps = select({ | 579 deps = select({ |
525 "//conditions:default": [], | 580 "//conditions:default": [], |
526 ":use_fast_cpp_protos": ["//util/python:python_headers"], | 581 ":use_fast_cpp_protos": ["//external:python_headers"], |
527 }), | 582 }), |
528 ) | 583 ) |
529 | 584 |
530 cc_binary( | 585 cc_binary( |
531 name = "pyext/_message.so", | 586 name = "pyext/_message.so", |
532 srcs = glob([ | 587 srcs = glob([ |
533 "python/google/protobuf/pyext/*.cc", | 588 "python/google/protobuf/pyext/*.cc", |
534 "python/google/protobuf/pyext/*.h", | 589 "python/google/protobuf/pyext/*.h", |
535 ]), | 590 ]), |
536 copts = COPTS + [ | 591 copts = COPTS + [ |
537 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1", | 592 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1", |
538 ], | 593 ] + select({ |
| 594 "//conditions:default": [], |
| 595 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"], |
| 596 }), |
539 includes = [ | 597 includes = [ |
540 "python/", | 598 "python/", |
541 "src/", | 599 "src/", |
542 ], | 600 ], |
543 linkshared = 1, | 601 linkshared = 1, |
544 linkstatic = 1, | 602 linkstatic = 1, |
545 deps = [ | 603 deps = [ |
546 ":protobuf", | 604 ":protobuf", |
547 ] + select({ | 605 ] + select({ |
548 "//conditions:default": [], | 606 "//conditions:default": [], |
549 ":use_fast_cpp_protos": ["//util/python:python_headers"], | 607 ":use_fast_cpp_protos": ["//external:python_headers"], |
550 }), | 608 }), |
551 ) | 609 ) |
552 | 610 |
553 config_setting( | 611 config_setting( |
554 name = "use_fast_cpp_protos", | 612 name = "use_fast_cpp_protos", |
555 values = { | 613 values = { |
556 "define": "use_fast_cpp_protos=true", | 614 "define": "use_fast_cpp_protos=true", |
557 }, | 615 }, |
558 ) | 616 ) |
559 | 617 |
| 618 config_setting( |
| 619 name = "allow_oversize_protos", |
| 620 values = { |
| 621 "define": "allow_oversize_protos=true", |
| 622 }, |
| 623 ) |
| 624 |
560 py_proto_library( | 625 py_proto_library( |
561 name = "protobuf_python", | 626 name = "protobuf_python", |
562 srcs = WELL_KNOWN_PROTOS, | 627 srcs = WELL_KNOWN_PROTOS, |
563 include = "src", | 628 include = "src", |
564 data = select({ | 629 data = select({ |
565 "//conditions:default": [], | 630 "//conditions:default": [], |
566 ":use_fast_cpp_protos": [ | 631 ":use_fast_cpp_protos": [ |
567 ":internal/_api_implementation.so", | 632 ":internal/_api_implementation.so", |
568 ":pyext/_message.so", | 633 ":pyext/_message.so", |
569 ], | 634 ], |
570 }), | 635 }), |
571 default_runtime = "", | 636 default_runtime = "", |
572 protoc = ":protoc", | 637 protoc = ":protoc", |
573 py_extra_srcs = [":python_srcs"], | 638 py_libs = [ |
574 py_libs = ["//external:six"], | 639 ":python_srcs", |
| 640 "//external:six" |
| 641 ], |
575 srcs_version = "PY2AND3", | 642 srcs_version = "PY2AND3", |
576 visibility = ["//visibility:public"], | 643 visibility = ["//visibility:public"], |
577 ) | 644 ) |
578 | 645 |
579 internal_copied_filegroup( | |
580 name = "python_test_srcs", | |
581 srcs = glob( | |
582 [ | |
583 "python/google/protobuf/internal/*_test.py", | |
584 "python/google/protobuf/internal/test_util.py", | |
585 ], | |
586 ), | |
587 include = "python", | |
588 ) | |
589 | |
590 py_proto_library( | 646 py_proto_library( |
591 name = "python_common_test_protos", | 647 name = "python_common_test_protos", |
592 srcs = LITE_TEST_PROTOS + TEST_PROTOS, | 648 srcs = LITE_TEST_PROTOS + TEST_PROTOS, |
593 include = "src", | 649 include = "src", |
594 default_runtime = "", | 650 default_runtime = "", |
595 protoc = ":protoc", | 651 protoc = ":protoc", |
| 652 srcs_version = "PY2AND3", |
596 deps = [":protobuf_python"], | 653 deps = [":protobuf_python"], |
597 ) | 654 ) |
598 | 655 |
599 py_proto_library( | 656 py_proto_library( |
600 name = "python_specific_test_protos", | 657 name = "python_specific_test_protos", |
601 srcs = glob([ | 658 srcs = glob([ |
602 "python/google/protobuf/internal/*.proto", | 659 "python/google/protobuf/internal/*.proto", |
603 "python/google/protobuf/internal/import_test_package/*.proto", | 660 "python/google/protobuf/internal/import_test_package/*.proto", |
604 ]), | 661 ]), |
605 include = "python", | 662 include = "python", |
606 default_runtime = ":protobuf_python", | 663 default_runtime = ":protobuf_python", |
607 protoc = ":protoc", | 664 protoc = ":protoc", |
| 665 srcs_version = "PY2AND3", |
608 deps = [":python_common_test_protos"], | 666 deps = [":python_common_test_protos"], |
609 ) | 667 ) |
610 | 668 |
611 py_library( | 669 py_library( |
612 name = "python_tests", | 670 name = "python_tests", |
613 srcs = [":python_test_srcs"], | 671 srcs = glob( |
| 672 [ |
| 673 "python/google/protobuf/internal/*_test.py", |
| 674 "python/google/protobuf/internal/test_util.py", |
| 675 ], |
| 676 ), |
| 677 imports = ["python"], |
614 srcs_version = "PY2AND3", | 678 srcs_version = "PY2AND3", |
615 deps = [ | 679 deps = [ |
616 ":protobuf_python", | 680 ":protobuf_python", |
617 ":python_common_test_protos", | 681 ":python_common_test_protos", |
618 ":python_specific_test_protos", | 682 ":python_specific_test_protos", |
619 ], | 683 ], |
620 ) | 684 ) |
621 | 685 |
622 internal_protobuf_py_tests( | 686 internal_protobuf_py_tests( |
623 name = "python_tests_batch", | 687 name = "python_tests_batch", |
(...skipping 12 matching lines...) Expand all Loading... |
636 "reflection_test", | 700 "reflection_test", |
637 "service_reflection_test", | 701 "service_reflection_test", |
638 "symbol_database_test", | 702 "symbol_database_test", |
639 "text_encoding_test", | 703 "text_encoding_test", |
640 "text_format_test", | 704 "text_format_test", |
641 "unknown_fields_test", | 705 "unknown_fields_test", |
642 "wire_format_test", | 706 "wire_format_test", |
643 ], | 707 ], |
644 deps = [":python_tests"], | 708 deps = [":python_tests"], |
645 ) | 709 ) |
OLD | NEW |