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