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