| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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/android/config.gni") | 5 import("//build/config/android/config.gni") |
| 6 import("//build/config/android/internal_rules.gni") | 6 import("//build/config/android/internal_rules.gni") |
| 7 import("//build/toolchain/toolchain.gni") | 7 import("//build/toolchain/toolchain.gni") |
| 8 | 8 |
| 9 assert(is_android) | 9 assert(is_android) |
| 10 | 10 |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 # target. | 703 # target. |
| 704 # resource_dirs: List of directories containing resources for this target. | 704 # resource_dirs: List of directories containing resources for this target. |
| 705 # generated_resource_dirs: List of directories containing resources for this | 705 # generated_resource_dirs: List of directories containing resources for this |
| 706 # target which are *generated* by a dependency. |generated_resource_files| | 706 # target which are *generated* by a dependency. |generated_resource_files| |
| 707 # must be specified if |generated_resource_dirs| is specified. | 707 # must be specified if |generated_resource_dirs| is specified. |
| 708 # generated_resource_files: List of all files in |generated_resource_dirs|. | 708 # generated_resource_files: List of all files in |generated_resource_dirs|. |
| 709 # |generated_resource_dirs| must be specified in |generated_resource_files
| | 709 # |generated_resource_dirs| must be specified in |generated_resource_files
| |
| 710 # is specified. | 710 # is specified. |
| 711 # android_manifest: AndroidManifest.xml for this target. Defaults to | 711 # android_manifest: AndroidManifest.xml for this target. Defaults to |
| 712 # //build/android/AndroidManifest.xml. | 712 # //build/android/AndroidManifest.xml. |
| 713 # android_manifest_dep: Target that generates AndroidManifest (if applicable
) | |
| 714 # custom_package: java package for generated .java files. | 713 # custom_package: java package for generated .java files. |
| 715 # v14_skip: If true, don't run v14 resource generator on this. Defaults to | 714 # v14_skip: If true, don't run v14 resource generator on this. Defaults to |
| 716 # false. (see build/android/gyp/generate_v14_compatible_resources.py) | 715 # false. (see build/android/gyp/generate_v14_compatible_resources.py) |
| 717 # shared_resources: If true make a resource package that can be loaded by a | 716 # shared_resources: If true make a resource package that can be loaded by a |
| 718 # different application at runtime to access the package's resources. | 717 # different application at runtime to access the package's resources. |
| 719 # app_as_shared_lib: If true make a resource package that can be loaded as | 718 # app_as_shared_lib: If true make a resource package that can be loaded as |
| 720 # both shared_resources and normal application. | 719 # both shared_resources and normal application. |
| 721 | 720 |
| 722 # Example: | 721 # Example: |
| 723 # android_resources("foo_resources") { | 722 # android_resources("foo_resources") { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 740 zip_path = base_path + ".resources.zip" | 739 zip_path = base_path + ".resources.zip" |
| 741 srcjar_path = base_path + ".srcjar" | 740 srcjar_path = base_path + ".srcjar" |
| 742 r_text_path = base_path + "_R.txt" | 741 r_text_path = base_path + "_R.txt" |
| 743 build_config = base_path + ".build_config" | 742 build_config = base_path + ".build_config" |
| 744 | 743 |
| 745 build_config_target_name = "${target_name}__build_config" | 744 build_config_target_name = "${target_name}__build_config" |
| 746 process_resources_target_name = "${target_name}__process_resources" | 745 process_resources_target_name = "${target_name}__process_resources" |
| 747 final_target_name = target_name | 746 final_target_name = target_name |
| 748 | 747 |
| 749 write_build_config(build_config_target_name) { | 748 write_build_config(build_config_target_name) { |
| 750 type = "android_resources" | |
| 751 forward_variables_from(invoker, | 749 forward_variables_from(invoker, |
| 752 [ | 750 [ |
| 753 "android_manifest", | 751 "android_manifest", |
| 754 "custom_package", | 752 "custom_package", |
| 753 "deps", |
| 755 "resource_dirs", | 754 "resource_dirs", |
| 756 ]) | 755 ]) |
| 757 | 756 |
| 758 if (defined(invoker.deps)) { | |
| 759 possible_config_deps = invoker.deps | |
| 760 } | |
| 761 if (defined(invoker.android_manifest_dep)) { | |
| 762 deps = [ | |
| 763 invoker.android_manifest_dep, | |
| 764 ] | |
| 765 } | |
| 766 | |
| 767 # No package means resources override their deps. | 757 # No package means resources override their deps. |
| 768 if (defined(custom_package) || defined(android_manifest)) { | 758 if (defined(custom_package) || defined(android_manifest)) { |
| 769 r_text = r_text_path | 759 r_text = r_text_path |
| 770 } else { | 760 } else { |
| 771 assert(defined(invoker.deps), | 761 assert(defined(invoker.deps), |
| 772 "Must specify deps when custom_package is omitted.") | 762 "Must specify deps when custom_package is omitted.") |
| 773 } | 763 } |
| 764 visibility = [ ":$process_resources_target_name" ] |
| 774 | 765 |
| 766 type = "android_resources" |
| 775 resources_zip = zip_path | 767 resources_zip = zip_path |
| 776 srcjar = srcjar_path | 768 srcjar = srcjar_path |
| 777 } | 769 } |
| 778 | 770 |
| 779 process_resources(process_resources_target_name) { | 771 process_resources(process_resources_target_name) { |
| 772 visibility = [ ":$final_target_name" ] |
| 780 forward_variables_from(invoker, | 773 forward_variables_from(invoker, |
| 781 [ | 774 [ |
| 782 "app_as_shared_lib", | 775 "app_as_shared_lib", |
| 783 "android_manifest", | 776 "android_manifest", |
| 784 "custom_package", | 777 "custom_package", |
| 785 "deps", | 778 "deps", |
| 786 "generated_resource_dirs", | 779 "generated_resource_dirs", |
| 787 "generated_resource_files", | 780 "generated_resource_files", |
| 788 "resource_dirs", | 781 "resource_dirs", |
| 789 "shared_resources", | 782 "shared_resources", |
| 790 "v14_skip", | 783 "v14_skip", |
| 791 ]) | 784 ]) |
| 792 if (!defined(deps)) { | 785 if (!defined(deps)) { |
| 793 deps = [] | 786 deps = [] |
| 794 } | 787 } |
| 795 deps += [ ":$build_config_target_name" ] | 788 deps += [ ":$build_config_target_name" ] |
| 796 if (defined(invoker.android_manifest_dep)) { | |
| 797 deps += [ invoker.android_manifest_dep ] | |
| 798 } | |
| 799 | 789 |
| 800 # Always generate R.onResourcesLoaded() method, it is required for | 790 # Always generate R.onResourcesLoaded() method, it is required for |
| 801 # compiling ResourceRewriter, there is no side effect because the | 791 # compiling ResourceRewriter, there is no side effect because the |
| 802 # generated R.class isn't used in final apk. | 792 # generated R.class isn't used in final apk. |
| 803 shared_resources = true | 793 shared_resources = true |
| 804 if (!defined(android_manifest)) { | 794 if (!defined(android_manifest)) { |
| 805 android_manifest = "//build/android/AndroidManifest.xml" | 795 android_manifest = "//build/android/AndroidManifest.xml" |
| 806 } | 796 } |
| 807 } | 797 } |
| 808 | 798 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 # renaming_destinations = [ "renamed/asset2.png" ] | 842 # renaming_destinations = [ "renamed/asset2.png" ] |
| 853 # } | 843 # } |
| 854 template("android_assets") { | 844 template("android_assets") { |
| 855 set_sources_assignment_filter([]) | 845 set_sources_assignment_filter([]) |
| 856 forward_variables_from(invoker, [ "testonly" ]) | 846 forward_variables_from(invoker, [ "testonly" ]) |
| 857 | 847 |
| 858 _build_config = "$target_gen_dir/$target_name.build_config" | 848 _build_config = "$target_gen_dir/$target_name.build_config" |
| 859 _build_config_target_name = "${target_name}__build_config" | 849 _build_config_target_name = "${target_name}__build_config" |
| 860 | 850 |
| 861 write_build_config(_build_config_target_name) { | 851 write_build_config(_build_config_target_name) { |
| 852 forward_variables_from(invoker, |
| 853 [ |
| 854 "deps", |
| 855 "disable_compression", |
| 856 ]) |
| 862 type = "android_assets" | 857 type = "android_assets" |
| 863 build_config = _build_config | 858 build_config = _build_config |
| 864 | |
| 865 forward_variables_from(invoker, [ "disable_compression" ]) | |
| 866 | |
| 867 if (defined(invoker.deps)) { | |
| 868 possible_config_deps = invoker.deps | |
| 869 } | |
| 870 | |
| 871 if (defined(invoker.sources)) { | 859 if (defined(invoker.sources)) { |
| 872 asset_sources = invoker.sources | 860 asset_sources = invoker.sources |
| 873 } | 861 } |
| 874 if (defined(invoker.renaming_sources)) { | 862 if (defined(invoker.renaming_sources)) { |
| 875 assert(defined(invoker.renaming_destinations)) | 863 assert(defined(invoker.renaming_destinations)) |
| 876 _source_count = 0 | 864 _source_count = 0 |
| 877 foreach(_, invoker.renaming_sources) { | 865 foreach(_, invoker.renaming_sources) { |
| 878 _source_count += 1 | 866 _source_count += 1 |
| 879 } | 867 } |
| 880 _dest_count = 0 | 868 _dest_count = 0 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 900 # Declare a group() that supports forwarding java dependency information. | 888 # Declare a group() that supports forwarding java dependency information. |
| 901 # | 889 # |
| 902 # Example | 890 # Example |
| 903 # java_group("conditional_deps") { | 891 # java_group("conditional_deps") { |
| 904 # if (enable_foo) { | 892 # if (enable_foo) { |
| 905 # deps = [":foo_java"] | 893 # deps = [":foo_java"] |
| 906 # } | 894 # } |
| 907 # } | 895 # } |
| 908 template("java_group") { | 896 template("java_group") { |
| 909 write_build_config("${target_name}__build_config") { | 897 write_build_config("${target_name}__build_config") { |
| 898 forward_variables_from(invoker, [ "deps" ]) |
| 910 type = "group" | 899 type = "group" |
| 911 build_config = "$target_gen_dir/${invoker.target_name}.build_config" | 900 build_config = "$target_gen_dir/${invoker.target_name}.build_config" |
| 912 | |
| 913 if (defined(invoker.deps)) { | |
| 914 possible_config_deps = invoker.deps | |
| 915 } | |
| 916 } | 901 } |
| 917 group(target_name) { | 902 group(target_name) { |
| 903 deps = [] |
| 918 forward_variables_from(invoker, "*") | 904 forward_variables_from(invoker, "*") |
| 919 if (!defined(deps)) { | |
| 920 deps = [] | |
| 921 } | |
| 922 deps += [ ":${target_name}__build_config" ] | 905 deps += [ ":${target_name}__build_config" ] |
| 923 } | 906 } |
| 924 } | 907 } |
| 925 | 908 |
| 926 # Declare a target that generates localized strings.xml from a .grd file. | 909 # Declare a target that generates localized strings.xml from a .grd file. |
| 927 # | 910 # |
| 928 # If this target is included in the deps of an android resources/library/apk, | 911 # If this target is included in the deps of an android resources/library/apk, |
| 929 # the strings.xml will be included with that target. | 912 # the strings.xml will be included with that target. |
| 930 # | 913 # |
| 931 # Variables | 914 # Variables |
| 932 # deps: Specifies the dependencies of this target. | 915 # deps: Specifies the dependencies of this target. |
| 933 # grd_file: Path to the .grd file to generate strings.xml from. | 916 # grd_file: Path to the .grd file to generate strings.xml from. |
| 934 # outputs: Expected grit outputs (see grit rule). | 917 # outputs: Expected grit outputs (see grit rule). |
| 935 # | 918 # |
| 936 # Example | 919 # Example |
| 937 # java_strings_grd("foo_strings_grd") { | 920 # java_strings_grd("foo_strings_grd") { |
| 938 # grd_file = "foo_strings.grd" | 921 # grd_file = "foo_strings.grd" |
| 939 # } | 922 # } |
| 940 template("java_strings_grd") { | 923 template("java_strings_grd") { |
| 941 set_sources_assignment_filter([]) | 924 set_sources_assignment_filter([]) |
| 942 forward_variables_from(invoker, [ "testonly" ]) | 925 forward_variables_from(invoker, [ "testonly" ]) |
| 943 | 926 |
| 944 base_path = "$target_gen_dir/$target_name" | 927 base_path = "$target_gen_dir/$target_name" |
| 945 resources_zip = base_path + ".resources.zip" | 928 resources_zip = base_path + ".resources.zip" |
| 946 build_config = base_path + ".build_config" | 929 build_config = base_path + ".build_config" |
| 947 | 930 |
| 948 write_build_config("${target_name}__build_config") { | 931 write_build_config("${target_name}__build_config") { |
| 932 forward_variables_from(invoker, [ "deps" ]) |
| 949 type = "android_resources" | 933 type = "android_resources" |
| 950 } | 934 } |
| 951 | 935 |
| 952 # Put grit files into this subdirectory of target_gen_dir. | 936 # Put grit files into this subdirectory of target_gen_dir. |
| 953 extra_output_path = target_name + "_grit_output" | 937 extra_output_path = target_name + "_grit_output" |
| 954 | 938 |
| 955 grit_target_name = "${target_name}__grit" | 939 grit_target_name = "${target_name}__grit" |
| 956 grit_output_dir = "$target_gen_dir/$extra_output_path" | 940 grit_output_dir = "$target_gen_dir/$extra_output_path" |
| 957 grit(grit_target_name) { | 941 grit(grit_target_name) { |
| 958 forward_variables_from(invoker, [ "deps" ]) | |
| 959 grit_flags = [ | 942 grit_flags = [ |
| 960 "-E", | 943 "-E", |
| 961 "ANDROID_JAVA_TAGGED_ONLY=false", | 944 "ANDROID_JAVA_TAGGED_ONLY=false", |
| 962 ] | 945 ] |
| 963 output_dir = grit_output_dir | 946 output_dir = grit_output_dir |
| 964 resource_ids = "" | 947 resource_ids = "" |
| 965 source = invoker.grd_file | 948 source = invoker.grd_file |
| 966 outputs = invoker.outputs | 949 outputs = invoker.outputs |
| 967 } | 950 } |
| 968 | 951 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 | 992 |
| 1010 base_path = "$target_gen_dir/$target_name" | 993 base_path = "$target_gen_dir/$target_name" |
| 1011 resources_zip = base_path + ".resources.zip" | 994 resources_zip = base_path + ".resources.zip" |
| 1012 build_config = base_path + ".build_config" | 995 build_config = base_path + ".build_config" |
| 1013 | 996 |
| 1014 build_config_target_name = "${target_name}__build_config" | 997 build_config_target_name = "${target_name}__build_config" |
| 1015 zip_target_name = "${target_name}__zip" | 998 zip_target_name = "${target_name}__zip" |
| 1016 final_target_name = target_name | 999 final_target_name = target_name |
| 1017 | 1000 |
| 1018 write_build_config(build_config_target_name) { | 1001 write_build_config(build_config_target_name) { |
| 1002 visibility = [ ":$zip_target_name" ] |
| 1019 type = "android_resources" | 1003 type = "android_resources" |
| 1020 } | 1004 } |
| 1021 | 1005 |
| 1022 zip(zip_target_name) { | 1006 zip(zip_target_name) { |
| 1023 visibility = [ ":$final_target_name" ] | 1007 visibility = [ ":$final_target_name" ] |
| 1024 | 1008 |
| 1025 base_dir = invoker.grit_output_dir | 1009 base_dir = invoker.grit_output_dir |
| 1026 inputs = rebase_path(invoker.generated_files, ".", base_dir) | 1010 inputs = rebase_path(invoker.generated_files, ".", base_dir) |
| 1027 output = resources_zip | 1011 output = resources_zip |
| 1028 deps = [ | 1012 deps = [ |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 jar_path = _jar_path | 1603 jar_path = _jar_path |
| 1620 dex_path = final_dex_path | 1604 dex_path = final_dex_path |
| 1621 apk_path = _final_apk_path | 1605 apk_path = _final_apk_path |
| 1622 incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk" | 1606 incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk" |
| 1623 incremental_install_script_path = _incremental_install_script_path | 1607 incremental_install_script_path = _incremental_install_script_path |
| 1624 resources_zip = resources_zip_path | 1608 resources_zip = resources_zip_path |
| 1625 build_config = _build_config | 1609 build_config = _build_config |
| 1626 android_manifest = _android_manifest | 1610 android_manifest = _android_manifest |
| 1627 | 1611 |
| 1628 deps = _android_manifest_deps | 1612 deps = _android_manifest_deps |
| 1629 | |
| 1630 if (defined(invoker.deps)) { | 1613 if (defined(invoker.deps)) { |
| 1631 possible_config_deps = invoker.deps | 1614 deps += invoker.deps |
| 1632 } | 1615 } |
| 1633 | 1616 |
| 1634 if (defined(invoker.alternative_locale_resource_dep)) { | 1617 if (defined(invoker.alternative_locale_resource_dep)) { |
| 1635 possible_config_deps += [ invoker.alternative_locale_resource_dep ] | 1618 deps += [ invoker.alternative_locale_resource_dep ] |
| 1636 has_alternative_locale_resource = true | 1619 has_alternative_locale_resource = true |
| 1637 } | 1620 } |
| 1638 | 1621 |
| 1639 # Added emma to the target's classpath via its .build_config. | 1622 # Added emma to the target's classpath via its .build_config. |
| 1640 if (emma_coverage && !_emma_never_instrument) { | 1623 if (emma_coverage && !_emma_never_instrument) { |
| 1641 possible_config_deps += [ "//third_party/android_tools:emma_device" ] | 1624 deps += [ "//third_party/android_tools:emma_device" ] |
| 1642 } | 1625 } |
| 1643 | 1626 |
| 1644 proguard_enabled = _proguard_enabled | 1627 proguard_enabled = _proguard_enabled |
| 1645 if (_proguard_enabled) { | 1628 if (_proguard_enabled) { |
| 1646 proguard_info = "$_proguard_output_jar_path.info" | 1629 proguard_info = "$_proguard_output_jar_path.info" |
| 1647 } | 1630 } |
| 1648 | 1631 |
| 1649 # Don't depend on the runtime_deps target in order to avoid having to | 1632 # Don't depend on the runtime_deps target in order to avoid having to |
| 1650 # build the native libraries just to create the .build_config file. | 1633 # build the native libraries just to create the .build_config file. |
| 1651 # The dep is unnecessary since the runtime_deps file is created by gn gen | 1634 # The dep is unnecessary since the runtime_deps file is created by gn gen |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2510 android_library(target_name) { | 2493 android_library(target_name) { |
| 2511 chromium_code = false | 2494 chromium_code = false |
| 2512 java_files = [] | 2495 java_files = [] |
| 2513 srcjar_deps = [ ":${_template_name}__protoc_java" ] | 2496 srcjar_deps = [ ":${_template_name}__protoc_java" ] |
| 2514 deps = [ | 2497 deps = [ |
| 2515 "//third_party/android_protobuf:protobuf_nano_javalib", | 2498 "//third_party/android_protobuf:protobuf_nano_javalib", |
| 2516 ] | 2499 ] |
| 2517 } | 2500 } |
| 2518 } | 2501 } |
| 2519 } | 2502 } |
| OLD | NEW |