| 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 # Do not add any imports to non-//build directories here. | 5 # Do not add any imports to non-//build directories here. |
| 6 # Some projects (e.g. V8) do not have non-build directories DEPS'ed in. | 6 # Some projects (e.g. V8) do not have non-build directories DEPS'ed in. |
| 7 import("//build/config/android/config.gni") | 7 import("//build/config/android/config.gni") |
| 8 import("//build/config/android/internal_rules.gni") | 8 import("//build/config/android/internal_rules.gni") |
| 9 import("//build/config/compiler/compiler.gni") | 9 import("//build/config/compiler/compiler.gni") |
| 10 import("//build/config/dcheck_always_on.gni") | 10 import("//build/config/dcheck_always_on.gni") |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 # android_manifest: AndroidManifest.xml for this target. Defaults to | 639 # android_manifest: AndroidManifest.xml for this target. Defaults to |
| 640 # //build/android/AndroidManifest.xml. | 640 # //build/android/AndroidManifest.xml. |
| 641 # android_manifest_dep: Target that generates AndroidManifest (if applicable
) | 641 # android_manifest_dep: Target that generates AndroidManifest (if applicable
) |
| 642 # custom_package: java package for generated .java files. | 642 # custom_package: java package for generated .java files. |
| 643 # v14_skip: If true, don't run v14 resource generator on this. Defaults to | 643 # v14_skip: If true, don't run v14 resource generator on this. Defaults to |
| 644 # false. (see build/android/gyp/generate_v14_compatible_resources.py) | 644 # false. (see build/android/gyp/generate_v14_compatible_resources.py) |
| 645 # shared_resources: If true make a resource package that can be loaded by a | 645 # shared_resources: If true make a resource package that can be loaded by a |
| 646 # different application at runtime to access the package's resources. | 646 # different application at runtime to access the package's resources. |
| 647 # app_as_shared_lib: If true make a resource package that can be loaded as | 647 # app_as_shared_lib: If true make a resource package that can be loaded as |
| 648 # both shared_resources and normal application. | 648 # both shared_resources and normal application. |
| 649 # r_text_file: (optional) path to pre-generated R.txt to be used when |
| 650 # generating R.java instead of resource-based aapt-generated one. |
| 649 | 651 |
| 650 # Example: | 652 # Example: |
| 651 # android_resources("foo_resources") { | 653 # android_resources("foo_resources") { |
| 652 # deps = [":foo_strings_grd"] | 654 # deps = [":foo_strings_grd"] |
| 653 # resource_dirs = ["res"] | 655 # resource_dirs = ["res"] |
| 654 # custom_package = "org.chromium.foo" | 656 # custom_package = "org.chromium.foo" |
| 655 # } | 657 # } |
| 656 # | 658 # |
| 657 # android_resources("foo_resources_overrides") { | 659 # android_resources("foo_resources_overrides") { |
| 658 # deps = [":foo_resources"] | 660 # deps = [":foo_resources"] |
| 659 # resource_dirs = ["res_overrides"] | 661 # resource_dirs = ["res_overrides"] |
| 660 # } | 662 # } |
| 661 template("android_resources") { | 663 template("android_resources") { |
| 662 set_sources_assignment_filter([]) | 664 set_sources_assignment_filter([]) |
| 663 forward_variables_from(invoker, [ "testonly" ]) | 665 forward_variables_from(invoker, [ "testonly" ]) |
| 664 | 666 |
| 665 assert(defined(invoker.resource_dirs)) | 667 assert(defined(invoker.resource_dirs)) |
| 666 | 668 |
| 667 base_path = "$target_gen_dir/$target_name" | 669 base_path = "$target_gen_dir/$target_name" |
| 668 zip_path = base_path + ".resources.zip" | 670 zip_path = base_path + ".resources.zip" |
| 669 srcjar_path = base_path + ".srcjar" | 671 srcjar_path = base_path + ".srcjar" |
| 670 r_text_path = base_path + "_R.txt" | 672 r_text_out_path = base_path + "_R.txt" |
| 671 build_config = base_path + ".build_config" | 673 build_config = base_path + ".build_config" |
| 672 | 674 |
| 673 build_config_target_name = "${target_name}__build_config" | 675 build_config_target_name = "${target_name}__build_config" |
| 674 process_resources_target_name = "${target_name}__process_resources" | 676 process_resources_target_name = "${target_name}__process_resources" |
| 675 final_target_name = target_name | 677 final_target_name = target_name |
| 676 | 678 |
| 677 write_build_config(build_config_target_name) { | 679 write_build_config(build_config_target_name) { |
| 678 type = "android_resources" | 680 type = "android_resources" |
| 679 forward_variables_from(invoker, | 681 forward_variables_from(invoker, |
| 680 [ | 682 [ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 693 possible_config_deps = invoker.deps | 695 possible_config_deps = invoker.deps |
| 694 } | 696 } |
| 695 if (defined(invoker.android_manifest_dep)) { | 697 if (defined(invoker.android_manifest_dep)) { |
| 696 deps = [ | 698 deps = [ |
| 697 invoker.android_manifest_dep, | 699 invoker.android_manifest_dep, |
| 698 ] | 700 ] |
| 699 } | 701 } |
| 700 | 702 |
| 701 # No package means resources override their deps. | 703 # No package means resources override their deps. |
| 702 if (defined(custom_package) || defined(android_manifest)) { | 704 if (defined(custom_package) || defined(android_manifest)) { |
| 703 r_text = r_text_path | 705 r_text = r_text_out_path |
| 704 } else { | 706 } else { |
| 705 assert(defined(invoker.deps), | 707 assert(defined(invoker.deps), |
| 706 "Must specify deps when custom_package is omitted.") | 708 "Must specify deps when custom_package is omitted.") |
| 707 } | 709 } |
| 708 | 710 |
| 709 resources_zip = zip_path | 711 resources_zip = zip_path |
| 710 srcjar = srcjar_path | 712 srcjar = srcjar_path |
| 711 } | 713 } |
| 712 | 714 |
| 713 process_resources(process_resources_target_name) { | 715 process_resources(process_resources_target_name) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 724 "v14_skip", | 726 "v14_skip", |
| 725 ]) | 727 ]) |
| 726 if (!defined(deps)) { | 728 if (!defined(deps)) { |
| 727 deps = [] | 729 deps = [] |
| 728 } | 730 } |
| 729 deps += [ ":$build_config_target_name" ] | 731 deps += [ ":$build_config_target_name" ] |
| 730 if (defined(invoker.android_manifest_dep)) { | 732 if (defined(invoker.android_manifest_dep)) { |
| 731 deps += [ invoker.android_manifest_dep ] | 733 deps += [ invoker.android_manifest_dep ] |
| 732 } | 734 } |
| 733 | 735 |
| 736 if (defined(invoker.r_text_file)) { |
| 737 r_text_in_path = invoker.r_text_file |
| 738 } |
| 739 |
| 734 # Always generate R.onResourcesLoaded() method, it is required for | 740 # Always generate R.onResourcesLoaded() method, it is required for |
| 735 # compiling ResourceRewriter, there is no side effect because the | 741 # compiling ResourceRewriter, there is no side effect because the |
| 736 # generated R.class isn't used in final apk. | 742 # generated R.class isn't used in final apk. |
| 737 shared_resources = true | 743 shared_resources = true |
| 738 if (!defined(android_manifest)) { | 744 if (!defined(android_manifest)) { |
| 739 android_manifest = "//build/android/AndroidManifest.xml" | 745 android_manifest = "//build/android/AndroidManifest.xml" |
| 740 } | 746 } |
| 741 } | 747 } |
| 742 | 748 |
| 743 group(final_target_name) { | 749 group(final_target_name) { |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 process_resources(process_resources_target) { | 1666 process_resources(process_resources_target) { |
| 1661 forward_variables_from(invoker, | 1667 forward_variables_from(invoker, |
| 1662 [ | 1668 [ |
| 1663 "alternative_android_sdk_jar", | 1669 "alternative_android_sdk_jar", |
| 1664 "android_aapt_path", | 1670 "android_aapt_path", |
| 1665 "app_as_shared_lib", | 1671 "app_as_shared_lib", |
| 1666 "include_all_resources", | 1672 "include_all_resources", |
| 1667 "shared_resources", | 1673 "shared_resources", |
| 1668 ]) | 1674 ]) |
| 1669 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" | 1675 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" |
| 1670 r_text_path = "${target_gen_dir}/${target_name}_R.txt" | 1676 r_text_out_path = "${target_gen_dir}/${target_name}_R.txt" |
| 1671 android_manifest = _android_manifest | 1677 android_manifest = _android_manifest |
| 1672 resource_dirs = [ "//build/android/ant/empty/res" ] | 1678 resource_dirs = [ "//build/android/ant/empty/res" ] |
| 1673 zip_path = resources_zip_path | 1679 zip_path = resources_zip_path |
| 1674 all_resources_zip_path = _all_resources_zip_path | 1680 all_resources_zip_path = _all_resources_zip_path |
| 1675 generate_constant_ids = true | 1681 generate_constant_ids = true |
| 1676 proguard_file = _generated_proguard_config | 1682 proguard_file = _generated_proguard_config |
| 1677 | 1683 |
| 1678 build_config = _build_config | 1684 build_config = _build_config |
| 1679 deps = _android_manifest_deps + [ ":$build_config_target" ] | 1685 deps = _android_manifest_deps + [ ":$build_config_target" ] |
| 1680 if (defined(invoker.deps)) { | 1686 if (defined(invoker.deps)) { |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2671 rebase_path(_output_path, root_build_dir), | 2677 rebase_path(_output_path, root_build_dir), |
| 2672 "--extract", | 2678 "--extract", |
| 2673 ] | 2679 ] |
| 2674 inputs = [ | 2680 inputs = [ |
| 2675 invoker.aar_path, | 2681 invoker.aar_path, |
| 2676 ] | 2682 ] |
| 2677 outputs = [ | 2683 outputs = [ |
| 2678 "${_output_path}/AndroidManifest.xml", | 2684 "${_output_path}/AndroidManifest.xml", |
| 2679 ] | 2685 ] |
| 2680 | 2686 |
| 2687 if (_scanned_files.has_r_text_file) { |
| 2688 # Certain packages, in particular Play Services have no R.txt even |
| 2689 # though its presence is mandated by AAR spec. Such packages cause |
| 2690 # spurious rebuilds if this output is specified unconditionally. |
| 2691 outputs += [ "${_output_path}/R.txt" ] |
| 2692 } |
| 2693 |
| 2681 if (_scanned_files.resources != []) { | 2694 if (_scanned_files.resources != []) { |
| 2682 outputs += [ "${_output_path}/R.txt" ] | |
| 2683 outputs += get_path_info( | 2695 outputs += get_path_info( |
| 2684 rebase_path(_scanned_files.resources, "", _output_path), | 2696 rebase_path(_scanned_files.resources, "", _output_path), |
| 2685 "abspath") | 2697 "abspath") |
| 2686 } | 2698 } |
| 2687 if (_scanned_files.has_classes_jar) { | 2699 if (_scanned_files.has_classes_jar) { |
| 2688 outputs += [ "${_output_path}/classes.jar" ] | 2700 outputs += [ "${_output_path}/classes.jar" ] |
| 2689 } | 2701 } |
| 2690 outputs += | 2702 outputs += |
| 2691 get_path_info(rebase_path(_scanned_files.subjars, "", _output_path), | 2703 get_path_info(rebase_path(_scanned_files.subjars, "", _output_path), |
| 2692 "abspath") | 2704 "abspath") |
| 2693 if (_scanned_files.has_proguard_flags) { | 2705 if (_scanned_files.has_proguard_flags) { |
| 2694 outputs += [ "${_output_path}/proguard.txt" ] | 2706 outputs += [ "${_output_path}/proguard.txt" ] |
| 2695 } | 2707 } |
| 2696 } | 2708 } |
| 2697 | 2709 |
| 2698 # Create the android_resources target for resources. | 2710 # Create the android_resources target for resources. |
| 2699 if (_scanned_files.resources != []) { | 2711 if (_scanned_files.resources != [] || _scanned_files.has_r_text_file) { |
| 2700 _res_target_name = "${target_name}__res" | 2712 _res_target_name = "${target_name}__res" |
| 2701 android_resources(_res_target_name) { | 2713 android_resources(_res_target_name) { |
| 2702 forward_variables_from(invoker, [ "deps" ]) | 2714 forward_variables_from(invoker, [ "deps" ]) |
| 2703 if (!defined(deps)) { | 2715 if (!defined(deps)) { |
| 2704 deps = [] | 2716 deps = [] |
| 2705 } | 2717 } |
| 2706 deps += [ ":$_unpack_target_name" ] | 2718 deps += [ ":$_unpack_target_name" ] |
| 2707 resource_dirs = [] | 2719 resource_dirs = [] |
| 2708 generated_resource_dirs = [ "${_output_path}/res" ] | 2720 generated_resource_dirs = [ "${_output_path}/res" ] |
| 2709 generated_resource_files = | 2721 generated_resource_files = |
| 2710 rebase_path(_scanned_files.resources, "", _output_path) | 2722 rebase_path(_scanned_files.resources, "", _output_path) |
| 2711 android_manifest_dep = ":$_unpack_target_name" | 2723 android_manifest_dep = ":$_unpack_target_name" |
| 2712 android_manifest = "${_output_path}/AndroidManifest.xml" | 2724 android_manifest = "${_output_path}/AndroidManifest.xml" |
| 2725 if (_scanned_files.has_r_text_file) { |
| 2726 r_text_file = "${_output_path}/R.txt" |
| 2727 } |
| 2713 v14_skip = true | 2728 v14_skip = true |
| 2714 } | 2729 } |
| 2715 } | 2730 } |
| 2716 | 2731 |
| 2717 # Create android_java_prebuilt target for extra jars within jars/. | 2732 # Create android_java_prebuilt target for extra jars within jars/. |
| 2718 _subjar_targets = [] | 2733 _subjar_targets = [] |
| 2719 foreach(_tuple, _scanned_files.subjar_tuples) { | 2734 foreach(_tuple, _scanned_files.subjar_tuples) { |
| 2720 _current_target = "${target_name}__subjar_${_tuple[0]}" | 2735 _current_target = "${target_name}__subjar_${_tuple[0]}" |
| 2721 _subjar_targets += [ ":$_current_target" ] | 2736 _subjar_targets += [ ":$_current_target" ] |
| 2722 java_prebuilt(_current_target) { | 2737 java_prebuilt(_current_target) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2782 # because in practice they seem to contain classes required to be in the | 2797 # because in practice they seem to contain classes required to be in the |
| 2783 # classpath. | 2798 # classpath. |
| 2784 deps += _subjar_targets | 2799 deps += _subjar_targets |
| 2785 } | 2800 } |
| 2786 if (defined(_res_target_name)) { | 2801 if (defined(_res_target_name)) { |
| 2787 deps += [ ":$_res_target_name" ] | 2802 deps += [ ":$_res_target_name" ] |
| 2788 } | 2803 } |
| 2789 } | 2804 } |
| 2790 } | 2805 } |
| 2791 } | 2806 } |
| OLD | NEW |