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