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 |
869 foreach(_, invoker.renaming_destinations) { | 881 foreach(_, invoker.renaming_destinations) { |
870 _dest_count += 1 | 882 _dest_count += 1 |
871 } | 883 } |
872 assert( | 884 assert( |
873 _source_count == _dest_count, | 885 _source_count == _dest_count, |
874 "android_assets() renaming_sources.length != renaming_destinations.l
ength") | 886 "android_assets() renaming_sources.length != renaming_destinations.l
ength") |
875 asset_renaming_sources = invoker.renaming_sources | 887 asset_renaming_sources = invoker.renaming_sources |
876 asset_renaming_destinations = invoker.renaming_destinations | 888 asset_renaming_destinations = invoker.renaming_destinations |
877 } | 889 } |
878 } | 890 } |
879 | 891 |
880 group(target_name) { | 892 group(target_name) { |
881 forward_variables_from(invoker, [ "visibility" ]) | 893 forward_variables_from(invoker, |
| 894 [ |
| 895 "deps", |
| 896 "visibility", |
| 897 ]) |
882 public_deps = [ | 898 public_deps = [ |
883 ":$_build_config_target_name", | 899 ":$_build_config_target_name", |
884 ] | 900 ] |
885 } | 901 } |
886 } | 902 } |
887 | 903 |
888 # Declare a group() that supports forwarding java dependency information. | 904 # Declare a group() that supports forwarding java dependency information. |
889 # | 905 # |
890 # Example | 906 # Example |
891 # java_group("conditional_deps") { | 907 # java_group("conditional_deps") { |
892 # if (enable_foo) { | 908 # if (enable_foo) { |
893 # deps = [":foo_java"] | 909 # deps = [":foo_java"] |
894 # } | 910 # } |
895 # } | 911 # } |
896 template("java_group") { | 912 template("java_group") { |
897 write_build_config("${target_name}__build_config") { | 913 write_build_config("${target_name}__build_config") { |
898 forward_variables_from(invoker, [ "deps" ]) | |
899 type = "group" | 914 type = "group" |
900 build_config = "$target_gen_dir/${invoker.target_name}.build_config" | 915 build_config = "$target_gen_dir/${invoker.target_name}.build_config" |
| 916 |
| 917 if (defined(invoker.deps)) { |
| 918 possible_config_deps = invoker.deps |
| 919 } |
901 } | 920 } |
902 group(target_name) { | 921 group(target_name) { |
903 deps = [] | |
904 forward_variables_from(invoker, "*") | 922 forward_variables_from(invoker, "*") |
| 923 if (!defined(deps)) { |
| 924 deps = [] |
| 925 } |
905 deps += [ ":${target_name}__build_config" ] | 926 deps += [ ":${target_name}__build_config" ] |
906 } | 927 } |
907 } | 928 } |
908 | 929 |
909 # Declare a target that generates localized strings.xml from a .grd file. | 930 # Declare a target that generates localized strings.xml from a .grd file. |
910 # | 931 # |
911 # If this target is included in the deps of an android resources/library/apk, | 932 # If this target is included in the deps of an android resources/library/apk, |
912 # the strings.xml will be included with that target. | 933 # the strings.xml will be included with that target. |
913 # | 934 # |
914 # Variables | 935 # Variables |
915 # deps: Specifies the dependencies of this target. | 936 # deps: Specifies the dependencies of this target. |
916 # grd_file: Path to the .grd file to generate strings.xml from. | 937 # grd_file: Path to the .grd file to generate strings.xml from. |
917 # outputs: Expected grit outputs (see grit rule). | 938 # outputs: Expected grit outputs (see grit rule). |
918 # | 939 # |
919 # Example | 940 # Example |
920 # java_strings_grd("foo_strings_grd") { | 941 # java_strings_grd("foo_strings_grd") { |
921 # grd_file = "foo_strings.grd" | 942 # grd_file = "foo_strings.grd" |
922 # } | 943 # } |
923 template("java_strings_grd") { | 944 template("java_strings_grd") { |
924 set_sources_assignment_filter([]) | 945 set_sources_assignment_filter([]) |
925 forward_variables_from(invoker, [ "testonly" ]) | 946 forward_variables_from(invoker, [ "testonly" ]) |
926 | 947 |
927 base_path = "$target_gen_dir/$target_name" | 948 base_path = "$target_gen_dir/$target_name" |
928 resources_zip = base_path + ".resources.zip" | 949 resources_zip = base_path + ".resources.zip" |
929 build_config = base_path + ".build_config" | 950 build_config = base_path + ".build_config" |
930 | 951 |
931 write_build_config("${target_name}__build_config") { | 952 write_build_config("${target_name}__build_config") { |
932 forward_variables_from(invoker, [ "deps" ]) | |
933 type = "android_resources" | 953 type = "android_resources" |
934 } | 954 } |
935 | 955 |
936 # Put grit files into this subdirectory of target_gen_dir. | 956 # Put grit files into this subdirectory of target_gen_dir. |
937 extra_output_path = target_name + "_grit_output" | 957 extra_output_path = target_name + "_grit_output" |
938 | 958 |
939 grit_target_name = "${target_name}__grit" | 959 grit_target_name = "${target_name}__grit" |
940 grit_output_dir = "$target_gen_dir/$extra_output_path" | 960 grit_output_dir = "$target_gen_dir/$extra_output_path" |
941 grit(grit_target_name) { | 961 grit(grit_target_name) { |
| 962 forward_variables_from(invoker, [ "deps" ]) |
942 grit_flags = [ | 963 grit_flags = [ |
943 "-E", | 964 "-E", |
944 "ANDROID_JAVA_TAGGED_ONLY=false", | 965 "ANDROID_JAVA_TAGGED_ONLY=false", |
945 ] | 966 ] |
946 output_dir = grit_output_dir | 967 output_dir = grit_output_dir |
947 resource_ids = "" | 968 resource_ids = "" |
948 source = invoker.grd_file | 969 source = invoker.grd_file |
949 outputs = invoker.outputs | 970 outputs = invoker.outputs |
950 } | 971 } |
951 | 972 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 | 1013 |
993 base_path = "$target_gen_dir/$target_name" | 1014 base_path = "$target_gen_dir/$target_name" |
994 resources_zip = base_path + ".resources.zip" | 1015 resources_zip = base_path + ".resources.zip" |
995 build_config = base_path + ".build_config" | 1016 build_config = base_path + ".build_config" |
996 | 1017 |
997 build_config_target_name = "${target_name}__build_config" | 1018 build_config_target_name = "${target_name}__build_config" |
998 zip_target_name = "${target_name}__zip" | 1019 zip_target_name = "${target_name}__zip" |
999 final_target_name = target_name | 1020 final_target_name = target_name |
1000 | 1021 |
1001 write_build_config(build_config_target_name) { | 1022 write_build_config(build_config_target_name) { |
1002 visibility = [ ":$zip_target_name" ] | |
1003 type = "android_resources" | 1023 type = "android_resources" |
1004 } | 1024 } |
1005 | 1025 |
1006 zip(zip_target_name) { | 1026 zip(zip_target_name) { |
1007 visibility = [ ":$final_target_name" ] | 1027 visibility = [ ":$final_target_name" ] |
1008 | 1028 |
1009 base_dir = invoker.grit_output_dir | 1029 base_dir = invoker.grit_output_dir |
1010 inputs = rebase_path(invoker.generated_files, ".", base_dir) | 1030 inputs = rebase_path(invoker.generated_files, ".", base_dir) |
1011 output = resources_zip | 1031 output = resources_zip |
1012 deps = [ | 1032 deps = [ |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 jar_path = _jar_path | 1623 jar_path = _jar_path |
1604 dex_path = final_dex_path | 1624 dex_path = final_dex_path |
1605 apk_path = _final_apk_path | 1625 apk_path = _final_apk_path |
1606 incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk" | 1626 incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk" |
1607 incremental_install_script_path = _incremental_install_script_path | 1627 incremental_install_script_path = _incremental_install_script_path |
1608 resources_zip = resources_zip_path | 1628 resources_zip = resources_zip_path |
1609 build_config = _build_config | 1629 build_config = _build_config |
1610 android_manifest = _android_manifest | 1630 android_manifest = _android_manifest |
1611 | 1631 |
1612 deps = _android_manifest_deps | 1632 deps = _android_manifest_deps |
| 1633 |
1613 if (defined(invoker.deps)) { | 1634 if (defined(invoker.deps)) { |
1614 deps += invoker.deps | 1635 possible_config_deps = invoker.deps |
1615 } | 1636 } |
1616 | 1637 |
1617 if (defined(invoker.alternative_locale_resource_dep)) { | 1638 if (defined(invoker.alternative_locale_resource_dep)) { |
1618 deps += [ invoker.alternative_locale_resource_dep ] | 1639 possible_config_deps += [ invoker.alternative_locale_resource_dep ] |
1619 has_alternative_locale_resource = true | 1640 has_alternative_locale_resource = true |
1620 } | 1641 } |
1621 | 1642 |
1622 # Added emma to the target's classpath via its .build_config. | 1643 # Added emma to the target's classpath via its .build_config. |
1623 if (emma_coverage && !_emma_never_instrument) { | 1644 if (emma_coverage && !_emma_never_instrument) { |
1624 deps += [ "//third_party/android_tools:emma_device" ] | 1645 possible_config_deps += [ "//third_party/android_tools:emma_device" ] |
1625 } | 1646 } |
1626 | 1647 |
1627 proguard_enabled = _proguard_enabled | 1648 proguard_enabled = _proguard_enabled |
1628 if (_proguard_enabled) { | 1649 if (_proguard_enabled) { |
1629 proguard_info = "$_proguard_output_jar_path.info" | 1650 proguard_info = "$_proguard_output_jar_path.info" |
1630 } | 1651 } |
1631 | 1652 |
1632 # Don't depend on the runtime_deps target in order to avoid having to | 1653 # 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. | 1654 # 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 | 1655 # The dep is unnecessary since the runtime_deps file is created by gn gen |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 } | 2341 } |
2321 } | 2342 } |
2322 | 2343 |
2323 android_apk(target_name) { | 2344 android_apk(target_name) { |
2324 set_sources_assignment_filter([]) | 2345 set_sources_assignment_filter([]) |
2325 data_deps = [] | 2346 data_deps = [] |
2326 deps = [] | 2347 deps = [] |
2327 forward_variables_from(invoker, "*") | 2348 forward_variables_from(invoker, "*") |
2328 testonly = true | 2349 testonly = true |
2329 | 2350 |
2330 assert(!defined(invoker.proguard_enabled) || !invoker.proguard_enabled | 2351 assert(!defined(invoker.proguard_enabled) || !invoker.proguard_enabled || |
2331 || invoker.proguard_configs != []) | 2352 invoker.proguard_configs != []) |
2332 | 2353 |
2333 if (!defined(apk_name)) { | 2354 if (!defined(apk_name)) { |
2334 apk_name = get_label_info(invoker.shared_library, "name") | 2355 apk_name = get_label_info(invoker.shared_library, "name") |
2335 } | 2356 } |
2336 | 2357 |
2337 if (!defined(android_manifest)) { | 2358 if (!defined(android_manifest)) { |
2338 android_manifest_dep = ":${target_name}_manifest" | 2359 android_manifest_dep = ":${target_name}_manifest" |
2339 android_manifest = _android_manifest | 2360 android_manifest = _android_manifest |
2340 } | 2361 } |
2341 | 2362 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 android_library(target_name) { | 2511 android_library(target_name) { |
2491 chromium_code = false | 2512 chromium_code = false |
2492 java_files = [] | 2513 java_files = [] |
2493 srcjar_deps = [ ":${_template_name}__protoc_java" ] | 2514 srcjar_deps = [ ":${_template_name}__protoc_java" ] |
2494 deps = [ | 2515 deps = [ |
2495 "//third_party/android_protobuf:protobuf_nano_javalib", | 2516 "//third_party/android_protobuf:protobuf_nano_javalib", |
2496 ] | 2517 ] |
2497 } | 2518 } |
2498 } | 2519 } |
2499 } | 2520 } |
OLD | NEW |