| 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 exports_files(["LICENSE"]) |
| 6 |
| 5 ################################################################################ | 7 ################################################################################ |
| 6 # Protobuf Runtime Library | 8 # Protobuf Runtime Library |
| 7 ################################################################################ | 9 ################################################################################ |
| 8 | 10 |
| 9 COPTS = [ | 11 COPTS = [ |
| 10 "-DHAVE_PTHREAD", | 12 "-DHAVE_PTHREAD", |
| 11 "-Wall", | 13 "-Wall", |
| 12 "-Wwrite-strings", | 14 "-Wwrite-strings", |
| 13 "-Woverloaded-virtual", | 15 "-Woverloaded-virtual", |
| 14 "-Wno-sign-compare", | 16 "-Wno-sign-compare", |
| 15 "-Wno-error=unused-function", | 17 "-Wno-unused-function", |
| 16 ] | 18 ] |
| 17 | 19 |
| 18 config_setting( | 20 config_setting( |
| 19 name = "android", | 21 name = "android", |
| 20 values = { | 22 values = { |
| 21 "crosstool_top": "//external:android/crosstool", | 23 "crosstool_top": "//external:android/crosstool", |
| 22 }, | 24 }, |
| 23 ) | 25 ) |
| 24 | 26 |
| 25 # Android builds do not need to link in a separate pthread library. | 27 # Android builds do not need to link in a separate pthread library. |
| 26 LINK_OPTS = select({ | 28 LINK_OPTS = select({ |
| 27 ":android": [], | 29 ":android": [], |
| 28 "//conditions:default": ["-lpthread"], | 30 "//conditions:default": ["-lpthread"], |
| 29 }) | 31 }) |
| 30 | 32 |
| 31 load( | 33 load( |
| 32 "protobuf", | 34 "protobuf", |
| 33 "cc_proto_library", | 35 "cc_proto_library", |
| 34 "py_proto_library", | 36 "py_proto_library", |
| 37 "internal_copied_filegroup", |
| 35 "internal_gen_well_known_protos_java", | 38 "internal_gen_well_known_protos_java", |
| 36 "internal_protobuf_py_tests", | 39 "internal_protobuf_py_tests", |
| 37 ) | 40 ) |
| 38 | 41 |
| 39 config_setting( | 42 config_setting( |
| 40 name = "ios_armv7", | 43 name = "ios_armv7", |
| 41 values = { | 44 values = { |
| 42 "ios_cpu": "armv7", | 45 "ios_cpu": "armv7", |
| 43 }, | 46 }, |
| 44 ) | 47 ) |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 default_runtime = ":protobuf", | 220 default_runtime = ":protobuf", |
| 218 internal_bootstrap_hack = 1, | 221 internal_bootstrap_hack = 1, |
| 219 protoc = ":protoc", | 222 protoc = ":protoc", |
| 220 visibility = ["//visibility:public"], | 223 visibility = ["//visibility:public"], |
| 221 ) | 224 ) |
| 222 | 225 |
| 223 ################################################################################ | 226 ################################################################################ |
| 224 # Protocol Buffers Compiler | 227 # Protocol Buffers Compiler |
| 225 ################################################################################ | 228 ################################################################################ |
| 226 | 229 |
| 230 cc_binary( |
| 231 name = "js_embed", |
| 232 srcs = ["src/google/protobuf/compiler/js/embed.cc"], |
| 233 visibility = ["//visibility:public"], |
| 234 ) |
| 235 |
| 236 genrule( |
| 237 name = "generate_js_well_known_types_embed", |
| 238 srcs = [ |
| 239 "src/google/protobuf/compiler/js/well_known_types/any.js", |
| 240 "src/google/protobuf/compiler/js/well_known_types/struct.js", |
| 241 "src/google/protobuf/compiler/js/well_known_types/timestamp.js", |
| 242 ], |
| 243 outs = ["src/google/protobuf/compiler/js/well_known_types_embed.cc"], |
| 244 cmd = "$(location :js_embed) $(SRCS) > $@", |
| 245 tools = [":js_embed"], |
| 246 ) |
| 247 |
| 227 cc_library( | 248 cc_library( |
| 228 name = "protoc_lib", | 249 name = "protoc_lib", |
| 229 srcs = [ | 250 srcs = [ |
| 230 # AUTOGEN(protoc_lib_srcs) | 251 # AUTOGEN(protoc_lib_srcs) |
| 231 "src/google/protobuf/compiler/code_generator.cc", | 252 "src/google/protobuf/compiler/code_generator.cc", |
| 232 "src/google/protobuf/compiler/command_line_interface.cc", | 253 "src/google/protobuf/compiler/command_line_interface.cc", |
| 233 "src/google/protobuf/compiler/cpp/cpp_enum.cc", | 254 "src/google/protobuf/compiler/cpp/cpp_enum.cc", |
| 234 "src/google/protobuf/compiler/cpp/cpp_enum_field.cc", | 255 "src/google/protobuf/compiler/cpp/cpp_enum_field.cc", |
| 235 "src/google/protobuf/compiler/cpp/cpp_extension.cc", | 256 "src/google/protobuf/compiler/cpp/cpp_extension.cc", |
| 236 "src/google/protobuf/compiler/cpp/cpp_field.cc", | 257 "src/google/protobuf/compiler/cpp/cpp_field.cc", |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 "src/google/protobuf/compiler/javanano/javanano_extension.cc", | 315 "src/google/protobuf/compiler/javanano/javanano_extension.cc", |
| 295 "src/google/protobuf/compiler/javanano/javanano_field.cc", | 316 "src/google/protobuf/compiler/javanano/javanano_field.cc", |
| 296 "src/google/protobuf/compiler/javanano/javanano_file.cc", | 317 "src/google/protobuf/compiler/javanano/javanano_file.cc", |
| 297 "src/google/protobuf/compiler/javanano/javanano_generator.cc", | 318 "src/google/protobuf/compiler/javanano/javanano_generator.cc", |
| 298 "src/google/protobuf/compiler/javanano/javanano_helpers.cc", | 319 "src/google/protobuf/compiler/javanano/javanano_helpers.cc", |
| 299 "src/google/protobuf/compiler/javanano/javanano_map_field.cc", | 320 "src/google/protobuf/compiler/javanano/javanano_map_field.cc", |
| 300 "src/google/protobuf/compiler/javanano/javanano_message.cc", | 321 "src/google/protobuf/compiler/javanano/javanano_message.cc", |
| 301 "src/google/protobuf/compiler/javanano/javanano_message_field.cc", | 322 "src/google/protobuf/compiler/javanano/javanano_message_field.cc", |
| 302 "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc", | 323 "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc", |
| 303 "src/google/protobuf/compiler/js/js_generator.cc", | 324 "src/google/protobuf/compiler/js/js_generator.cc", |
| 325 "src/google/protobuf/compiler/js/well_known_types_embed.cc", |
| 304 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", | 326 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", |
| 305 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", | 327 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", |
| 306 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", | 328 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", |
| 307 "src/google/protobuf/compiler/objectivec/objectivec_field.cc", | 329 "src/google/protobuf/compiler/objectivec/objectivec_field.cc", |
| 308 "src/google/protobuf/compiler/objectivec/objectivec_file.cc", | 330 "src/google/protobuf/compiler/objectivec/objectivec_file.cc", |
| 309 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc", | 331 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc", |
| 310 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc", | 332 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc", |
| 311 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc", | 333 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc", |
| 312 "src/google/protobuf/compiler/objectivec/objectivec_message.cc", | 334 "src/google/protobuf/compiler/objectivec/objectivec_message.cc", |
| 313 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc", | 335 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc", |
| 314 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc", | 336 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc", |
| 315 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", | 337 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", |
| 338 "src/google/protobuf/compiler/php/php_generator.cc", |
| 316 "src/google/protobuf/compiler/plugin.cc", | 339 "src/google/protobuf/compiler/plugin.cc", |
| 317 "src/google/protobuf/compiler/plugin.pb.cc", | 340 "src/google/protobuf/compiler/plugin.pb.cc", |
| 318 "src/google/protobuf/compiler/python/python_generator.cc", | 341 "src/google/protobuf/compiler/python/python_generator.cc", |
| 319 "src/google/protobuf/compiler/ruby/ruby_generator.cc", | 342 "src/google/protobuf/compiler/ruby/ruby_generator.cc", |
| 320 "src/google/protobuf/compiler/subprocess.cc", | 343 "src/google/protobuf/compiler/subprocess.cc", |
| 321 "src/google/protobuf/compiler/zip_writer.cc", | 344 "src/google/protobuf/compiler/zip_writer.cc", |
| 322 ], | 345 ], |
| 323 copts = COPTS, | 346 copts = COPTS, |
| 324 includes = ["src/"], | 347 includes = ["src/"], |
| 325 linkopts = LINK_OPTS, | 348 linkopts = LINK_OPTS, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 "google/protobuf/unittest_proto3_arena_lite.proto", | 403 "google/protobuf/unittest_proto3_arena_lite.proto", |
| 381 "google/protobuf/unittest_proto3_lite.proto", | 404 "google/protobuf/unittest_proto3_lite.proto", |
| 382 "google/protobuf/unittest_well_known_types.proto", | 405 "google/protobuf/unittest_well_known_types.proto", |
| 383 "google/protobuf/util/internal/testdata/anys.proto", | 406 "google/protobuf/util/internal/testdata/anys.proto", |
| 384 "google/protobuf/util/internal/testdata/books.proto", | 407 "google/protobuf/util/internal/testdata/books.proto", |
| 385 "google/protobuf/util/internal/testdata/default_value.proto", | 408 "google/protobuf/util/internal/testdata/default_value.proto", |
| 386 "google/protobuf/util/internal/testdata/default_value_test.proto", | 409 "google/protobuf/util/internal/testdata/default_value_test.proto", |
| 387 "google/protobuf/util/internal/testdata/field_mask.proto", | 410 "google/protobuf/util/internal/testdata/field_mask.proto", |
| 388 "google/protobuf/util/internal/testdata/maps.proto", | 411 "google/protobuf/util/internal/testdata/maps.proto", |
| 389 "google/protobuf/util/internal/testdata/oneofs.proto", | 412 "google/protobuf/util/internal/testdata/oneofs.proto", |
| 413 "google/protobuf/util/internal/testdata/proto3.proto", |
| 390 "google/protobuf/util/internal/testdata/struct.proto", | 414 "google/protobuf/util/internal/testdata/struct.proto", |
| 391 "google/protobuf/util/internal/testdata/timestamp_duration.proto", | 415 "google/protobuf/util/internal/testdata/timestamp_duration.proto", |
| 416 "google/protobuf/util/internal/testdata/wrappers.proto", |
| 392 "google/protobuf/util/json_format_proto3.proto", | 417 "google/protobuf/util/json_format_proto3.proto", |
| 393 "google/protobuf/util/message_differencer_unittest.proto", | 418 "google/protobuf/util/message_differencer_unittest.proto", |
| 394 ] | 419 ] |
| 395 | 420 |
| 396 TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS] | 421 TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS] |
| 397 | 422 |
| 398 cc_proto_library( | 423 cc_proto_library( |
| 399 name = "cc_test_protos", | 424 name = "cc_test_protos", |
| 400 srcs = LITE_TEST_PROTOS + TEST_PROTOS, | 425 srcs = LITE_TEST_PROTOS + TEST_PROTOS, |
| 401 include = "src", | 426 include = "src", |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 ################################################################################ | 578 ################################################################################ |
| 554 | 579 |
| 555 py_library( | 580 py_library( |
| 556 name = "python_srcs", | 581 name = "python_srcs", |
| 557 srcs = glob( | 582 srcs = glob( |
| 558 [ | 583 [ |
| 559 "python/google/protobuf/*.py", | 584 "python/google/protobuf/*.py", |
| 560 "python/google/protobuf/**/*.py", | 585 "python/google/protobuf/**/*.py", |
| 561 ], | 586 ], |
| 562 exclude = [ | 587 exclude = [ |
| 588 "python/google/protobuf/__init__.py", |
| 589 "python/google/protobuf/**/__init__.py", |
| 563 "python/google/protobuf/internal/*_test.py", | 590 "python/google/protobuf/internal/*_test.py", |
| 564 "python/google/protobuf/internal/test_util.py", | 591 "python/google/protobuf/internal/test_util.py", |
| 565 ], | 592 ], |
| 566 ), | 593 ), |
| 567 srcs_version = "PY2AND3", | 594 srcs_version = "PY2AND3", |
| 568 imports = ["python"], | 595 imports = ["python"], |
| 569 ) | 596 ) |
| 570 | 597 |
| 571 cc_binary( | 598 cc_binary( |
| 572 name = "internal/_api_implementation.so", | 599 name = "python/google/protobuf/internal/_api_implementation.so", |
| 573 srcs = ["python/google/protobuf/internal/api_implementation.cc"], | 600 srcs = ["python/google/protobuf/internal/api_implementation.cc"], |
| 574 copts = COPTS + [ | 601 copts = COPTS + [ |
| 575 "-DPYTHON_PROTO2_CPP_IMPL_V2", | 602 "-DPYTHON_PROTO2_CPP_IMPL_V2", |
| 576 ], | 603 ], |
| 577 linkshared = 1, | 604 linkshared = 1, |
| 578 linkstatic = 1, | 605 linkstatic = 1, |
| 579 deps = select({ | 606 deps = select({ |
| 580 "//conditions:default": [], | 607 "//conditions:default": [], |
| 581 ":use_fast_cpp_protos": ["//external:python_headers"], | 608 ":use_fast_cpp_protos": ["//external:python_headers"], |
| 582 }), | 609 }), |
| 583 ) | 610 ) |
| 584 | 611 |
| 585 cc_binary( | 612 cc_binary( |
| 586 name = "pyext/_message.so", | 613 name = "python/google/protobuf/pyext/_message.so", |
| 587 srcs = glob([ | 614 srcs = glob([ |
| 588 "python/google/protobuf/pyext/*.cc", | 615 "python/google/protobuf/pyext/*.cc", |
| 589 "python/google/protobuf/pyext/*.h", | 616 "python/google/protobuf/pyext/*.h", |
| 590 ]), | 617 ]), |
| 591 copts = COPTS + [ | 618 copts = COPTS + [ |
| 592 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1", | 619 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1", |
| 593 ] + select({ | 620 ] + select({ |
| 594 "//conditions:default": [], | 621 "//conditions:default": [], |
| 595 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"], | 622 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"], |
| 596 }), | 623 }), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 615 }, | 642 }, |
| 616 ) | 643 ) |
| 617 | 644 |
| 618 config_setting( | 645 config_setting( |
| 619 name = "allow_oversize_protos", | 646 name = "allow_oversize_protos", |
| 620 values = { | 647 values = { |
| 621 "define": "allow_oversize_protos=true", | 648 "define": "allow_oversize_protos=true", |
| 622 }, | 649 }, |
| 623 ) | 650 ) |
| 624 | 651 |
| 652 # Copy the builtin proto files from src/google/protobuf to |
| 653 # python/google/protobuf. This way, the generated Python sources will be in the |
| 654 # same directory as the Python runtime sources. This is necessary for the |
| 655 # modules to be imported correctly since they are all part of the same Python |
| 656 # package. |
| 657 internal_copied_filegroup( |
| 658 name = "protos_python", |
| 659 srcs = WELL_KNOWN_PROTOS, |
| 660 strip_prefix = "src", |
| 661 dest = "python", |
| 662 ) |
| 663 |
| 664 # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in |
| 665 # which case we can simply add :protos_python in srcs. |
| 666 COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] |
| 667 |
| 625 py_proto_library( | 668 py_proto_library( |
| 626 name = "protobuf_python", | 669 name = "protobuf_python", |
| 627 srcs = WELL_KNOWN_PROTOS, | 670 srcs = COPIED_WELL_KNOWN_PROTOS, |
| 628 include = "src", | 671 include = "python", |
| 629 data = select({ | 672 data = select({ |
| 630 "//conditions:default": [], | 673 "//conditions:default": [], |
| 631 ":use_fast_cpp_protos": [ | 674 ":use_fast_cpp_protos": [ |
| 632 ":internal/_api_implementation.so", | 675 ":python/google/protobuf/internal/_api_implementation.so", |
| 633 ":pyext/_message.so", | 676 ":python/google/protobuf/pyext/_message.so", |
| 634 ], | 677 ], |
| 635 }), | 678 }), |
| 636 default_runtime = "", | 679 default_runtime = "", |
| 637 protoc = ":protoc", | 680 protoc = ":protoc", |
| 638 py_libs = [ | 681 py_libs = [ |
| 639 ":python_srcs", | 682 ":python_srcs", |
| 640 "//external:six" | 683 "//external:six" |
| 641 ], | 684 ], |
| 642 srcs_version = "PY2AND3", | 685 srcs_version = "PY2AND3", |
| 643 visibility = ["//visibility:public"], | 686 visibility = ["//visibility:public"], |
| 644 ) | 687 ) |
| 645 | 688 |
| 689 # Copy the test proto files from src/google/protobuf to |
| 690 # python/google/protobuf. This way, the generated Python sources will be in the |
| 691 # same directory as the Python runtime sources. This is necessary for the |
| 692 # modules to be imported correctly by the tests since they are all part of the |
| 693 # same Python package. |
| 694 internal_copied_filegroup( |
| 695 name = "protos_python_test", |
| 696 srcs = LITE_TEST_PROTOS + TEST_PROTOS, |
| 697 strip_prefix = "src", |
| 698 dest = "python", |
| 699 ) |
| 700 |
| 701 # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in |
| 702 # which case we can simply add :protos_python_test in srcs. |
| 703 COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS] |
| 704 COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS] |
| 705 |
| 646 py_proto_library( | 706 py_proto_library( |
| 647 name = "python_common_test_protos", | 707 name = "python_common_test_protos", |
| 648 srcs = LITE_TEST_PROTOS + TEST_PROTOS, | 708 srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS, |
| 649 include = "src", | 709 include = "python", |
| 650 default_runtime = "", | 710 default_runtime = "", |
| 651 protoc = ":protoc", | 711 protoc = ":protoc", |
| 652 srcs_version = "PY2AND3", | 712 srcs_version = "PY2AND3", |
| 653 deps = [":protobuf_python"], | 713 deps = [":protobuf_python"], |
| 654 ) | 714 ) |
| 655 | 715 |
| 656 py_proto_library( | 716 py_proto_library( |
| 657 name = "python_specific_test_protos", | 717 name = "python_specific_test_protos", |
| 658 srcs = glob([ | 718 srcs = glob([ |
| 659 "python/google/protobuf/internal/*.proto", | 719 "python/google/protobuf/internal/*.proto", |
| 660 "python/google/protobuf/internal/import_test_package/*.proto", | 720 "python/google/protobuf/internal/import_test_package/*.proto", |
| 661 ]), | 721 ]), |
| 662 include = "python", | 722 include = "python", |
| 663 default_runtime = ":protobuf_python", | 723 default_runtime = ":protobuf_python", |
| 664 protoc = ":protoc", | 724 protoc = ":protoc", |
| 665 srcs_version = "PY2AND3", | 725 srcs_version = "PY2AND3", |
| 666 deps = [":python_common_test_protos"], | 726 deps = [":python_common_test_protos"], |
| 667 ) | 727 ) |
| 668 | 728 |
| 669 py_library( | 729 py_library( |
| 670 name = "python_tests", | 730 name = "python_tests", |
| 671 srcs = glob( | 731 srcs = glob( |
| 672 [ | 732 [ |
| 673 "python/google/protobuf/internal/*_test.py", | 733 "python/google/protobuf/internal/*_test.py", |
| 674 "python/google/protobuf/internal/test_util.py", | 734 "python/google/protobuf/internal/test_util.py", |
| 735 "python/google/protobuf/internal/import_test_package/__init__.py", |
| 675 ], | 736 ], |
| 676 ), | 737 ), |
| 677 imports = ["python"], | 738 imports = ["python"], |
| 678 srcs_version = "PY2AND3", | 739 srcs_version = "PY2AND3", |
| 679 deps = [ | 740 deps = [ |
| 680 ":protobuf_python", | 741 ":protobuf_python", |
| 681 ":python_common_test_protos", | 742 ":python_common_test_protos", |
| 682 ":python_specific_test_protos", | 743 ":python_specific_test_protos", |
| 683 ], | 744 ], |
| 684 ) | 745 ) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 700 "reflection_test", | 761 "reflection_test", |
| 701 "service_reflection_test", | 762 "service_reflection_test", |
| 702 "symbol_database_test", | 763 "symbol_database_test", |
| 703 "text_encoding_test", | 764 "text_encoding_test", |
| 704 "text_format_test", | 765 "text_format_test", |
| 705 "unknown_fields_test", | 766 "unknown_fields_test", |
| 706 "wire_format_test", | 767 "wire_format_test", |
| 707 ], | 768 ], |
| 708 deps = [":python_tests"], | 769 deps = [":python_tests"], |
| 709 ) | 770 ) |
| 771 |
| 772 proto_lang_toolchain( |
| 773 name = "cc_toolchain", |
| 774 runtime = ":protobuf", |
| 775 command_line = "--cpp_out=$(OUT)", |
| 776 visibility = ["//visibility:public"], |
| 777 ) |
| OLD | NEW |