| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/ios/ios_sdk.gni") | 5 import("//build/config/ios/ios_sdk.gni") |
| 6 import("//build/config/mac/base_rules.gni") | 6 import("//build/config/mac/base_rules.gni") |
| 7 | 7 |
| 8 # Generates Info.plist files for Mac apps and frameworks. | 8 # Generates Info.plist files for Mac apps and frameworks. |
| 9 # | 9 # |
| 10 # Arguments | 10 # Arguments |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 # See "gn help shared_library" for more information on arguments supported | 634 # See "gn help shared_library" for more information on arguments supported |
| 635 # by shared library target. | 635 # by shared library target. |
| 636 template("ios_framework_bundle") { | 636 template("ios_framework_bundle") { |
| 637 _target_name = target_name | 637 _target_name = target_name |
| 638 _output_name = target_name | 638 _output_name = target_name |
| 639 if (defined(invoker.output_name)) { | 639 if (defined(invoker.output_name)) { |
| 640 _output_name = invoker.output_name | 640 _output_name = invoker.output_name |
| 641 } | 641 } |
| 642 _framework_target = _target_name | 642 _framework_target = _target_name |
| 643 | 643 |
| 644 if (defined(invoker.public_headers) && invoker.public_headers != []) { | 644 _has_public_headers = |
| 645 _public_headers = invoker.public_headers | 645 defined(invoker.public_headers) && invoker.public_headers != [] |
| 646 _framework_name = _output_name + ".framework" | 646 |
| 647 _framework_root = "$root_out_dir/$_framework_name" | 647 _is_fat_build = additional_toolchains != [] |
| 648 if (_is_fat_build) { |
| 649 _is_fat_build_main_target = current_toolchain == default_toolchain |
| 650 } |
| 651 |
| 652 # This template has a different expansion depending on whether public headers |
| 653 # are defined or not. If no public headers are speficied, then is forwards to |
| 654 # the generic "framework_bundle" target, otherwise if expands to targets that |
| 655 # create header map mapping and corresponding config and configure them as |
| 656 # dependencies of the generic "framework_bundle" target. |
| 657 # |
| 658 # The expansion is a bit different for multi-architecture builds (aka fat |
| 659 # binary builds). Then the targets build for the non-default toolchain uses |
| 660 # the same header map (if available) as the one used by the default toolchain. |
| 661 |
| 662 _toolchain_suffix = "" |
| 663 if (_is_fat_build && !_is_fat_build_main_target) { |
| 664 _toolchain_suffix = "($default_toolchain)" |
| 665 } |
| 666 |
| 667 if (_has_public_headers) { |
| 668 _framework_headers_target = _target_name + "_framework_headers" |
| 669 _framework_public_config = _target_name + "_ios_public_config" |
| 648 _framework_target = target_name + "_internal" | 670 _framework_target = target_name + "_internal" |
| 671 _headers_map_config = _target_name + "_headers_map" |
| 649 | 672 |
| 650 _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap" | 673 if (!_is_fat_build || _is_fat_build_main_target) { |
| 651 _framework_headers_target = _target_name + "_framework_headers" | 674 _public_headers = invoker.public_headers |
| 675 _framework_name = _output_name + ".framework" |
| 676 _framework_root = "$root_out_dir/$_framework_name" |
| 652 | 677 |
| 653 _compile_headers_map_target = _target_name + "_compile_headers_map" | 678 _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap" |
| 654 action(_compile_headers_map_target) { | |
| 655 visibility = [ ":$_framework_headers_target" ] | |
| 656 script = "//build/config/ios/write_framework_hmap.py" | |
| 657 outputs = [ | |
| 658 _header_map_filename, | |
| 659 ] | |
| 660 | 679 |
| 661 # The header map generation only wants the list of headers, not all of | 680 _compile_headers_map_target = _target_name + "_compile_headers_map" |
| 662 # sources, so filter any non-header source files from "sources". It is | 681 action(_compile_headers_map_target) { |
| 663 # less error prone that having the developer duplicate the list of all | 682 visibility = [ ":$_framework_headers_target" ] |
| 664 # headers in addition to "sources". | 683 script = "//build/config/ios/write_framework_hmap.py" |
| 665 set_sources_assignment_filter([ | 684 outputs = [ |
| 666 "*.c", | 685 _header_map_filename, |
| 667 "*.cc", | 686 ] |
| 668 "*.cpp", | |
| 669 "*.m", | |
| 670 "*.mm", | |
| 671 ]) | |
| 672 sources = invoker.sources | |
| 673 set_sources_assignment_filter([]) | |
| 674 | 687 |
| 675 args = [ | 688 # The header map generation only wants the list of headers, not all of |
| 676 rebase_path(_header_map_filename), | 689 # sources, so filter any non-header source files from "sources". It is |
| 677 rebase_path(_framework_root, root_build_dir), | 690 # less error prone that having the developer duplicate the list of all |
| 678 ] + rebase_path(sources, root_build_dir) | 691 # headers in addition to "sources". |
| 679 } | 692 set_sources_assignment_filter([ |
| 693 "*.c", |
| 694 "*.cc", |
| 695 "*.cpp", |
| 696 "*.m", |
| 697 "*.mm", |
| 698 ]) |
| 699 sources = invoker.sources |
| 700 set_sources_assignment_filter([]) |
| 680 | 701 |
| 681 _create_module_map_target = _target_name + "_module_map" | 702 args = [ |
| 682 action(_create_module_map_target) { | 703 rebase_path(_header_map_filename), |
| 683 visibility = [ ":$_framework_headers_target" ] | 704 rebase_path(_framework_root, root_build_dir), |
| 684 script = "//build/config/ios/write_framework_modulemap.py" | 705 ] + rebase_path(sources, root_build_dir) |
| 685 outputs = [ | 706 } |
| 686 "$_framework_root/Modules/module.modulemap", | |
| 687 ] | |
| 688 args = [ rebase_path("$_framework_root", root_build_dir) ] | |
| 689 } | |
| 690 | 707 |
| 691 _copy_public_headers_target = _target_name + "_copy_public_headers" | 708 _create_module_map_target = _target_name + "_module_map" |
| 692 copy(_copy_public_headers_target) { | 709 action(_create_module_map_target) { |
| 693 visibility = [ ":$_framework_headers_target" ] | 710 visibility = [ ":$_framework_headers_target" ] |
| 694 sources = _public_headers | 711 script = "//build/config/ios/write_framework_modulemap.py" |
| 695 outputs = [ | 712 outputs = [ |
| 696 "$_framework_root/Headers/{{source_file_part}}", | 713 "$_framework_root/Modules/module.modulemap", |
| 697 ] | 714 ] |
| 698 } | 715 args = [ rebase_path("$_framework_root", root_build_dir) ] |
| 716 } |
| 699 | 717 |
| 700 _headers_map_config = _target_name + "_headers_map" | 718 _copy_public_headers_target = _target_name + "_copy_public_headers" |
| 701 config(_headers_map_config) { | 719 copy(_copy_public_headers_target) { |
| 702 visibility = [ ":$_target_name" ] | 720 visibility = [ ":$_framework_headers_target" ] |
| 703 include_dirs = [ _header_map_filename ] | 721 sources = _public_headers |
| 704 ldflags = [ | 722 outputs = [ |
| 705 "-install_name", | 723 "$_framework_root/Headers/{{source_file_part}}", |
| 706 "@rpath/$_framework_name/$_output_name", | 724 ] |
| 707 ] | 725 } |
| 708 } | |
| 709 | 726 |
| 710 group(_framework_headers_target) { | 727 config(_headers_map_config) { |
| 711 deps = [ | 728 visibility = [ ":$_target_name" ] |
| 712 ":$_compile_headers_map_target", | 729 include_dirs = [ _header_map_filename ] |
| 713 ":$_copy_public_headers_target", | 730 ldflags = [ |
| 714 ":$_create_module_map_target", | 731 "-install_name", |
| 715 ] | 732 "@rpath/$_framework_name/$_output_name", |
| 733 ] |
| 734 } |
| 735 |
| 736 group(_framework_headers_target) { |
| 737 deps = [ |
| 738 ":$_compile_headers_map_target", |
| 739 ":$_copy_public_headers_target", |
| 740 ":$_create_module_map_target", |
| 741 ] |
| 742 } |
| 743 |
| 744 config(_framework_public_config) { |
| 745 visibility = [ ":$_framework_public_config" ] |
| 746 common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_build_dir) ] |
| 747 cflags_objc = common_flags |
| 748 cflags_objcc = common_flags |
| 749 |
| 750 # The link settings are inherited from the framework_bundle config. |
| 751 } |
| 716 } | 752 } |
| 717 } | 753 } |
| 718 | 754 |
| 719 _framework_public_config = _target_name + "_ios_public_config" | |
| 720 config(_framework_public_config) { | |
| 721 visibility = [ ":$_framework_public_config" ] | |
| 722 if (defined(_public_headers)) { | |
| 723 common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_build_dir) ] | |
| 724 cflags_objc = common_flags | |
| 725 cflags_objcc = common_flags | |
| 726 } | |
| 727 | |
| 728 # The link settings are inherited from the framework_bundle config. | |
| 729 } | |
| 730 | |
| 731 framework_bundle(_framework_target) { | 755 framework_bundle(_framework_target) { |
| 732 forward_variables_from(invoker, | 756 forward_variables_from(invoker, |
| 733 "*", | 757 "*", |
| 734 [ | 758 [ |
| 735 "output_name", | 759 "output_name", |
| 736 "public_headers", | 760 "public_headers", |
| 737 "visibility", | 761 "visibility", |
| 738 ]) | 762 ]) |
| 739 output_name = _output_name | 763 output_name = _output_name |
| 740 | 764 |
| 741 if (!defined(public_configs)) { | 765 if (_has_public_headers) { |
| 742 public_configs = [] | 766 if (!defined(public_configs)) { |
| 767 public_configs = [] |
| 768 } |
| 769 public_configs += [ ":$_framework_public_config$_toolchain_suffix" ] |
| 743 } | 770 } |
| 744 public_configs += [ ":$_framework_public_config" ] | |
| 745 | 771 |
| 746 if (defined(_public_headers)) { | 772 if (_has_public_headers) { |
| 747 visibility = [ | 773 visibility = [ |
| 748 ":$_target_name", | 774 ":$_target_name$_toolchain_suffix", |
| 749 ":$_target_name+link", | 775 ":$_target_name+link$_toolchain_suffix", |
| 750 ] | 776 ] |
| 751 configs += [ ":$_headers_map_config" ] | 777 configs += [ ":$_headers_map_config$_toolchain_suffix" ] |
| 752 | 778 |
| 753 if (!defined(deps)) { | 779 if (!defined(deps)) { |
| 754 deps = [] | 780 deps = [] |
| 755 } | 781 } |
| 756 deps += [ ":$_framework_headers_target" ] | 782 deps += [ ":$_framework_headers_target$_toolchain_suffix" ] |
| 757 } else { | 783 } else { |
| 758 if (defined(invoker.visibility)) { | 784 if (defined(invoker.visibility)) { |
| 759 visibility = invoker.visibility | 785 visibility = invoker.visibility |
| 760 visibility += [ ":$_target_name+link" ] | 786 visibility += [ ":$_target_name+link$_toolchain_suffix" ] |
| 761 } | 787 } |
| 762 } | 788 } |
| 763 } | 789 } |
| 764 | 790 |
| 765 if (defined(_public_headers)) { | 791 if (_has_public_headers) { |
| 766 group(_target_name) { | 792 group(_target_name) { |
| 767 forward_variables_from(invoker, | 793 forward_variables_from(invoker, |
| 768 [ | 794 [ |
| 769 "testonly", | 795 "testonly", |
| 770 "public_configs", | 796 "public_configs", |
| 771 ]) | 797 ]) |
| 772 | 798 |
| 773 if (defined(invoker.visibility)) { | 799 if (defined(invoker.visibility)) { |
| 774 visibility = invoker.visibility | 800 visibility = invoker.visibility |
| 775 visibility += [ ":$_target_name+link" ] | 801 visibility += [ ":$_target_name+link" ] |
| 776 } | 802 } |
| 777 | 803 |
| 778 public_deps = [ | 804 public_deps = [ |
| 779 ":$_framework_target", | 805 ":$_framework_target$_toolchain_suffix", |
| 780 ] | 806 ] |
| 781 } | 807 } |
| 782 | 808 |
| 783 group(_target_name + "+link") { | 809 group(_target_name + "+link") { |
| 784 forward_variables_from(invoker, | 810 forward_variables_from(invoker, |
| 785 [ | 811 [ |
| 786 "testonly", | 812 "testonly", |
| 787 "visibility", | 813 "visibility", |
| 788 ]) | 814 ]) |
| 789 public_deps = [ | 815 public_deps = [ |
| 790 ":$_framework_target+link", | 816 ":$_framework_target+link$_toolchain_suffix", |
| 791 ] | 817 ] |
| 792 } | 818 } |
| 793 } | 819 } |
| 794 } | 820 } |
| 795 | 821 |
| 796 set_defaults("ios_framework_bundle") { | 822 set_defaults("ios_framework_bundle") { |
| 797 configs = default_shared_library_configs | 823 configs = default_shared_library_configs |
| 798 } | 824 } |
| OLD | NEW |