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

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

Issue 1288023003: Create *_managed targets for android_apk()s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more forwarded vars Created 5 years, 4 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
« no previous file with comments | « no previous file | build/config/android/rules.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6
7 assert(is_android) 7 assert(is_android)
8 8
9 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) 9 rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
10 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) 10 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir)
11 rebased_android_sdk_build_tools = 11 rebased_android_sdk_build_tools =
12 rebase_path(android_sdk_build_tools, root_build_dir) 12 rebase_path(android_sdk_build_tools, root_build_dir)
13 13
14 android_sdk_jar = "$android_sdk/android.jar" 14 android_sdk_jar = "$android_sdk/android.jar"
15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) 15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
16 android_aapt_path = "$rebased_android_sdk_build_tools/aapt" 16 android_aapt_path = "$rebased_android_sdk_build_tools/aapt"
17 17
18 android_configuration_name = "Release"
19 if (is_debug) {
20 android_configuration_name = "Debug"
21 }
22
18 template("android_lint") { 23 template("android_lint") {
19 set_sources_assignment_filter([]) 24 set_sources_assignment_filter([])
20 if (defined(invoker.testonly)) { 25 if (defined(invoker.testonly)) {
21 testonly = invoker.testonly 26 testonly = invoker.testonly
22 } 27 }
23 28
24 jar_path = invoker.jar_path 29 jar_path = invoker.jar_path
25 android_manifest = invoker.android_manifest 30 android_manifest = invoker.android_manifest
26 java_files = invoker.java_files 31 java_files = invoker.java_files
27 base_path = "$target_gen_dir/$target_name" 32 base_path = "$target_gen_dir/$target_name"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 if (defined(invoker.visibility)) { 502 if (defined(invoker.visibility)) {
498 visibility = invoker.visibility 503 visibility = invoker.visibility
499 } 504 }
500 public_deps = [ 505 public_deps = [
501 ":${target_name}__jar_toc", 506 ":${target_name}__jar_toc",
502 ":$_output_jar_target", 507 ":$_output_jar_target",
503 ] 508 ]
504 } 509 }
505 } 510 }
506 511
512 # Creates an unsigned .apk
513 #
514 # Variables
515 # deps: Specifies the dependencies of this target.
516 # dex_path: Path to classes.dex file to include (optional).
517 # resource_packaged_apk_path: Path to .ap_ to use.
518 # output_apk_path: Output path for the generated .apk.
519 # native_libs_dir: Directory containing native libraries.
520 template("package_apk") {
521 action(target_name) {
522 forward_variables_from(invoker,
523 [
524 "deps",
525 "data_deps",
526 "public_deps",
527 "testonly",
528 ])
529 script = "//build/android/gyp/ant.py"
530 _ant_script = "//build/android/ant/apk-package.xml"
531
532 depfile = "$target_gen_dir/$target_name.d"
533
534 inputs = [
535 invoker.resource_packaged_apk_path,
536 _ant_script,
537 ]
538 if (defined(invoker.dex_path)) {
539 inputs += [ invoker.dex_path ]
540 }
541
542 outputs = [
543 depfile,
544 invoker.output_apk_path,
545 ]
546
547 _rebased_emma_jar = ""
548 _rebased_resource_packaged_apk_path =
549 rebase_path(invoker.resource_packaged_apk_path, root_build_dir)
550 _rebased_packaged_apk_path =
551 rebase_path(invoker.output_apk_path, root_build_dir)
552 _rebased_native_libs_dir =
553 rebase_path(invoker.native_libs_dir, root_build_dir)
554 args = [
555 "--depfile",
556 rebase_path(depfile, root_build_dir),
557 "--",
558 "-quiet",
559 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root",
560 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools",
561 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path",
562 "-DCONFIGURATION_NAME=$android_configuration_name",
563 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir",
564 "-DOUT_DIR=",
565 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path",
566 "-DEMMA_INSTRUMENT=0",
567 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar",
568 "-Dbasedir=.",
569 "-buildfile",
570 rebase_path(_ant_script, root_build_dir),
571 ]
572 if (defined(invoker.dex_path)) {
573 _rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir)
574 args += [
575 "-DDEX_FILE_PATH=$_rebased_dex_path",
576 "-DHAS_CODE=true",
577 ]
578 } else {
579 args += [ "-DHAS_CODE=false" ]
580 }
581 }
582 }
583
507 template("finalize_apk") { 584 template("finalize_apk") {
Dirk Pranke 2015/08/25 20:04:27 this still needs comments.
agrieve 2015/08/25 23:46:59 Done.
508 action(target_name) { 585 action(target_name) {
509 script = "//build/android/gyp/finalize_apk.py" 586 script = "//build/android/gyp/finalize_apk.py"
510 depfile = "$target_gen_dir/$target_name.d" 587 depfile = "$target_gen_dir/$target_name.d"
511 588 forward_variables_from(invoker,
512 if (defined(invoker.testonly)) { 589 [
513 testonly = invoker.testonly 590 "deps",
514 } 591 "data_deps",
592 "public_deps",
593 "testonly",
594 ])
515 595
516 sources = [ 596 sources = [
517 invoker.input_apk_path, 597 invoker.input_apk_path,
518 ] 598 ]
519 inputs = [ 599 inputs = [
520 invoker.keystore_path, 600 invoker.keystore_path,
521 ] 601 ]
522 outputs = [ 602 outputs = [
523 depfile, 603 depfile,
524 invoker.output_apk_path, 604 invoker.output_apk_path,
(...skipping 17 matching lines...) Expand all
542 ] 622 ]
543 if (defined(invoker.rezip_apk) && invoker.rezip_apk) { 623 if (defined(invoker.rezip_apk) && invoker.rezip_apk) {
544 _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar" 624 _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar"
545 inputs += [ _rezip_jar_path ] 625 inputs += [ _rezip_jar_path ]
546 args += [ 626 args += [
547 "--load-library-from-zip=1", 627 "--load-library-from-zip=1",
548 "--rezip-apk-jar-path", 628 "--rezip-apk-jar-path",
549 rebase_path(_rezip_jar_path, root_build_dir), 629 rebase_path(_rezip_jar_path, root_build_dir),
550 ] 630 ]
551 } 631 }
552
553 if (defined(invoker.deps)) {
554 deps = invoker.deps
555 }
556 if (defined(invoker.public_deps)) {
557 public_deps = invoker.public_deps
558 }
559 if (defined(invoker.data_deps)) {
560 data_deps = invoker.data_deps
561 }
562 } 632 }
563 } 633 }
564 634
565 # Packages resources, assets, dex, and native libraries into an apk. Signs and 635 # Packages resources, assets, dex, and native libraries into an apk. Signs and
566 # zipaligns the apk. 636 # zipaligns the apk.
567 template("create_apk") { 637 template("create_apk") {
568 set_sources_assignment_filter([]) 638 set_sources_assignment_filter([])
569 if (defined(invoker.testonly)) { 639 forward_variables_from(invoker, [ "testonly" ])
570 testonly = invoker.testonly
571 }
572 640
573 _android_manifest = invoker.android_manifest 641 _android_manifest = invoker.android_manifest
574 _base_path = invoker.base_path 642 _base_path = invoker.base_path
575 _final_apk_path = invoker.apk_path 643 _final_apk_path = invoker.apk_path
644 _managed_final_apk_path_helper =
645 process_file_template([ _final_apk_path ],
646 "{{source_dir}}/{{source_name_part}}_managed.apk")
647 _managed_final_apk_path = _managed_final_apk_path_helper[0]
576 648
577 if (defined(invoker.resources_zip)) { 649 if (defined(invoker.resources_zip)) {
578 _resources_zip = invoker.resources_zip 650 _resources_zip = invoker.resources_zip
579 } 651 }
580 if (defined(invoker.dex_path)) { 652 if (defined(invoker.dex_path)) {
581 _dex_path = invoker.dex_path 653 _dex_path = invoker.dex_path
582 } 654 }
583 _load_library_from_apk = invoker.load_library_from_apk 655 _load_library_from_apk = invoker.load_library_from_apk
584 656
585 _package_deps = [] 657 _package_deps = []
(...skipping 10 matching lines...) Expand all
596 _asset_location = invoker.asset_location 668 _asset_location = invoker.asset_location
597 } 669 }
598 670
599 _version_code = invoker.version_code 671 _version_code = invoker.version_code
600 _version_name = invoker.version_name 672 _version_name = invoker.version_name
601 673
602 _base_apk_path = _base_path + ".apk_intermediates" 674 _base_apk_path = _base_path + ".apk_intermediates"
603 675
604 _resource_packaged_apk_path = _base_apk_path + ".ap_" 676 _resource_packaged_apk_path = _base_apk_path + ".ap_"
605 _packaged_apk_path = _base_apk_path + ".unfinished.apk" 677 _packaged_apk_path = _base_apk_path + ".unfinished.apk"
678 _managed_packaged_apk_path = _base_apk_path + "_managed.unfinished.apk"
606 _shared_resources = 679 _shared_resources =
607 defined(invoker.shared_resources) && invoker.shared_resources 680 defined(invoker.shared_resources) && invoker.shared_resources
608 681
609 _configuration_name = "Release"
610 if (is_debug) {
611 _configuration_name = "Debug"
612 }
613
614 _keystore_path = invoker.keystore_path 682 _keystore_path = invoker.keystore_path
615 _keystore_name = invoker.keystore_name 683 _keystore_name = invoker.keystore_name
616 _keystore_password = invoker.keystore_password 684 _keystore_password = invoker.keystore_password
617 685
618 _split_densities = [] 686 _split_densities = []
619 if (defined(invoker.create_density_splits) && invoker.create_density_splits) { 687 if (defined(invoker.create_density_splits) && invoker.create_density_splits) {
620 _split_densities = [ 688 _split_densities = [
621 "hdpi", 689 "hdpi",
622 "xhdpi", 690 "xhdpi",
623 "xxhdpi", 691 "xxhdpi",
(...skipping 24 matching lines...) Expand all
648 _resource_packaged_apk_path, 716 _resource_packaged_apk_path,
649 ] 717 ]
650 718
651 args = [ 719 args = [
652 "--depfile", 720 "--depfile",
653 rebase_path(depfile, root_build_dir), 721 rebase_path(depfile, root_build_dir),
654 "--android-sdk", 722 "--android-sdk",
655 rebased_android_sdk, 723 rebased_android_sdk,
656 "--aapt-path", 724 "--aapt-path",
657 android_aapt_path, 725 android_aapt_path,
658 "--configuration-name=$_configuration_name", 726 "--configuration-name=$android_configuration_name",
659 "--android-manifest", 727 "--android-manifest",
660 rebase_path(_android_manifest, root_build_dir), 728 rebase_path(_android_manifest, root_build_dir),
661 "--version-code", 729 "--version-code",
662 _version_code, 730 _version_code,
663 "--version-name", 731 "--version-name",
664 _version_name, 732 _version_name,
665 "--apk-path", 733 "--apk-path",
666 rebase_path(_resource_packaged_apk_path, root_build_dir), 734 rebase_path(_resource_packaged_apk_path, root_build_dir),
667 ] 735 ]
668 736
(...skipping 26 matching lines...) Expand all
695 } 763 }
696 if (defined(invoker.extensions_to_not_compress)) { 764 if (defined(invoker.extensions_to_not_compress)) {
697 args += [ 765 args += [
698 "--no-compress", 766 "--no-compress",
699 invoker.extensions_to_not_compress, 767 invoker.extensions_to_not_compress,
700 ] 768 ]
701 } 769 }
702 } 770 }
703 771
704 package_target = "${target_name}__package" 772 package_target = "${target_name}__package"
705 action(package_target) { 773 package_apk(package_target) {
706 script = "//build/android/gyp/ant.py" 774 deps = []
707 _ant_script = "//build/android/ant/apk-package.xml" 775 forward_variables_from(invoker, [ "deps" ])
776 deps += [ ":${_package_resources_target_name}" ]
708 777
709 deps = [ 778 if (defined(_dex_path)) {
710 ":${_package_resources_target_name}", 779 dex_path = _dex_path
711 ]
712 if (defined(invoker.deps)) {
713 deps += invoker.deps
714 } 780 }
715 depfile = "$target_gen_dir/$target_name.d" 781 native_libs_dir = _native_libs_dir
782 output_apk_path = _packaged_apk_path
783 resource_packaged_apk_path = _resource_packaged_apk_path
784 }
716 785
717 inputs = [ 786 _managed_package_target = "${target_name}_managed__package"
718 _resource_packaged_apk_path, 787 package_apk(_managed_package_target) {
719 _ant_script, 788 deps = []
720 ] 789 forward_variables_from(invoker, [ "deps" ])
790 deps += [ ":${_package_resources_target_name}" ]
791
792 # TODO(agrieve): Multidex
721 if (defined(_dex_path)) { 793 if (defined(_dex_path)) {
722 inputs += [ _dex_path ] 794 dex_path = _dex_path
723 } 795 }
724 796
725 outputs = [ 797 # TODO(agrieve): Add a placeholder .so for http://crbug.com/384638
726 depfile, 798 native_libs_dir = "//build/android/empty/res"
727 _packaged_apk_path, 799 output_apk_path = _managed_packaged_apk_path
728 ] 800 resource_packaged_apk_path = _resource_packaged_apk_path
729
730 _rebased_emma_jar = ""
731 _rebased_resource_packaged_apk_path =
732 rebase_path(_resource_packaged_apk_path, root_build_dir)
733 _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir)
734 _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir)
735 args = [
736 "--depfile",
737 rebase_path(depfile, root_build_dir),
738 "--",
739 "-quiet",
740 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root",
741 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools",
742 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path",
743 "-DCONFIGURATION_NAME=$_configuration_name",
744 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir",
745 "-DOUT_DIR=",
746 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path",
747 "-DEMMA_INSTRUMENT=0",
748 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar",
749 "-Dbasedir=.",
750 "-buildfile",
751 rebase_path(_ant_script, root_build_dir),
752 ]
753 if (defined(_dex_path)) {
754 _rebased_dex_path = rebase_path(_dex_path, root_build_dir)
755 args += [
756 "-DDEX_FILE_PATH=$_rebased_dex_path",
757 "-DHAS_CODE=true",
758 ]
759 } else {
760 args += [ "-DHAS_CODE=false" ]
761 }
762 } 801 }
763 802
764 _finalize_apk_rule_name = "${target_name}__finalize" 803 _finalize_apk_rule_name = "${target_name}__finalize"
765 finalize_apk(_finalize_apk_rule_name) { 804 finalize_apk(_finalize_apk_rule_name) {
766 input_apk_path = _packaged_apk_path 805 input_apk_path = _packaged_apk_path
767 output_apk_path = _final_apk_path 806 output_apk_path = _final_apk_path
768 keystore_path = _keystore_path 807 keystore_path = _keystore_path
769 keystore_name = _keystore_name 808 keystore_name = _keystore_name
770 keystore_password = _keystore_password 809 keystore_password = _keystore_password
771 rezip_apk = _load_library_from_apk 810 rezip_apk = _load_library_from_apk
772 811
773 public_deps = [ 812 public_deps = [
774 # Generator of the _packaged_apk_path this target takes as input. 813 # Generator of the _packaged_apk_path this target takes as input.
775 ":$package_target", 814 ":$package_target",
776 ] 815 ]
777 } 816 }
778 817
779 _final_deps = [ ":${_finalize_apk_rule_name}" ] 818 _managed_finalize_apk_rule_name = "${target_name}_managed__finalize"
819 finalize_apk(_managed_finalize_apk_rule_name) {
820 input_apk_path = _managed_packaged_apk_path
821 output_apk_path = _managed_final_apk_path
822 keystore_path = _keystore_path
823 keystore_name = _keystore_name
824 keystore_password = _keystore_password
825
826 public_deps = [
827 ":$_managed_package_target",
828 ]
829 }
830
831 _split_deps = []
780 832
781 template("finalize_split") { 833 template("finalize_split") {
782 finalize_apk(target_name) { 834 finalize_apk(target_name) {
783 _config = invoker.split_config 835 _config = invoker.split_config
784 _type = invoker.split_type 836 _type = invoker.split_type
785 input_apk_path = "${_resource_packaged_apk_path}_${_config}" 837 input_apk_path = "${_resource_packaged_apk_path}_${_config}"
786 _output_paths = process_file_template( 838 _output_paths = process_file_template(
787 [ _final_apk_path ], 839 [ _final_apk_path ],
788 "{{source_dir}}/{{source_name_part}}-${_type}-${_config}.apk") 840 "{{source_dir}}/{{source_name_part}}-${_type}-${_config}.apk")
789 output_apk_path = _output_paths[0] 841 output_apk_path = _output_paths[0]
790 keystore_path = _keystore_path 842 keystore_path = _keystore_path
791 keystore_name = _keystore_name 843 keystore_name = _keystore_name
792 keystore_password = _keystore_password 844 keystore_password = _keystore_password
793 deps = [ 845 deps = [
794 ":${_package_resources_target_name}", 846 ":${_package_resources_target_name}",
795 ] 847 ]
796 } 848 }
797 } 849 }
798 850
799 foreach(_split, _split_densities) { 851 foreach(_split, _split_densities) {
800 _split_rule = "${target_name}__finalize_${_split}_split" 852 _split_rule = "${target_name}__finalize_${_split}_split"
801 finalize_split(_split_rule) { 853 finalize_split(_split_rule) {
802 split_type = "density" 854 split_type = "density"
803 split_config = _split 855 split_config = _split
804 } 856 }
805 _final_deps += [ ":$_split_rule" ] 857 _split_deps += [ ":$_split_rule" ]
806 } 858 }
807 foreach(_split, _split_languages) { 859 foreach(_split, _split_languages) {
808 _split_rule = "${target_name}__finalize_${_split}_split" 860 _split_rule = "${target_name}__finalize_${_split}_split"
809 finalize_split(_split_rule) { 861 finalize_split(_split_rule) {
810 split_type = "lang" 862 split_type = "lang"
811 split_config = _split 863 split_config = _split
812 } 864 }
813 _final_deps += [ ":$_split_rule" ] 865 _split_deps += [ ":$_split_rule" ]
814 } 866 }
815 867
816 group(target_name) { 868 group(target_name) {
817 public_deps = _final_deps 869 public_deps = [ ":${_finalize_apk_rule_name}" ] + _split_deps
870 }
871 group("${target_name}_managed") {
872 public_deps = [ ":${_managed_finalize_apk_rule_name}" ] + _split_deps
818 } 873 }
819 } 874 }
820 875
821 template("java_prebuilt_impl") { 876 template("java_prebuilt_impl") {
822 set_sources_assignment_filter([]) 877 set_sources_assignment_filter([])
823 if (defined(invoker.testonly)) { 878 if (defined(invoker.testonly)) {
824 testonly = invoker.testonly 879 testonly = invoker.testonly
825 } 880 }
826 _supports_android = 881 _supports_android =
827 defined(invoker.supports_android) && invoker.supports_android 882 defined(invoker.supports_android) && invoker.supports_android
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 ] 1636 ]
1582 args = [ 1637 args = [
1583 "--depfile", 1638 "--depfile",
1584 rebase_path(depfile, root_build_dir), 1639 rebase_path(depfile, root_build_dir),
1585 "--script-output-path", 1640 "--script-output-path",
1586 rebase_path(generated_script, root_build_dir), 1641 rebase_path(generated_script, root_build_dir),
1587 ] 1642 ]
1588 args += test_runner_args 1643 args += test_runner_args
1589 } 1644 }
1590 } 1645 }
OLDNEW
« no previous file with comments | « no previous file | build/config/android/rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698