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