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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 "src/google/protobuf/compiler/javanano/javanano_extension.cc", | 297 "src/google/protobuf/compiler/javanano/javanano_extension.cc", |
295 "src/google/protobuf/compiler/javanano/javanano_field.cc", | 298 "src/google/protobuf/compiler/javanano/javanano_field.cc", |
296 "src/google/protobuf/compiler/javanano/javanano_file.cc", | 299 "src/google/protobuf/compiler/javanano/javanano_file.cc", |
297 "src/google/protobuf/compiler/javanano/javanano_generator.cc", | 300 "src/google/protobuf/compiler/javanano/javanano_generator.cc", |
298 "src/google/protobuf/compiler/javanano/javanano_helpers.cc", | 301 "src/google/protobuf/compiler/javanano/javanano_helpers.cc", |
299 "src/google/protobuf/compiler/javanano/javanano_map_field.cc", | 302 "src/google/protobuf/compiler/javanano/javanano_map_field.cc", |
300 "src/google/protobuf/compiler/javanano/javanano_message.cc", | 303 "src/google/protobuf/compiler/javanano/javanano_message.cc", |
301 "src/google/protobuf/compiler/javanano/javanano_message_field.cc", | 304 "src/google/protobuf/compiler/javanano/javanano_message_field.cc", |
302 "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc", | 305 "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc", |
303 "src/google/protobuf/compiler/js/js_generator.cc", | 306 "src/google/protobuf/compiler/js/js_generator.cc", |
| 307 "src/google/protobuf/compiler/js/well_known_types_embed.cc", |
304 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", | 308 "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", |
305 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", | 309 "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", |
306 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", | 310 "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", |
307 "src/google/protobuf/compiler/objectivec/objectivec_field.cc", | 311 "src/google/protobuf/compiler/objectivec/objectivec_field.cc", |
308 "src/google/protobuf/compiler/objectivec/objectivec_file.cc", | 312 "src/google/protobuf/compiler/objectivec/objectivec_file.cc", |
309 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc", | 313 "src/google/protobuf/compiler/objectivec/objectivec_generator.cc", |
310 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc", | 314 "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc", |
311 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc", | 315 "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc", |
312 "src/google/protobuf/compiler/objectivec/objectivec_message.cc", | 316 "src/google/protobuf/compiler/objectivec/objectivec_message.cc", |
313 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc", | 317 "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc", |
314 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc", | 318 "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc", |
315 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", | 319 "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", |
| 320 "src/google/protobuf/compiler/php/php_generator.cc", |
316 "src/google/protobuf/compiler/plugin.cc", | 321 "src/google/protobuf/compiler/plugin.cc", |
317 "src/google/protobuf/compiler/plugin.pb.cc", | 322 "src/google/protobuf/compiler/plugin.pb.cc", |
318 "src/google/protobuf/compiler/python/python_generator.cc", | 323 "src/google/protobuf/compiler/python/python_generator.cc", |
319 "src/google/protobuf/compiler/ruby/ruby_generator.cc", | 324 "src/google/protobuf/compiler/ruby/ruby_generator.cc", |
320 "src/google/protobuf/compiler/subprocess.cc", | 325 "src/google/protobuf/compiler/subprocess.cc", |
321 "src/google/protobuf/compiler/zip_writer.cc", | 326 "src/google/protobuf/compiler/zip_writer.cc", |
322 ], | 327 ], |
323 copts = COPTS, | 328 copts = COPTS, |
324 includes = ["src/"], | 329 includes = ["src/"], |
325 linkopts = LINK_OPTS, | 330 linkopts = LINK_OPTS, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 "google/protobuf/unittest_proto3_arena_lite.proto", | 385 "google/protobuf/unittest_proto3_arena_lite.proto", |
381 "google/protobuf/unittest_proto3_lite.proto", | 386 "google/protobuf/unittest_proto3_lite.proto", |
382 "google/protobuf/unittest_well_known_types.proto", | 387 "google/protobuf/unittest_well_known_types.proto", |
383 "google/protobuf/util/internal/testdata/anys.proto", | 388 "google/protobuf/util/internal/testdata/anys.proto", |
384 "google/protobuf/util/internal/testdata/books.proto", | 389 "google/protobuf/util/internal/testdata/books.proto", |
385 "google/protobuf/util/internal/testdata/default_value.proto", | 390 "google/protobuf/util/internal/testdata/default_value.proto", |
386 "google/protobuf/util/internal/testdata/default_value_test.proto", | 391 "google/protobuf/util/internal/testdata/default_value_test.proto", |
387 "google/protobuf/util/internal/testdata/field_mask.proto", | 392 "google/protobuf/util/internal/testdata/field_mask.proto", |
388 "google/protobuf/util/internal/testdata/maps.proto", | 393 "google/protobuf/util/internal/testdata/maps.proto", |
389 "google/protobuf/util/internal/testdata/oneofs.proto", | 394 "google/protobuf/util/internal/testdata/oneofs.proto", |
| 395 "google/protobuf/util/internal/testdata/proto3.proto", |
390 "google/protobuf/util/internal/testdata/struct.proto", | 396 "google/protobuf/util/internal/testdata/struct.proto", |
391 "google/protobuf/util/internal/testdata/timestamp_duration.proto", | 397 "google/protobuf/util/internal/testdata/timestamp_duration.proto", |
| 398 "google/protobuf/util/internal/testdata/wrappers.proto", |
392 "google/protobuf/util/json_format_proto3.proto", | 399 "google/protobuf/util/json_format_proto3.proto", |
393 "google/protobuf/util/message_differencer_unittest.proto", | 400 "google/protobuf/util/message_differencer_unittest.proto", |
394 ] | 401 ] |
395 | 402 |
396 TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS] | 403 TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS] |
397 | 404 |
398 cc_proto_library( | 405 cc_proto_library( |
399 name = "cc_test_protos", | 406 name = "cc_test_protos", |
400 srcs = LITE_TEST_PROTOS + TEST_PROTOS, | 407 srcs = LITE_TEST_PROTOS + TEST_PROTOS, |
401 include = "src", | 408 include = "src", |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 ################################################################################ | 560 ################################################################################ |
554 | 561 |
555 py_library( | 562 py_library( |
556 name = "python_srcs", | 563 name = "python_srcs", |
557 srcs = glob( | 564 srcs = glob( |
558 [ | 565 [ |
559 "python/google/protobuf/*.py", | 566 "python/google/protobuf/*.py", |
560 "python/google/protobuf/**/*.py", | 567 "python/google/protobuf/**/*.py", |
561 ], | 568 ], |
562 exclude = [ | 569 exclude = [ |
| 570 "python/google/protobuf/__init__.py", |
| 571 "python/google/protobuf/**/__init__.py", |
563 "python/google/protobuf/internal/*_test.py", | 572 "python/google/protobuf/internal/*_test.py", |
564 "python/google/protobuf/internal/test_util.py", | 573 "python/google/protobuf/internal/test_util.py", |
565 ], | 574 ], |
566 ), | 575 ), |
567 srcs_version = "PY2AND3", | 576 srcs_version = "PY2AND3", |
568 imports = ["python"], | 577 imports = ["python"], |
569 ) | 578 ) |
570 | 579 |
571 cc_binary( | 580 cc_binary( |
572 name = "internal/_api_implementation.so", | 581 name = "python/google/protobuf/internal/_api_implementation.so", |
573 srcs = ["python/google/protobuf/internal/api_implementation.cc"], | 582 srcs = ["python/google/protobuf/internal/api_implementation.cc"], |
574 copts = COPTS + [ | 583 copts = COPTS + [ |
575 "-DPYTHON_PROTO2_CPP_IMPL_V2", | 584 "-DPYTHON_PROTO2_CPP_IMPL_V2", |
576 ], | 585 ], |
577 linkshared = 1, | 586 linkshared = 1, |
578 linkstatic = 1, | 587 linkstatic = 1, |
579 deps = select({ | 588 deps = select({ |
580 "//conditions:default": [], | 589 "//conditions:default": [], |
581 ":use_fast_cpp_protos": ["//external:python_headers"], | 590 ":use_fast_cpp_protos": ["//external:python_headers"], |
582 }), | 591 }), |
583 ) | 592 ) |
584 | 593 |
585 cc_binary( | 594 cc_binary( |
586 name = "pyext/_message.so", | 595 name = "python/google/protobuf/pyext/_message.so", |
587 srcs = glob([ | 596 srcs = glob([ |
588 "python/google/protobuf/pyext/*.cc", | 597 "python/google/protobuf/pyext/*.cc", |
589 "python/google/protobuf/pyext/*.h", | 598 "python/google/protobuf/pyext/*.h", |
590 ]), | 599 ]), |
591 copts = COPTS + [ | 600 copts = COPTS + [ |
592 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1", | 601 "-DGOOGLE_PROTOBUF_HAS_ONEOF=1", |
593 ] + select({ | 602 ] + select({ |
594 "//conditions:default": [], | 603 "//conditions:default": [], |
595 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"], | 604 ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"], |
596 }), | 605 }), |
(...skipping 18 matching lines...) Expand all Loading... |
615 }, | 624 }, |
616 ) | 625 ) |
617 | 626 |
618 config_setting( | 627 config_setting( |
619 name = "allow_oversize_protos", | 628 name = "allow_oversize_protos", |
620 values = { | 629 values = { |
621 "define": "allow_oversize_protos=true", | 630 "define": "allow_oversize_protos=true", |
622 }, | 631 }, |
623 ) | 632 ) |
624 | 633 |
| 634 # Copy the builtin proto files from src/google/protobuf to |
| 635 # python/google/protobuf. This way, the generated Python sources will be in the |
| 636 # same directory as the Python runtime sources. This is necessary for the |
| 637 # modules to be imported correctly since they are all part of the same Python |
| 638 # package. |
| 639 internal_copied_filegroup( |
| 640 name = "protos_python", |
| 641 srcs = WELL_KNOWN_PROTOS, |
| 642 strip_prefix = "src", |
| 643 dest = "python", |
| 644 ) |
| 645 |
| 646 # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in |
| 647 # which case we can simply add :protos_python in srcs. |
| 648 COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] |
| 649 |
625 py_proto_library( | 650 py_proto_library( |
626 name = "protobuf_python", | 651 name = "protobuf_python", |
627 srcs = WELL_KNOWN_PROTOS, | 652 srcs = COPIED_WELL_KNOWN_PROTOS, |
628 include = "src", | 653 include = "python", |
629 data = select({ | 654 data = select({ |
630 "//conditions:default": [], | 655 "//conditions:default": [], |
631 ":use_fast_cpp_protos": [ | 656 ":use_fast_cpp_protos": [ |
632 ":internal/_api_implementation.so", | 657 ":python/google/protobuf/internal/_api_implementation.so", |
633 ":pyext/_message.so", | 658 ":python/google/protobuf/pyext/_message.so", |
634 ], | 659 ], |
635 }), | 660 }), |
636 default_runtime = "", | 661 default_runtime = "", |
637 protoc = ":protoc", | 662 protoc = ":protoc", |
638 py_libs = [ | 663 py_libs = [ |
639 ":python_srcs", | 664 ":python_srcs", |
640 "//external:six" | 665 "//external:six" |
641 ], | 666 ], |
642 srcs_version = "PY2AND3", | 667 srcs_version = "PY2AND3", |
643 visibility = ["//visibility:public"], | 668 visibility = ["//visibility:public"], |
644 ) | 669 ) |
645 | 670 |
| 671 # Copy the test proto files from src/google/protobuf to |
| 672 # python/google/protobuf. This way, the generated Python sources will be in the |
| 673 # same directory as the Python runtime sources. This is necessary for the |
| 674 # modules to be imported correctly by the tests since they are all part of the |
| 675 # same Python package. |
| 676 internal_copied_filegroup( |
| 677 name = "protos_python_test", |
| 678 srcs = LITE_TEST_PROTOS + TEST_PROTOS, |
| 679 strip_prefix = "src", |
| 680 dest = "python", |
| 681 ) |
| 682 |
| 683 # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in |
| 684 # which case we can simply add :protos_python_test in srcs. |
| 685 COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS] |
| 686 COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS] |
| 687 |
646 py_proto_library( | 688 py_proto_library( |
647 name = "python_common_test_protos", | 689 name = "python_common_test_protos", |
648 srcs = LITE_TEST_PROTOS + TEST_PROTOS, | 690 srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS, |
649 include = "src", | 691 include = "python", |
650 default_runtime = "", | 692 default_runtime = "", |
651 protoc = ":protoc", | 693 protoc = ":protoc", |
652 srcs_version = "PY2AND3", | 694 srcs_version = "PY2AND3", |
653 deps = [":protobuf_python"], | 695 deps = [":protobuf_python"], |
654 ) | 696 ) |
655 | 697 |
656 py_proto_library( | 698 py_proto_library( |
657 name = "python_specific_test_protos", | 699 name = "python_specific_test_protos", |
658 srcs = glob([ | 700 srcs = glob([ |
659 "python/google/protobuf/internal/*.proto", | 701 "python/google/protobuf/internal/*.proto", |
660 "python/google/protobuf/internal/import_test_package/*.proto", | 702 "python/google/protobuf/internal/import_test_package/*.proto", |
661 ]), | 703 ]), |
662 include = "python", | 704 include = "python", |
663 default_runtime = ":protobuf_python", | 705 default_runtime = ":protobuf_python", |
664 protoc = ":protoc", | 706 protoc = ":protoc", |
665 srcs_version = "PY2AND3", | 707 srcs_version = "PY2AND3", |
666 deps = [":python_common_test_protos"], | 708 deps = [":python_common_test_protos"], |
667 ) | 709 ) |
668 | 710 |
669 py_library( | 711 py_library( |
670 name = "python_tests", | 712 name = "python_tests", |
671 srcs = glob( | 713 srcs = glob( |
672 [ | 714 [ |
673 "python/google/protobuf/internal/*_test.py", | 715 "python/google/protobuf/internal/*_test.py", |
674 "python/google/protobuf/internal/test_util.py", | 716 "python/google/protobuf/internal/test_util.py", |
| 717 "python/google/protobuf/internal/import_test_package/__init__.py", |
675 ], | 718 ], |
676 ), | 719 ), |
677 imports = ["python"], | 720 imports = ["python"], |
678 srcs_version = "PY2AND3", | 721 srcs_version = "PY2AND3", |
679 deps = [ | 722 deps = [ |
680 ":protobuf_python", | 723 ":protobuf_python", |
681 ":python_common_test_protos", | 724 ":python_common_test_protos", |
682 ":python_specific_test_protos", | 725 ":python_specific_test_protos", |
683 ], | 726 ], |
684 ) | 727 ) |
(...skipping 15 matching lines...) Expand all Loading... |
700 "reflection_test", | 743 "reflection_test", |
701 "service_reflection_test", | 744 "service_reflection_test", |
702 "symbol_database_test", | 745 "symbol_database_test", |
703 "text_encoding_test", | 746 "text_encoding_test", |
704 "text_format_test", | 747 "text_format_test", |
705 "unknown_fields_test", | 748 "unknown_fields_test", |
706 "wire_format_test", | 749 "wire_format_test", |
707 ], | 750 ], |
708 deps = [":python_tests"], | 751 deps = [":python_tests"], |
709 ) | 752 ) |
| 753 |
| 754 proto_lang_toolchain( |
| 755 name = "cc_toolchain", |
| 756 runtime = ":protobuf", |
| 757 command_line = "--cpp_out=$(OUT)", |
| 758 visibility = ["//visibility:public"], |
| 759 ) |
OLD | NEW |