Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: build/config/android/internal_rules.gni

Issue 1338813003: GN: Side-load dex files as well as native code in incremental installs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Python review comments 1 Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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("//third_party/ijar/ijar.gni") 6 import("//third_party/ijar/ijar.gni")
7 7
8 assert(is_android) 8 assert(is_android)
9 9
10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) 10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 # deps: Specifies the dependencies of this target. 512 # deps: Specifies the dependencies of this target.
513 # dex_path: Path to classes.dex file to include (optional). 513 # dex_path: Path to classes.dex file to include (optional).
514 # resource_packaged_apk_path: Path to .ap_ to use. 514 # resource_packaged_apk_path: Path to .ap_ to use.
515 # output_apk_path: Output path for the generated .apk. 515 # output_apk_path: Output path for the generated .apk.
516 # native_libs_dir: Directory containing native libraries. 516 # native_libs_dir: Directory containing native libraries.
517 template("package_apk") { 517 template("package_apk") {
518 action(target_name) { 518 action(target_name) {
519 forward_variables_from(invoker, 519 forward_variables_from(invoker,
520 [ 520 [
521 "deps", 521 "deps",
522 "data_deps",
523 "public_deps", 522 "public_deps",
524 "testonly", 523 "testonly",
525 ]) 524 ])
526 script = "//build/android/gyp/ant.py" 525 script = "//build/android/gyp/ant.py"
527 _ant_script = "//build/android/ant/apk-package.xml" 526 _ant_script = "//build/android/ant/apk-package.xml"
528 527
529 depfile = "$target_gen_dir/$target_name.d" 528 depfile = "$target_gen_dir/$target_name.d"
529 data_deps = [ "//tools/android/md5sum" ] # Used when deploying APKs
530 530
531 inputs = [ 531 inputs = [
532 invoker.resource_packaged_apk_path, 532 invoker.resource_packaged_apk_path,
533 _ant_script, 533 _ant_script,
534 ] 534 ]
535 if (defined(invoker.dex_path)) { 535 if (defined(invoker.dex_path)) {
536 inputs += [ invoker.dex_path ] 536 inputs += [ invoker.dex_path ]
537 } 537 }
538 538
539 outputs = [ 539 outputs = [
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 _base_path = invoker.base_path 648 _base_path = invoker.base_path
649 _final_apk_path = invoker.apk_path 649 _final_apk_path = invoker.apk_path
650 _incremental_final_apk_path_helper = 650 _incremental_final_apk_path_helper =
651 process_file_template( 651 process_file_template(
652 [ _final_apk_path ], 652 [ _final_apk_path ],
653 "{{source_dir}}/{{source_name_part}}_incremental.apk") 653 "{{source_dir}}/{{source_name_part}}_incremental.apk")
654 _incremental_final_apk_path = _incremental_final_apk_path_helper[0] 654 _incremental_final_apk_path = _incremental_final_apk_path_helper[0]
655 655
656 if (defined(invoker.resources_zip)) { 656 if (defined(invoker.resources_zip)) {
657 _resources_zip = invoker.resources_zip 657 _resources_zip = invoker.resources_zip
658 assert(_resources_zip != "") # Mark as used.
658 } 659 }
659 if (defined(invoker.dex_path)) { 660 if (defined(invoker.dex_path)) {
660 _dex_path = invoker.dex_path 661 _dex_path = invoker.dex_path
661 } 662 }
662 _load_library_from_apk = invoker.load_library_from_apk 663 _load_library_from_apk = invoker.load_library_from_apk
663 664
664 _package_deps = [] 665 _deps = []
665 if (defined(invoker.deps)) { 666 if (defined(invoker.deps)) {
666 _package_deps = invoker.deps 667 _deps = invoker.deps
667 } 668 }
668 669
669 _native_libs_dir = "//build/android/empty/res" 670 _native_libs_dir = "//build/android/empty/res"
670 if (defined(invoker.native_libs_dir)) { 671 if (defined(invoker.native_libs_dir)) {
671 _native_libs_dir = invoker.native_libs_dir 672 _native_libs_dir = invoker.native_libs_dir
672 } 673 }
673 674
674 if (defined(invoker.asset_location)) { 675 if (defined(invoker.asset_location)) {
675 _asset_location = invoker.asset_location 676 _asset_location = invoker.asset_location
677 assert(_asset_location != "") # Mark as used.
676 } 678 }
677 679
678 _version_code = invoker.version_code 680 _version_code = invoker.version_code
679 _version_name = invoker.version_name 681 _version_name = invoker.version_name
682 assert(_version_code != -1) # Mark as used.
683 assert(_version_name != "") # Mark as used.
680 684
681 _base_apk_path = _base_path + ".apk_intermediates" 685 _base_apk_path = _base_path + ".apk_intermediates"
682 686
683 _resource_packaged_apk_path = _base_apk_path + ".ap_" 687 _resource_packaged_apk_path = _base_apk_path + ".ap_"
688 _incremental_resource_packaged_apk_path = _base_apk_path + "_incremental.ap_"
684 _packaged_apk_path = _base_apk_path + ".unfinished.apk" 689 _packaged_apk_path = _base_apk_path + ".unfinished.apk"
685 _incremental_packaged_apk_path = 690 _incremental_packaged_apk_path =
686 _base_apk_path + "_incremental.unfinished.apk" 691 _base_apk_path + "_incremental.unfinished.apk"
687 _shared_resources = 692 _shared_resources =
688 defined(invoker.shared_resources) && invoker.shared_resources 693 defined(invoker.shared_resources) && invoker.shared_resources
694 assert(_shared_resources || true) # Mark as used.
689 695
690 _keystore_path = invoker.keystore_path 696 _keystore_path = invoker.keystore_path
691 _keystore_name = invoker.keystore_name 697 _keystore_name = invoker.keystore_name
692 _keystore_password = invoker.keystore_password 698 _keystore_password = invoker.keystore_password
693 699
694 _split_densities = [] 700 _split_densities = []
695 if (defined(invoker.create_density_splits) && invoker.create_density_splits) { 701 if (defined(invoker.create_density_splits) && invoker.create_density_splits) {
696 _split_densities = [ 702 _split_densities = [
697 "hdpi", 703 "hdpi",
698 "xhdpi", 704 "xhdpi",
699 "xxhdpi", 705 "xxhdpi",
700 "xxxhdpi", 706 "xxxhdpi",
701 "tvdpi", 707 "tvdpi",
702 ] 708 ]
703 } 709 }
704 710
705 _split_languages = [] 711 _split_languages = []
706 if (defined(invoker.language_splits)) { 712 if (defined(invoker.language_splits)) {
707 _split_languages = invoker.language_splits 713 _split_languages = invoker.language_splits
708 } 714 }
709 715
716 template("package_resources_helper") {
717 action(target_name) {
718 deps = invoker.deps
719
720 script = "//build/android/gyp/package_resources.py"
721 depfile = "${target_gen_dir}/${target_name}.d"
722 inputs = [
723 invoker.android_manifest,
724 ]
725 if (defined(_resources_zip)) {
726 inputs += [ _resources_zip ]
727 }
728 outputs = [
729 depfile,
730 invoker.resource_packaged_apk_path,
731 ]
732
733 args = [
734 "--depfile",
735 rebase_path(depfile, root_build_dir),
736 "--android-sdk",
737 rebased_android_sdk,
738 "--aapt-path",
739 android_aapt_path,
740 "--configuration-name=$android_configuration_name",
741 "--android-manifest",
742 rebase_path(invoker.android_manifest, root_build_dir),
743 "--version-code",
744 _version_code,
745 "--version-name",
746 _version_name,
747 "--apk-path",
748 rebase_path(invoker.resource_packaged_apk_path, root_build_dir),
749 ]
750
751 if (defined(_asset_location)) {
752 args += [
753 "--asset-dir",
754 rebase_path(_asset_location, root_build_dir),
755 ]
756 }
757 if (defined(_resources_zip)) {
758 args += [
759 "--resource-zips",
760 rebase_path(_resources_zip, root_build_dir),
761 ]
762 }
763 if (_shared_resources) {
764 args += [ "--shared-resources" ]
765 }
766 if (_split_densities != []) {
767 args += [ "--create-density-splits" ]
768 foreach(_density, _split_densities) {
769 outputs += [ "${invoker.resource_packaged_apk_path}_${_density}" ]
770 }
771 }
772 if (_split_languages != []) {
773 args += [ "--language-splits=$_split_languages" ]
774 foreach(_language, _split_languages) {
775 outputs += [ "${invoker.resource_packaged_apk_path}_${_language}" ]
776 }
777 }
778 if (defined(invoker.extensions_to_not_compress)) {
779 args += [
780 "--no-compress",
781 invoker.extensions_to_not_compress,
782 ]
783 }
784 }
785 }
786
710 _package_resources_target_name = "${target_name}__package_resources" 787 _package_resources_target_name = "${target_name}__package_resources"
711 action(_package_resources_target_name) { 788 package_resources_helper(_package_resources_target_name) {
712 deps = _package_deps 789 forward_variables_from(invoker, [ "extensions_to_not_compress" ])
790 deps = _deps
791 android_manifest = _android_manifest
792 resource_packaged_apk_path = _resource_packaged_apk_path
793 }
713 794
714 script = "//build/android/gyp/package_resources.py" 795 _generate_incremental_manifest_target_name =
796 "${target_name}_incremental_generate_manifest"
797 _incremental_android_manifest =
798 get_label_info(_generate_incremental_manifest_target_name,
799 "target_gen_dir") + "/AndroidManifest.xml"
800 action(_generate_incremental_manifest_target_name) {
801 deps = _deps
802 script = "//build/android/incremental_install/generate_android_manifest.py"
715 depfile = "${target_gen_dir}/${target_name}.d" 803 depfile = "${target_gen_dir}/${target_name}.d"
716 inputs = [ 804 inputs = [
717 _android_manifest, 805 _android_manifest,
718 ] 806 ]
719 if (defined(_resources_zip)) {
720 inputs += [ _resources_zip ]
721 }
722 outputs = [ 807 outputs = [
723 depfile, 808 depfile,
724 _resource_packaged_apk_path, 809 _incremental_android_manifest,
725 ] 810 ]
726 811
812 _rebased_src_manifest = rebase_path(_android_manifest, root_build_dir)
813 _rebased_incremental_manifest =
814 rebase_path(_incremental_android_manifest, root_build_dir)
727 args = [ 815 args = [
728 "--depfile", 816 "--src-manifest=$_rebased_src_manifest",
729 rebase_path(depfile, root_build_dir), 817 "--out-manifest=$_rebased_incremental_manifest",
730 "--android-sdk",
731 rebased_android_sdk,
732 "--aapt-path",
733 android_aapt_path,
734 "--configuration-name=$android_configuration_name",
735 "--android-manifest",
736 rebase_path(_android_manifest, root_build_dir),
737 "--version-code",
738 _version_code,
739 "--version-name",
740 _version_name,
741 "--apk-path",
742 rebase_path(_resource_packaged_apk_path, root_build_dir),
743 ] 818 ]
819 if (disable_incremental_isolated_processes) {
820 args += [ "--disable-isolated-processes" ]
821 }
822 }
744 823
745 if (defined(_asset_location)) { 824 _incremental_package_resources_target_name =
746 args += [ 825 "${target_name}_incremental__package_resources"
747 "--asset-dir", 826
748 rebase_path(_asset_location, root_build_dir), 827 # TODO(agrieve): See if we can speed up this step by swapping the manifest
749 ] 828 # from the result of the main package_resources step.
750 } 829 package_resources_helper(_incremental_package_resources_target_name) {
751 if (defined(_resources_zip)) { 830 forward_variables_from(invoker, [ "extensions_to_not_compress" ])
752 args += [ 831 deps = _deps + [ ":$_generate_incremental_manifest_target_name" ]
753 "--resource-zips", 832 android_manifest = _incremental_android_manifest
754 rebase_path(_resources_zip, root_build_dir), 833 resource_packaged_apk_path = _incremental_resource_packaged_apk_path
755 ]
756 }
757 if (_shared_resources) {
758 args += [ "--shared-resources" ]
759 }
760 if (_split_densities != []) {
761 args += [ "--create-density-splits" ]
762 foreach(_density, _split_densities) {
763 outputs += [ "${_resource_packaged_apk_path}_${_density}" ]
764 }
765 }
766 if (_split_languages != []) {
767 args += [ "--language-splits=$_split_languages" ]
768 foreach(_language, _split_languages) {
769 outputs += [ "${_resource_packaged_apk_path}_${_language}" ]
770 }
771 }
772 if (defined(invoker.extensions_to_not_compress)) {
773 args += [
774 "--no-compress",
775 invoker.extensions_to_not_compress,
776 ]
777 }
778 } 834 }
779 835
780 package_target = "${target_name}__package" 836 package_target = "${target_name}__package"
781 package_apk(package_target) { 837 package_apk(package_target) {
782 deps = [] 838 deps = _deps + [ ":${_package_resources_target_name}" ]
783 forward_variables_from(invoker, [ "deps" ])
784 deps += [ ":${_package_resources_target_name}" ]
785
786 data_deps = [ "//tools/android/md5sum" ] # Used when deploying APKs
787 839
788 if (defined(_dex_path)) { 840 if (defined(_dex_path)) {
789 dex_path = _dex_path 841 dex_path = _dex_path
790 } 842 }
791 native_libs_dir = _native_libs_dir 843 native_libs_dir = _native_libs_dir
792 output_apk_path = _packaged_apk_path 844 output_apk_path = _packaged_apk_path
793 resource_packaged_apk_path = _resource_packaged_apk_path 845 resource_packaged_apk_path = _resource_packaged_apk_path
794 } 846 }
795 847
796 _incremental_package_target = "${target_name}_incremental__package" 848 _incremental_package_target = "${target_name}_incremental__package"
797 package_apk(_incremental_package_target) { 849 package_apk(_incremental_package_target) {
798 deps = [] 850 _dex_target = "//build/android/incremental_install:bootstrap_java__dex"
799 forward_variables_from(invoker, [ "deps" ]) 851 deps = _deps + [
800 deps += [ ":${_package_resources_target_name}" ] 852 ":${_incremental_package_resources_target_name}",
853 _dex_target,
854 ]
801 855
802 # TODO(agrieve): Multidex
803 if (defined(_dex_path)) { 856 if (defined(_dex_path)) {
804 dex_path = _dex_path 857 dex_path =
858 get_label_info(_dex_target, "target_gen_dir") + "/bootstrap.dex"
805 } 859 }
806 860
807 # TODO(agrieve): Add a placeholder .so for http://crbug.com/384638 861 # TODO(agrieve): Add a placeholder .so for http://crbug.com/384638
808 native_libs_dir = "//build/android/empty/res" 862 native_libs_dir = "//build/android/empty/res"
809 output_apk_path = _incremental_packaged_apk_path 863 output_apk_path = _incremental_packaged_apk_path
810 resource_packaged_apk_path = _resource_packaged_apk_path 864 resource_packaged_apk_path = _incremental_resource_packaged_apk_path
811 } 865 }
812 866
813 _finalize_apk_rule_name = "${target_name}__finalize" 867 _finalize_apk_rule_name = "${target_name}__finalize"
814 finalize_apk(_finalize_apk_rule_name) { 868 finalize_apk(_finalize_apk_rule_name) {
815 input_apk_path = _packaged_apk_path 869 input_apk_path = _packaged_apk_path
816 output_apk_path = _final_apk_path 870 output_apk_path = _final_apk_path
817 keystore_path = _keystore_path 871 keystore_path = _keystore_path
818 keystore_name = _keystore_name 872 keystore_name = _keystore_name
819 keystore_password = _keystore_password 873 keystore_password = _keystore_password
820 rezip_apk = _load_library_from_apk 874 rezip_apk = _load_library_from_apk
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 ] 1682 ]
1629 args = [ 1683 args = [
1630 "--depfile", 1684 "--depfile",
1631 rebase_path(depfile, root_build_dir), 1685 rebase_path(depfile, root_build_dir),
1632 "--script-output-path", 1686 "--script-output-path",
1633 rebase_path(generated_script, root_build_dir), 1687 rebase_path(generated_script, root_build_dir),
1634 ] 1688 ]
1635 args += test_runner_args 1689 args += test_runner_args
1636 } 1690 }
1637 } 1691 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698