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/zip.gni") | 6 import("//build/config/zip.gni") |
7 import("//third_party/ijar/ijar.gni") | 7 import("//third_party/ijar/ijar.gni") |
8 | 8 |
9 assert(is_android) | 9 assert(is_android) |
10 | 10 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 # deps: Specifies the dependencies of this target. | 473 # deps: Specifies the dependencies of this target. |
474 # dex_path: Path to classes.dex file to include (optional). | 474 # dex_path: Path to classes.dex file to include (optional). |
475 # resource_packaged_apk_path: Path to .ap_ to use. | 475 # resource_packaged_apk_path: Path to .ap_ to use. |
476 # output_apk_path: Output path for the generated .apk. | 476 # output_apk_path: Output path for the generated .apk. |
477 # native_libs_dir: Directory containing native libraries. | 477 # native_libs_dir: Directory containing native libraries. |
478 template("package_apk") { | 478 template("package_apk") { |
479 action(target_name) { | 479 action(target_name) { |
480 forward_variables_from(invoker, | 480 forward_variables_from(invoker, |
481 [ | 481 [ |
482 "deps", | 482 "deps", |
483 "data_deps", | |
484 "public_deps", | 483 "public_deps", |
485 "testonly", | 484 "testonly", |
486 ]) | 485 ]) |
487 script = "//build/android/gyp/ant.py" | 486 script = "//build/android/gyp/ant.py" |
488 _ant_script = "//build/android/ant/apk-package.xml" | 487 _ant_script = "//build/android/ant/apk-package.xml" |
489 | 488 |
490 depfile = "$target_gen_dir/$target_name.d" | 489 depfile = "$target_gen_dir/$target_name.d" |
490 data_deps = [ "//tools/android/md5sum" ] # Used when deploying APKs | |
491 | 491 |
492 inputs = [ | 492 inputs = [ |
493 invoker.resource_packaged_apk_path, | 493 invoker.resource_packaged_apk_path, |
494 _ant_script, | 494 _ant_script, |
495 ] | 495 ] |
496 if (defined(invoker.dex_path)) { | 496 if (defined(invoker.dex_path)) { |
497 inputs += [ invoker.dex_path ] | 497 inputs += [ invoker.dex_path ] |
498 } | 498 } |
499 | 499 |
500 outputs = [ | 500 outputs = [ |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 _base_path = invoker.base_path | 609 _base_path = invoker.base_path |
610 _final_apk_path = invoker.apk_path | 610 _final_apk_path = invoker.apk_path |
611 _incremental_final_apk_path_helper = | 611 _incremental_final_apk_path_helper = |
612 process_file_template( | 612 process_file_template( |
613 [ _final_apk_path ], | 613 [ _final_apk_path ], |
614 "{{source_dir}}/{{source_name_part}}_incremental.apk") | 614 "{{source_dir}}/{{source_name_part}}_incremental.apk") |
615 _incremental_final_apk_path = _incremental_final_apk_path_helper[0] | 615 _incremental_final_apk_path = _incremental_final_apk_path_helper[0] |
616 | 616 |
617 if (defined(invoker.resources_zip)) { | 617 if (defined(invoker.resources_zip)) { |
618 _resources_zip = invoker.resources_zip | 618 _resources_zip = invoker.resources_zip |
619 assert(_resources_zip != "") # Mark as used. | |
619 } | 620 } |
620 if (defined(invoker.dex_path)) { | 621 if (defined(invoker.dex_path)) { |
621 _dex_path = invoker.dex_path | 622 _dex_path = invoker.dex_path |
622 } | 623 } |
623 _load_library_from_apk = invoker.load_library_from_apk | 624 _load_library_from_apk = invoker.load_library_from_apk |
624 | 625 |
625 _package_deps = [] | 626 _deps = [] |
626 if (defined(invoker.deps)) { | 627 if (defined(invoker.deps)) { |
627 _package_deps = invoker.deps | 628 _deps = invoker.deps |
628 } | 629 } |
629 | 630 |
630 _native_libs_dir = "//build/android/empty/res" | 631 _native_libs_dir = "//build/android/empty/res" |
631 if (defined(invoker.native_libs_dir)) { | 632 if (defined(invoker.native_libs_dir)) { |
632 _native_libs_dir = invoker.native_libs_dir | 633 _native_libs_dir = invoker.native_libs_dir |
633 } | 634 } |
634 | 635 |
635 if (defined(invoker.asset_location)) { | 636 if (defined(invoker.asset_location)) { |
636 _asset_location = invoker.asset_location | 637 _asset_location = invoker.asset_location |
638 assert(_asset_location != "") # Mark as used. | |
637 } | 639 } |
638 | 640 |
639 _version_code = invoker.version_code | 641 _version_code = invoker.version_code |
640 _version_name = invoker.version_name | 642 _version_name = invoker.version_name |
643 assert(_version_code != -1) # Mark as used. | |
644 assert(_version_name != "") # Mark as used. | |
641 | 645 |
642 _base_apk_path = _base_path + ".apk_intermediates" | 646 _base_apk_path = _base_path + ".apk_intermediates" |
643 | 647 |
644 _resource_packaged_apk_path = _base_apk_path + ".ap_" | 648 _resource_packaged_apk_path = _base_apk_path + ".ap_" |
649 _incremental_resource_packaged_apk_path = _base_apk_path + "_incremental.ap_" | |
645 _packaged_apk_path = _base_apk_path + ".unfinished.apk" | 650 _packaged_apk_path = _base_apk_path + ".unfinished.apk" |
646 _incremental_packaged_apk_path = | 651 _incremental_packaged_apk_path = |
647 _base_apk_path + "_incremental.unfinished.apk" | 652 _base_apk_path + "_incremental.unfinished.apk" |
648 _shared_resources = | 653 _shared_resources = |
649 defined(invoker.shared_resources) && invoker.shared_resources | 654 defined(invoker.shared_resources) && invoker.shared_resources |
655 assert(_shared_resources || true) # Mark as used. | |
650 | 656 |
651 _keystore_path = invoker.keystore_path | 657 _keystore_path = invoker.keystore_path |
652 _keystore_name = invoker.keystore_name | 658 _keystore_name = invoker.keystore_name |
653 _keystore_password = invoker.keystore_password | 659 _keystore_password = invoker.keystore_password |
654 | 660 |
655 _split_densities = [] | 661 _split_densities = [] |
656 if (defined(invoker.create_density_splits) && invoker.create_density_splits) { | 662 if (defined(invoker.create_density_splits) && invoker.create_density_splits) { |
657 _split_densities = [ | 663 _split_densities = [ |
658 "hdpi", | 664 "hdpi", |
659 "xhdpi", | 665 "xhdpi", |
660 "xxhdpi", | 666 "xxhdpi", |
661 "xxxhdpi", | 667 "xxxhdpi", |
662 "tvdpi", | 668 "tvdpi", |
663 ] | 669 ] |
664 } | 670 } |
665 | 671 |
666 _split_languages = [] | 672 _split_languages = [] |
667 if (defined(invoker.language_splits)) { | 673 if (defined(invoker.language_splits)) { |
668 _split_languages = invoker.language_splits | 674 _split_languages = invoker.language_splits |
669 } | 675 } |
670 | 676 |
677 template("package_resources_helper") { | |
678 action(target_name) { | |
679 deps = invoker.deps | |
jbudorick
2015/09/16 15:38:00
forward_variables_from?
agrieve
2015/09/16 15:50:47
In this case I want it to be an error if deps isn'
| |
680 | |
681 script = "//build/android/gyp/package_resources.py" | |
682 depfile = "${target_gen_dir}/${target_name}.d" | |
683 inputs = [ | |
684 invoker.android_manifest, | |
685 ] | |
686 if (defined(_resources_zip)) { | |
687 inputs += [ _resources_zip ] | |
688 } | |
689 outputs = [ | |
690 depfile, | |
691 invoker.resource_packaged_apk_path, | |
692 ] | |
693 | |
694 args = [ | |
695 "--depfile", | |
696 rebase_path(depfile, root_build_dir), | |
697 "--android-sdk", | |
698 rebased_android_sdk, | |
699 "--aapt-path", | |
700 android_aapt_path, | |
701 "--configuration-name=$android_configuration_name", | |
702 "--android-manifest", | |
703 rebase_path(invoker.android_manifest, root_build_dir), | |
704 "--version-code", | |
705 _version_code, | |
706 "--version-name", | |
707 _version_name, | |
708 "--apk-path", | |
709 rebase_path(invoker.resource_packaged_apk_path, root_build_dir), | |
710 ] | |
711 | |
712 if (defined(_asset_location)) { | |
713 args += [ | |
714 "--asset-dir", | |
715 rebase_path(_asset_location, root_build_dir), | |
716 ] | |
717 } | |
718 if (defined(_resources_zip)) { | |
719 args += [ | |
720 "--resource-zips", | |
721 rebase_path(_resources_zip, root_build_dir), | |
722 ] | |
723 } | |
724 if (_shared_resources) { | |
725 args += [ "--shared-resources" ] | |
726 } | |
727 if (_split_densities != []) { | |
728 args += [ "--create-density-splits" ] | |
729 foreach(_density, _split_densities) { | |
730 outputs += [ "${invoker.resource_packaged_apk_path}_${_density}" ] | |
731 } | |
732 } | |
733 if (_split_languages != []) { | |
734 args += [ "--language-splits=$_split_languages" ] | |
735 foreach(_language, _split_languages) { | |
736 outputs += [ "${invoker.resource_packaged_apk_path}_${_language}" ] | |
737 } | |
738 } | |
739 if (defined(invoker.extensions_to_not_compress)) { | |
740 args += [ | |
741 "--no-compress", | |
742 invoker.extensions_to_not_compress, | |
743 ] | |
744 } | |
745 } | |
746 } | |
747 | |
671 _package_resources_target_name = "${target_name}__package_resources" | 748 _package_resources_target_name = "${target_name}__package_resources" |
672 action(_package_resources_target_name) { | 749 package_resources_helper(_package_resources_target_name) { |
673 deps = _package_deps | 750 forward_variables_from(invoker, [ "extensions_to_not_compress" ]) |
751 deps = _deps | |
752 android_manifest = _android_manifest | |
753 resource_packaged_apk_path = _resource_packaged_apk_path | |
754 } | |
674 | 755 |
675 script = "//build/android/gyp/package_resources.py" | 756 _generate_incremental_manifest_target_name = |
757 "${target_name}_incremental_generate_manifest" | |
758 _incremental_android_manifest = | |
759 get_label_info(_generate_incremental_manifest_target_name, | |
760 "target_gen_dir") + "/AndroidManifest.xml" | |
761 action(_generate_incremental_manifest_target_name) { | |
762 deps = _deps | |
763 script = "//build/android/incremental_install/generate_android_manifest.py" | |
676 depfile = "${target_gen_dir}/${target_name}.d" | 764 depfile = "${target_gen_dir}/${target_name}.d" |
677 inputs = [ | 765 inputs = [ |
678 _android_manifest, | 766 _android_manifest, |
679 ] | 767 ] |
680 if (defined(_resources_zip)) { | |
681 inputs += [ _resources_zip ] | |
682 } | |
683 outputs = [ | 768 outputs = [ |
684 depfile, | 769 depfile, |
685 _resource_packaged_apk_path, | 770 _incremental_android_manifest, |
686 ] | 771 ] |
687 | 772 |
773 _rebased_src_manifest = rebase_path(_android_manifest, root_build_dir) | |
774 _rebased_incremental_manifest = | |
775 rebase_path(_incremental_android_manifest, root_build_dir) | |
688 args = [ | 776 args = [ |
689 "--depfile", | 777 "--src-manifest=$_rebased_src_manifest", |
690 rebase_path(depfile, root_build_dir), | 778 "--out-manifest=$_rebased_incremental_manifest", |
691 "--android-sdk", | |
692 rebased_android_sdk, | |
693 "--aapt-path", | |
694 android_aapt_path, | |
695 "--configuration-name=$android_configuration_name", | |
696 "--android-manifest", | |
697 rebase_path(_android_manifest, root_build_dir), | |
698 "--version-code", | |
699 _version_code, | |
700 "--version-name", | |
701 _version_name, | |
702 "--apk-path", | |
703 rebase_path(_resource_packaged_apk_path, root_build_dir), | |
704 ] | 779 ] |
780 if (disable_incremental_isolated_processes) { | |
781 args += [ "--disable-isolated-processes" ] | |
782 } | |
783 } | |
705 | 784 |
706 if (defined(_asset_location)) { | 785 _incremental_package_resources_target_name = |
707 args += [ | 786 "${target_name}_incremental__package_resources" |
708 "--asset-dir", | 787 |
709 rebase_path(_asset_location, root_build_dir), | 788 # TODO(agrieve): See if we can speed up this step by swapping the manifest |
710 ] | 789 # from the result of the main package_resources step. |
711 } | 790 package_resources_helper(_incremental_package_resources_target_name) { |
712 if (defined(_resources_zip)) { | 791 forward_variables_from(invoker, [ "extensions_to_not_compress" ]) |
713 args += [ | 792 deps = _deps + [ ":$_generate_incremental_manifest_target_name" ] |
714 "--resource-zips", | 793 android_manifest = _incremental_android_manifest |
715 rebase_path(_resources_zip, root_build_dir), | 794 resource_packaged_apk_path = _incremental_resource_packaged_apk_path |
716 ] | |
717 } | |
718 if (_shared_resources) { | |
719 args += [ "--shared-resources" ] | |
720 } | |
721 if (_split_densities != []) { | |
722 args += [ "--create-density-splits" ] | |
723 foreach(_density, _split_densities) { | |
724 outputs += [ "${_resource_packaged_apk_path}_${_density}" ] | |
725 } | |
726 } | |
727 if (_split_languages != []) { | |
728 args += [ "--language-splits=$_split_languages" ] | |
729 foreach(_language, _split_languages) { | |
730 outputs += [ "${_resource_packaged_apk_path}_${_language}" ] | |
731 } | |
732 } | |
733 if (defined(invoker.extensions_to_not_compress)) { | |
734 args += [ | |
735 "--no-compress", | |
736 invoker.extensions_to_not_compress, | |
737 ] | |
738 } | |
739 } | 795 } |
740 | 796 |
741 package_target = "${target_name}__package" | 797 package_target = "${target_name}__package" |
742 package_apk(package_target) { | 798 package_apk(package_target) { |
743 deps = [] | 799 deps = _deps + [ ":${_package_resources_target_name}" ] |
744 forward_variables_from(invoker, [ "deps" ]) | |
745 deps += [ ":${_package_resources_target_name}" ] | |
746 | |
747 data_deps = [ "//tools/android/md5sum" ] # Used when deploying APKs | |
748 | 800 |
749 if (defined(_dex_path)) { | 801 if (defined(_dex_path)) { |
750 dex_path = _dex_path | 802 dex_path = _dex_path |
751 } | 803 } |
752 native_libs_dir = _native_libs_dir | 804 native_libs_dir = _native_libs_dir |
753 output_apk_path = _packaged_apk_path | 805 output_apk_path = _packaged_apk_path |
754 resource_packaged_apk_path = _resource_packaged_apk_path | 806 resource_packaged_apk_path = _resource_packaged_apk_path |
755 } | 807 } |
756 | 808 |
757 _incremental_package_target = "${target_name}_incremental__package" | 809 _incremental_package_target = "${target_name}_incremental__package" |
758 package_apk(_incremental_package_target) { | 810 package_apk(_incremental_package_target) { |
759 deps = [] | 811 _dex_target = "//build/android/incremental_install:bootstrap_java__dex" |
760 forward_variables_from(invoker, [ "deps" ]) | 812 deps = _deps + [ |
761 deps += [ ":${_package_resources_target_name}" ] | 813 ":${_incremental_package_resources_target_name}", |
814 _dex_target, | |
815 ] | |
762 | 816 |
763 # TODO(agrieve): Multidex | |
764 if (defined(_dex_path)) { | 817 if (defined(_dex_path)) { |
765 dex_path = _dex_path | 818 dex_path = |
819 get_label_info(_dex_target, "target_gen_dir") + "/bootstrap.dex" | |
766 } | 820 } |
767 | 821 |
768 # TODO(agrieve): Add a placeholder .so for http://crbug.com/384638 | 822 # TODO(agrieve): Add a placeholder .so for http://crbug.com/384638 |
769 native_libs_dir = "//build/android/empty/res" | 823 native_libs_dir = "//build/android/empty/res" |
770 output_apk_path = _incremental_packaged_apk_path | 824 output_apk_path = _incremental_packaged_apk_path |
771 resource_packaged_apk_path = _resource_packaged_apk_path | 825 resource_packaged_apk_path = _incremental_resource_packaged_apk_path |
772 } | 826 } |
773 | 827 |
774 _finalize_apk_rule_name = "${target_name}__finalize" | 828 _finalize_apk_rule_name = "${target_name}__finalize" |
775 finalize_apk(_finalize_apk_rule_name) { | 829 finalize_apk(_finalize_apk_rule_name) { |
776 input_apk_path = _packaged_apk_path | 830 input_apk_path = _packaged_apk_path |
777 output_apk_path = _final_apk_path | 831 output_apk_path = _final_apk_path |
778 keystore_path = _keystore_path | 832 keystore_path = _keystore_path |
779 keystore_name = _keystore_name | 833 keystore_name = _keystore_name |
780 keystore_password = _keystore_password | 834 keystore_password = _keystore_password |
781 rezip_apk = _load_library_from_apk | 835 rezip_apk = _load_library_from_apk |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1589 ] | 1643 ] |
1590 args = [ | 1644 args = [ |
1591 "--depfile", | 1645 "--depfile", |
1592 rebase_path(depfile, root_build_dir), | 1646 rebase_path(depfile, root_build_dir), |
1593 "--script-output-path", | 1647 "--script-output-path", |
1594 rebase_path(generated_script, root_build_dir), | 1648 rebase_path(generated_script, root_build_dir), |
1595 ] | 1649 ] |
1596 args += test_runner_args | 1650 args += test_runner_args |
1597 } | 1651 } |
1598 } | 1652 } |
OLD | NEW |