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

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: 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 template("package_apk") {
Dirk Pranke 2015/08/12 18:55:20 This should have comments describing what this rul
agrieve 2015/08/18 14:48:47 Done.
513 action(target_name) {
514 if (defined(invoker.testonly)) {
515 testonly = invoker.testonly
516 }
517 script = "//build/android/gyp/ant.py"
518 _ant_script = "//build/android/ant/apk-package.xml"
519
520 deps = invoker.deps
521 depfile = "$target_gen_dir/$target_name.d"
522
523 inputs = [
524 invoker.resource_packaged_apk_path,
525 _ant_script,
526 ]
527 if (defined(invoker.dex_path)) {
528 inputs += [ invoker.dex_path ]
529 }
530
531 outputs = [
532 depfile,
533 invoker.output_apk_path,
534 ]
535
536 _rebased_emma_jar = ""
537 _rebased_resource_packaged_apk_path =
538 rebase_path(invoker.resource_packaged_apk_path, root_build_dir)
539 _rebased_packaged_apk_path =
540 rebase_path(invoker.output_apk_path, root_build_dir)
541 _rebased_native_libs_dir =
542 rebase_path(invoker.native_libs_dir, root_build_dir)
543 args = [
544 "--depfile",
545 rebase_path(depfile, root_build_dir),
546 "--",
547 "-quiet",
548 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root",
549 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools",
550 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path",
551 "-DCONFIGURATION_NAME=$android_configuration_name",
552 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir",
553 "-DOUT_DIR=",
554 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path",
555 "-DEMMA_INSTRUMENT=0",
556 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar",
557 "-Dbasedir=.",
558 "-buildfile",
559 rebase_path(_ant_script, root_build_dir),
560 ]
561 if (defined(invoker.dex_path)) {
562 _rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir)
563 args += [
564 "-DDEX_FILE_PATH=$_rebased_dex_path",
565 "-DHAS_CODE=true",
566 ]
567 } else {
568 args += [ "-DHAS_CODE=false" ]
569 }
570 }
571 }
572
507 template("finalize_apk") { 573 template("finalize_apk") {
508 action(target_name) { 574 action(target_name) {
509 script = "//build/android/gyp/finalize_apk.py" 575 script = "//build/android/gyp/finalize_apk.py"
510 depfile = "$target_gen_dir/$target_name.d" 576 depfile = "$target_gen_dir/$target_name.d"
511 577
512 if (defined(invoker.testonly)) { 578 if (defined(invoker.testonly)) {
513 testonly = invoker.testonly 579 testonly = invoker.testonly
514 } 580 }
515 581
516 sources = [ 582 sources = [
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 # zipaligns the apk. 632 # zipaligns the apk.
567 template("create_apk") { 633 template("create_apk") {
568 set_sources_assignment_filter([]) 634 set_sources_assignment_filter([])
569 if (defined(invoker.testonly)) { 635 if (defined(invoker.testonly)) {
570 testonly = invoker.testonly 636 testonly = invoker.testonly
571 } 637 }
572 638
573 _android_manifest = invoker.android_manifest 639 _android_manifest = invoker.android_manifest
574 _base_path = invoker.base_path 640 _base_path = invoker.base_path
575 _final_apk_path = invoker.apk_path 641 _final_apk_path = invoker.apk_path
642 _managed_final_apk_path_helper =
643 process_file_template([ _final_apk_path ],
644 "{{source_dir}}/{{source_name_part}}_managed.apk")
645 _managed_final_apk_path = _managed_final_apk_path_helper[0]
576 646
577 if (defined(invoker.resources_zip)) { 647 if (defined(invoker.resources_zip)) {
578 _resources_zip = invoker.resources_zip 648 _resources_zip = invoker.resources_zip
579 } 649 }
580 if (defined(invoker.dex_path)) { 650 if (defined(invoker.dex_path)) {
581 _dex_path = invoker.dex_path 651 _dex_path = invoker.dex_path
582 } 652 }
583 _load_library_from_apk = invoker.load_library_from_apk 653 _load_library_from_apk = invoker.load_library_from_apk
584 654
585 _package_deps = [] 655 _package_deps = []
(...skipping 10 matching lines...) Expand all
596 _asset_location = invoker.asset_location 666 _asset_location = invoker.asset_location
597 } 667 }
598 668
599 _version_code = invoker.version_code 669 _version_code = invoker.version_code
600 _version_name = invoker.version_name 670 _version_name = invoker.version_name
601 671
602 _base_apk_path = _base_path + ".apk_intermediates" 672 _base_apk_path = _base_path + ".apk_intermediates"
603 673
604 _resource_packaged_apk_path = _base_apk_path + ".ap_" 674 _resource_packaged_apk_path = _base_apk_path + ".ap_"
605 _packaged_apk_path = _base_apk_path + ".unfinished.apk" 675 _packaged_apk_path = _base_apk_path + ".unfinished.apk"
676 _managed_packaged_apk_path = _base_apk_path + "_managed.unfinished.apk"
606 _shared_resources = 677 _shared_resources =
607 defined(invoker.shared_resources) && invoker.shared_resources 678 defined(invoker.shared_resources) && invoker.shared_resources
608 679
609 _configuration_name = "Release"
610 if (is_debug) {
611 _configuration_name = "Debug"
612 }
613
614 _keystore_path = invoker.keystore_path 680 _keystore_path = invoker.keystore_path
615 _keystore_name = invoker.keystore_name 681 _keystore_name = invoker.keystore_name
616 _keystore_password = invoker.keystore_password 682 _keystore_password = invoker.keystore_password
617 683
618 _split_densities = [] 684 _split_densities = []
619 if (defined(invoker.create_density_splits) && invoker.create_density_splits) { 685 if (defined(invoker.create_density_splits) && invoker.create_density_splits) {
620 _split_densities = [ 686 _split_densities = [
621 "hdpi", 687 "hdpi",
622 "xhdpi", 688 "xhdpi",
623 "xxhdpi", 689 "xxhdpi",
(...skipping 24 matching lines...) Expand all
648 _resource_packaged_apk_path, 714 _resource_packaged_apk_path,
649 ] 715 ]
650 716
651 args = [ 717 args = [
652 "--depfile", 718 "--depfile",
653 rebase_path(depfile, root_build_dir), 719 rebase_path(depfile, root_build_dir),
654 "--android-sdk", 720 "--android-sdk",
655 rebased_android_sdk, 721 rebased_android_sdk,
656 "--aapt-path", 722 "--aapt-path",
657 android_aapt_path, 723 android_aapt_path,
658 "--configuration-name=$_configuration_name", 724 "--configuration-name=$android_configuration_name",
659 "--android-manifest", 725 "--android-manifest",
660 rebase_path(_android_manifest, root_build_dir), 726 rebase_path(_android_manifest, root_build_dir),
661 "--version-code", 727 "--version-code",
662 _version_code, 728 _version_code,
663 "--version-name", 729 "--version-name",
664 _version_name, 730 _version_name,
665 "--apk-path", 731 "--apk-path",
666 rebase_path(_resource_packaged_apk_path, root_build_dir), 732 rebase_path(_resource_packaged_apk_path, root_build_dir),
667 ] 733 ]
668 734
(...skipping 26 matching lines...) Expand all
695 } 761 }
696 if (defined(invoker.extensions_to_not_compress)) { 762 if (defined(invoker.extensions_to_not_compress)) {
697 args += [ 763 args += [
698 "--no-compress", 764 "--no-compress",
699 invoker.extensions_to_not_compress, 765 invoker.extensions_to_not_compress,
700 ] 766 ]
701 } 767 }
702 } 768 }
703 769
704 package_target = "${target_name}__package" 770 package_target = "${target_name}__package"
705 action(package_target) { 771 package_apk(package_target) {
706 script = "//build/android/gyp/ant.py"
707 _ant_script = "//build/android/ant/apk-package.xml"
708
709 deps = [ 772 deps = [
710 ":${_package_resources_target_name}", 773 ":${_package_resources_target_name}",
711 ] 774 ]
712 if (defined(invoker.deps)) { 775 if (defined(invoker.deps)) {
713 deps += invoker.deps 776 deps += invoker.deps
714 } 777 }
715 depfile = "$target_gen_dir/$target_name.d" 778 if (defined(_dex_path)) {
779 dex_path = _dex_path
780 }
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 = [
789 ":${_package_resources_target_name}",
720 ] 790 ]
721 if (defined(_dex_path)) { 791 if (defined(invoker.deps)) {
722 inputs += [ _dex_path ] 792 deps += invoker.deps
723 } 793 }
724 794
725 outputs = [ 795 # TODO(agrieve): Multidex
726 depfile, 796 if (defined(_dex_path)) {
727 _packaged_apk_path, 797 dex_path = _dex_path
728 ] 798 }
729 799
730 _rebased_emma_jar = "" 800 # TODO(agrieve): Add a placeholder .so for http://crbug.com/384638
731 _rebased_resource_packaged_apk_path = 801 native_libs_dir = "//build/android/empty/res"
732 rebase_path(_resource_packaged_apk_path, root_build_dir) 802 output_apk_path = _managed_packaged_apk_path
733 _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir) 803 resource_packaged_apk_path = _resource_packaged_apk_path
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 } 804 }
763 805
764 _finalize_apk_rule_name = "${target_name}__finalize" 806 _finalize_apk_rule_name = "${target_name}__finalize"
765 finalize_apk(_finalize_apk_rule_name) { 807 finalize_apk(_finalize_apk_rule_name) {
766 input_apk_path = _packaged_apk_path 808 input_apk_path = _packaged_apk_path
767 output_apk_path = _final_apk_path 809 output_apk_path = _final_apk_path
768 keystore_path = _keystore_path 810 keystore_path = _keystore_path
769 keystore_name = _keystore_name 811 keystore_name = _keystore_name
770 keystore_password = _keystore_password 812 keystore_password = _keystore_password
771 rezip_apk = _load_library_from_apk 813 rezip_apk = _load_library_from_apk
772 814
773 public_deps = [ 815 public_deps = [
774 # Generator of the _packaged_apk_path this target takes as input. 816 # Generator of the _packaged_apk_path this target takes as input.
775 ":$package_target", 817 ":$package_target",
776 ] 818 ]
777 } 819 }
778 820
779 _final_deps = [ ":${_finalize_apk_rule_name}" ] 821 _managed_finalize_apk_rule_name = "${target_name}_managed__finalize"
822 finalize_apk(_managed_finalize_apk_rule_name) {
823 input_apk_path = _managed_packaged_apk_path
824 output_apk_path = _managed_final_apk_path
825 keystore_path = _keystore_path
826 keystore_name = _keystore_name
827 keystore_password = _keystore_password
828
829 public_deps = [
830 ":$_managed_package_target",
831 ]
832 }
833
834 _split_deps = []
780 835
781 template("finalize_split") { 836 template("finalize_split") {
782 finalize_apk(target_name) { 837 finalize_apk(target_name) {
783 _config = invoker.split_config 838 _config = invoker.split_config
784 _type = invoker.split_type 839 _type = invoker.split_type
785 input_apk_path = "${_resource_packaged_apk_path}_${_config}" 840 input_apk_path = "${_resource_packaged_apk_path}_${_config}"
786 _output_paths = process_file_template( 841 _output_paths = process_file_template(
787 [ _final_apk_path ], 842 [ _final_apk_path ],
788 "{{source_dir}}/{{source_name_part}}-${_type}-${_config}.apk") 843 "{{source_dir}}/{{source_name_part}}-${_type}-${_config}.apk")
789 output_apk_path = _output_paths[0] 844 output_apk_path = _output_paths[0]
790 keystore_path = _keystore_path 845 keystore_path = _keystore_path
791 keystore_name = _keystore_name 846 keystore_name = _keystore_name
792 keystore_password = _keystore_password 847 keystore_password = _keystore_password
793 deps = [ 848 deps = [
794 ":${_package_resources_target_name}", 849 ":${_package_resources_target_name}",
795 ] 850 ]
796 } 851 }
797 } 852 }
798 853
799 foreach(_split, _split_densities) { 854 foreach(_split, _split_densities) {
800 _split_rule = "${target_name}__finalize_${_split}_split" 855 _split_rule = "${target_name}__finalize_${_split}_split"
801 finalize_split(_split_rule) { 856 finalize_split(_split_rule) {
802 split_type = "density" 857 split_type = "density"
803 split_config = _split 858 split_config = _split
804 } 859 }
805 _final_deps += [ ":$_split_rule" ] 860 _split_deps += [ ":$_split_rule" ]
806 } 861 }
807 foreach(_split, _split_languages) { 862 foreach(_split, _split_languages) {
808 _split_rule = "${target_name}__finalize_${_split}_split" 863 _split_rule = "${target_name}__finalize_${_split}_split"
809 finalize_split(_split_rule) { 864 finalize_split(_split_rule) {
810 split_type = "lang" 865 split_type = "lang"
811 split_config = _split 866 split_config = _split
812 } 867 }
813 _final_deps += [ ":$_split_rule" ] 868 _split_deps += [ ":$_split_rule" ]
814 } 869 }
815 870
816 group(target_name) { 871 group(target_name) {
817 public_deps = _final_deps 872 public_deps = [ ":${_finalize_apk_rule_name}" ] + _split_deps
873 }
874 group("${target_name}_managed") {
875 public_deps = [ ":${_managed_finalize_apk_rule_name}" ] + _split_deps
818 } 876 }
819 } 877 }
820 878
821 template("java_prebuilt_impl") { 879 template("java_prebuilt_impl") {
822 set_sources_assignment_filter([]) 880 set_sources_assignment_filter([])
823 if (defined(invoker.testonly)) { 881 if (defined(invoker.testonly)) {
824 testonly = invoker.testonly 882 testonly = invoker.testonly
825 } 883 }
826 _supports_android = 884 _supports_android =
827 defined(invoker.supports_android) && invoker.supports_android 885 defined(invoker.supports_android) && invoker.supports_android
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 ] 1639 ]
1582 args = [ 1640 args = [
1583 "--depfile", 1641 "--depfile",
1584 rebase_path(depfile, root_build_dir), 1642 rebase_path(depfile, root_build_dir),
1585 "--script-output-path", 1643 "--script-output-path",
1586 rebase_path(generated_script, root_build_dir), 1644 rebase_path(generated_script, root_build_dir),
1587 ] 1645 ]
1588 args += test_runner_args 1646 args += test_runner_args
1589 } 1647 }
1590 } 1648 }
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