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

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

Issue 732423002: Update from chromium https://crrev.com/304586 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « build/config/android/internal_rules.gni ('k') | build/config/compiler/BUILD.gn » ('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("//base/android/linker/config.gni") 5 import("//base/android/linker/config.gni")
6 import("//build/config/android/config.gni") 6 import("//build/config/android/config.gni")
7 import("//build/config/android/internal_rules.gni") 7 import("//build/config/android/internal_rules.gni")
8 import("//tools/grit/grit_rule.gni") 8 import("//tools/grit/grit_rule.gni")
9 import("//tools/relocation_packer/config.gni") 9 import("//tools/relocation_packer/config.gni")
10 10
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 633 }
634 634
635 group(target_name) { 635 group(target_name) {
636 deps = [ 636 deps = [
637 ":${target_name}__build_config", 637 ":${target_name}__build_config",
638 ":${target_name}__zip", 638 ":${target_name}__zip",
639 ] 639 ]
640 } 640 }
641 } 641 }
642 642
643 # Declare a Java executable target
644 #
645 # This target creates an executable from java code and libraries. The executable
646 # will be in the output folder's /bin/ directory.
647 #
648 # Variables
649 # deps: Specifies the dependencies of this target. Java targets in this list
650 # will be included in the executable (and the javac classpath).
651 #
652 # java_files: List of .java files included in this library.
653 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
654 # will be added to java_files and be included in this library.
655 # srcjars: List of srcjars to be included in this library, together with the
656 # ones obtained from srcjar_deps.
657 #
658 # chromium_code: If true, extra analysis warning/errors will be enabled.
659 #
660 # datadeps, testonly
661 #
662 # Example
663 # java_library("foo") {
664 # java_files = [ "org/chromium/foo/FooMain.java" ]
665 # deps = [ ":bar_java" ]
666 # main_class = "org.chromium.foo.FooMain"
667 # }
668 template("java_binary") {
669 # TODO(cjhopman): This should not act like a java_library for dependents (i.e.
670 # dependents shouldn't get the jar in their classpath, etc.).
671 java_library_impl(target_name) {
672 if (defined(invoker.DEPRECATED_java_in_dir)) { DEPRECATED_java_in_dir = invo ker.DEPRECATED_java_in_dir }
673 if (defined(invoker.chromium_code)) { chromium_code = invoker.chromium_code }
674 if (defined(invoker.datadeps)) { deps = invoker.datadeps }
675 if (defined(invoker.deps)) { deps = invoker.deps }
676 if (defined(invoker.java_files)) { java_files = invoker.java_files }
677 if (defined(invoker.srcjar_deps)) { srcjar_deps = invoker.srcjar_deps }
678 if (defined(invoker.srcjars)) { srcjars = invoker.srcjars }
679 if (defined(invoker.testonly)) { testonly = invoker.testonly }
680
681 main_class = invoker.main_class
682 }
683 }
684
643 685
686 # Declare an java library target
687 #
688 # Variables
689 # deps: Specifies the dependencies of this target. Java targets in this list
690 # will be added to the javac classpath.
691 #
692 # java_files: List of .java files included in this library.
693 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
694 # will be added to java_files and be included in this library.
695 # srcjars: List of srcjars to be included in this library, together with the
696 # ones obtained from srcjar_deps.
697 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
698 # this directory will be included in the library. This is only supported to
699 # ease the gyp->gn conversion and will be removed in the future.
700 #
701 # chromium_code: If true, extra analysis warning/errors will be enabled.
702 # jar_excluded_patterns: List of patterns of .class files to exclude from the
703 # final jar.
704 #
705 # proguard_preprocess: If true, proguard preprocessing will be run. This can
706 # be used to remove unwanted parts of the library.
707 # proguard_config: Path to the proguard config for preprocessing.
708 #
709 # supports_android: If true, Android targets (android_library, android_apk)
710 # may depend on this target. Note: if true, this target must only use the
711 # subset of Java available on Android.
712 # requires_android_platform: If true, this library may depend on
713 # android-specific targets. If this is the case, there should be some
714 # android-platform-like implementation available at runtime (Android,
715 # robolectric, etc).
716 #
717 # datadeps, testonly
718 #
719 # Example
720 # java_library("foo_java") {
721 # java_files = [
722 # "org/chromium/foo/Foo.java",
723 # "org/chromium/foo/FooInterface.java",
724 # "org/chromium/foo/FooService.java",
725 # ]
726 # deps = [
727 # ":bar_java"
728 # ]
729 # srcjar_deps = [
730 # ":foo_generated_enum"
731 # ]
732 # jar_excluded_patterns = [
733 # "*/FooService.class", "*/FooService##*.class"
734 # ]
735 # }
736 template("java_library") {
737 java_library_impl(target_name) {
738 if (defined(invoker.DEPRECATED_java_in_dir)) { DEPRECATED_java_in_dir = invo ker.DEPRECATED_java_in_dir }
739 if (defined(invoker.chromium_code)) { chromium_code = invoker.chromium_code }
740 if (defined(invoker.datadeps)) { deps = invoker.datadeps }
741 if (defined(invoker.deps)) { deps = invoker.deps }
742 if (defined(invoker.jar_excluded_patterns)) { jar_excluded_patterns = invoke r.jar_excluded_patterns }
743 if (defined(invoker.java_files)) { java_files = invoker.java_files }
744 if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_c onfig }
745 if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.pr oguard_preprocess }
746 if (defined(invoker.srcjar_deps)) { srcjar_deps = invoker.srcjar_deps }
747 if (defined(invoker.srcjars)) { srcjars = invoker.srcjars }
748 if (defined(invoker.testonly)) { testonly = invoker.testonly }
749 if (defined(invoker.jar_path)) { jar_path = invoker.jar_path }
750
751 if (defined(invoker.supports_android) && invoker.supports_android) {
752 supports_android = true
753 }
754 if (defined(invoker.requires_android_platform)
755 && invoker.requires_android_platform) {
756 supports_android = true
757 requires_android = true
758 }
759 }
760 }
761
762
763 # Declare an java library target for a prebuilt jar
764 #
765 # Variables
766 # deps: Specifies the dependencies of this target. Java targets in this list
767 # will be added to the javac classpath.
768 # jar_path: Path to the prebuilt jar.
769 # proguard_preprocess: If true, proguard preprocessing will be run. This can
770 # be used to remove unwanted parts of the library.
771 # proguard_config: Path to the proguard config for preprocessing.
772 #
773 # Example
774 # java_prebuilt("foo_java") {
775 # jar_path = "foo.jar"
776 # deps = [
777 # ":foo_resources",
778 # ":bar_java"
779 # ]
780 # }
781 template("java_prebuilt") {
782 java_prebuilt_impl(target_name) {
783 jar_path = invoker.jar_path
784 if (defined(invoker.testonly)) { testonly = invoker.testonly }
785 if (defined(invoker.deps)) { deps = invoker.deps }
786 if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_c onfig }
787 if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.pr oguard_preprocess }
788 }
789 }
790
644 # Declare an Android library target 791 # Declare an Android library target
645 # 792 #
646 # This target creates an Android library containing java code and Android 793 # This target creates an Android library containing java code and Android
647 # resources. 794 # resources.
648 # 795 #
649 # Variables 796 # Variables
650 # deps: Specifies the dependencies of this target. Java targets in this list 797 # deps: Specifies the dependencies of this target. Java targets in this list
651 # will be added to the javac classpath. Android resources in dependencies 798 # will be added to the javac classpath. Android resources in dependencies
652 # will be used when building this library. 799 # will be used when building this library.
800 #
653 # java_files: List of .java files included in this library. 801 # java_files: List of .java files included in this library.
654 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars 802 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
655 # will be added to java_files and be included in this library. 803 # will be added to java_files and be included in this library.
656 # srcjars: List of srcjars to be included in this library, together with the 804 # srcjars: List of srcjars to be included in this library, together with the
657 # ones obtained from srcjar_deps. 805 # ones obtained from srcjar_deps.
806 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
807 # this directory will be included in the library. This is only supported to
808 # ease the gyp->gn conversion and will be removed in the future.
809 #
658 # chromium_code: If true, extra analysis warning/errors will be enabled. 810 # chromium_code: If true, extra analysis warning/errors will be enabled.
659 # jar_excluded_patterns: List of patterns of .class files to exclude from the 811 # jar_excluded_patterns: List of patterns of .class files to exclude from the
660 # final jar. 812 # final jar.
813 #
661 # proguard_preprocess: If true, proguard preprocessing will be run. This can 814 # proguard_preprocess: If true, proguard preprocessing will be run. This can
662 # be used to remove unwanted parts of the library. 815 # be used to remove unwanted parts of the library.
663 # proguard_config: Path to the proguard config for preprocessing. 816 # proguard_config: Path to the proguard config for preprocessing.
664 # 817 #
665 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
666 # this directory will be included in the library. This is only supported to
667 # ease the gyp->gn conversion and will be removed in the future.
668 # 818 #
669 # Example 819 # Example
670 # android_library("foo_java") { 820 # android_library("foo_java") {
671 # java_files = [ 821 # java_files = [
672 # "android/org/chromium/foo/Foo.java", 822 # "android/org/chromium/foo/Foo.java",
673 # "android/org/chromium/foo/FooInterface.java", 823 # "android/org/chromium/foo/FooInterface.java",
674 # "android/org/chromium/foo/FooService.java", 824 # "android/org/chromium/foo/FooService.java",
675 # ] 825 # ]
676 # deps = [ 826 # deps = [
677 # ":bar_java" 827 # ":bar_java"
678 # ] 828 # ]
679 # srcjar_deps = [ 829 # srcjar_deps = [
680 # ":foo_generated_enum" 830 # ":foo_generated_enum"
681 # ] 831 # ]
682 # jar_excluded_patterns = [ 832 # jar_excluded_patterns = [
683 # "*/FooService.class", "*/FooService##*.class" 833 # "*/FooService.class", "*/FooService##*.class"
684 # ] 834 # ]
685 # } 835 # }
686 template("android_library") { 836 template("android_library") {
687 if (defined(invoker.testonly)) { testonly = invoker.testonly } 837 assert(!defined(invoker.jar_path),
838 "android_library does not support a custom jar path")
839 java_library_impl(target_name) {
840 if (defined(invoker.DEPRECATED_java_in_dir)) { DEPRECATED_java_in_dir = invo ker.DEPRECATED_java_in_dir }
841 if (defined(invoker.chromium_code)) { chromium_code = invoker.chromium_code }
842 if (defined(invoker.datadeps)) { deps = invoker.datadeps }
843 if (defined(invoker.deps)) { deps = invoker.deps }
844 if (defined(invoker.jar_excluded_patterns)) { jar_excluded_patterns = invoke r.jar_excluded_patterns }
845 if (defined(invoker.java_files)) { java_files = invoker.java_files }
846 if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_c onfig }
847 if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.pr oguard_preprocess }
848 if (defined(invoker.srcjar_deps)) { srcjar_deps = invoker.srcjar_deps }
849 if (defined(invoker.srcjars)) { srcjars = invoker.srcjars }
850 if (defined(invoker.testonly)) { testonly = invoker.testonly }
851 if (defined(invoker.dex_path)) { dex_path = invoker.dex_path }
688 852
689 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir) 853 supports_android = true
690 || defined(invoker.srcjars) || defined(invoker.srcjar_deps)) 854 requires_android = true
691 _base_path = "$target_gen_dir/$target_name"
692 _build_config = _base_path + ".build_config"
693 _jar_path = _base_path + ".jar"
694 if (defined(invoker.dex_path)) {
695 _dex_path = invoker.dex_path
696 } else {
697 _dex_path = _base_path + ".dex.jar"
698 }
699 855
700 write_build_config("${target_name}__build_config") { 856 if (!defined(jar_excluded_patterns)) { jar_excluded_patterns = [] }
701 type = "android_library" 857 jar_excluded_patterns += [
702
703 deps = []
704 if (defined(invoker.deps)) {
705 deps += invoker.deps
706 }
707
708 build_config = _build_config
709 jar_path = _jar_path
710 dex_path = _dex_path
711 }
712
713 _chromium_code = true
714 if (defined(invoker.chromium_code)) {
715 _chromium_code = invoker.chromium_code
716 }
717
718 android_java_library(target_name) {
719 chromium_code = _chromium_code
720 if (defined(invoker.java_files)) {
721 java_files = invoker.java_files
722 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
723 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
724 }
725 build_config = _build_config
726 jar_path = _jar_path
727 dex_path = _dex_path
728
729 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
730 proguard_preprocess = true
731 proguard_config = invoker.proguard_config
732 }
733
734 jar_excluded_patterns = [
735 "*/R.class", "*/R##*.class", 858 "*/R.class", "*/R##*.class",
736 "*/Manifest.class", "*/Manifest##*.class", 859 "*/Manifest.class", "*/Manifest##*.class",
737 ] 860 ]
738 if (defined(invoker.jar_excluded_patterns)) {
739 jar_excluded_patterns += invoker.jar_excluded_patterns
740 }
741
742 if (defined(invoker.srcjar_deps)) {
743 srcjar_deps = invoker.srcjar_deps
744 }
745 if (defined(invoker.srcjars)) {
746 srcjars = invoker.srcjars
747 }
748 } 861 }
749 } 862 }
750 863
751 template("java_library") {
752 if (defined(invoker.testonly)) { testonly = invoker.testonly }
753
754 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
755 || defined(invoker.srcjars))
756
757 _srcjar_deps = []
758 if (defined(invoker.srcjar_deps)) {
759 _srcjar_deps = invoker.srcjar_deps
760 }
761
762 _srcjars = []
763 if (defined(invoker.srcjars)) {
764 _srcjars = invoker.srcjars
765 }
766
767 _java_files = []
768 if (defined(invoker.java_files)) {
769 _java_files = invoker.java_files
770 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
771 _src_dir = invoker.DEPRECATED_java_in_dir + "/src"
772 _src_dir_exists = exec_script("//build/dir_exists.py",
773 [ rebase_path(_src_dir, root_build_dir) ],
774 "string")
775 assert(_src_dir_exists == "False",
776 "In GN, java_in_dir should be the fully specified java directory " +
777 "(i.e. including the trailing \"/src\")")
778
779 _java_files_build_rel = exec_script(
780 "//build/android/gyp/find.py",
781 [
782 "--pattern",
783 "*.java",
784 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir)
785 ],
786 "list lines"
787 )
788 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
789 }
790 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
791
792 # TODO(cjhopman): Write a proper build config so that java library
793 # dependencies work correctly.
794 _build_config = "$target_gen_dir/$target_name.build_config"
795 write_file(
796 _build_config,
797 "{ \"javac\": { \"classpath\": [], \"srcjars\": [] } }")
798
799 _jar_path = "$root_build_dir/lib.java/$target_name.jar"
800 if (defined(invoker.jar_path)) {
801 _jar_path = invoker.jar_path
802 }
803
804 compile_java(target_name) {
805 build_config = _build_config
806 jar_path = _jar_path
807 java_files = _java_files
808 srcjar_deps = _srcjar_deps
809 srcjars = _srcjars
810 }
811 }
812
813
814 # Declare an Android library target for a prebuilt jar 864 # Declare an Android library target for a prebuilt jar
815 # 865 #
816 # This target creates an Android library containing java code and Android 866 # This target creates an Android library containing java code and Android
817 # resources. 867 # resources.
818 # 868 #
819 # Variables 869 # Variables
820 # deps: Specifies the dependencies of this target. Java targets in this list 870 # deps: Specifies the dependencies of this target. Java targets in this list
821 # will be added to the javac classpath. Android resources in dependencies 871 # will be added to the javac classpath. Android resources in dependencies
822 # will be used when building this library. 872 # will be used when building this library.
823 # jar_path: Path to the prebuilt jar. 873 # jar_path: Path to the prebuilt jar.
824 # proguard_preprocess: If true, proguard preprocessing will be run. This can 874 # proguard_preprocess: If true, proguard preprocessing will be run. This can
825 # be used to remove unwanted parts of the library. 875 # be used to remove unwanted parts of the library.
826 # proguard_config: Path to the proguard config for preprocessing. 876 # proguard_config: Path to the proguard config for preprocessing.
827 # 877 #
828 # Example 878 # Example
829 # android_java_prebuilt("foo_java") { 879 # android_java_prebuilt("foo_java") {
830 # jar_path = "foo.jar" 880 # jar_path = "foo.jar"
831 # deps = [ 881 # deps = [
832 # ":foo_resources", 882 # ":foo_resources",
833 # ":bar_java" 883 # ":bar_java"
834 # ] 884 # ]
835 # } 885 # }
836 template("android_java_prebuilt") { 886 template("android_java_prebuilt") {
837 if (defined(invoker.testonly)) { testonly = invoker.testonly } 887 java_prebuilt_impl(target_name) {
838 888 jar_path = invoker.jar_path
839 assert(defined(invoker.jar_path)) 889 supports_android = true
840 _base_path = "${target_gen_dir}/$target_name" 890 requires_android = true
841 _jar_path = _base_path + ".jar" 891 if (defined(invoker.testonly)) { testonly = invoker.testonly }
842 _dex_path = _base_path + ".dex.jar" 892 if (defined(invoker.deps)) { deps = invoker.deps }
843 _build_config = _base_path + ".build_config" 893 if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_c onfig }
844 894 if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.pr oguard_preprocess }
845 write_build_config("${target_name}__build_config") {
846 type = "android_library"
847
848 deps = []
849 if (defined(invoker.deps)) {
850 deps += invoker.deps
851 }
852 build_config = _build_config
853 jar_path = _jar_path
854 dex_path = _dex_path
855 }
856
857 java_prebuilt("${target_name}__process_jar") {
858 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
859 proguard_preprocess = true
860 proguard_config = invoker.proguard_config
861 }
862
863 build_config = _build_config
864 input_jar_path = invoker.jar_path
865 output_jar_path = _jar_path
866 }
867
868 dex("${target_name}__dex") {
869 sources = [_jar_path]
870 output = _dex_path
871 }
872
873 group(target_name) {
874 deps = [
875 ":${target_name}__build_config",
876 ":${target_name}__dex",
877 ]
878 } 895 }
879 } 896 }
880 897
881 898
882 899
883 # Declare an Android apk target 900 # Declare an Android apk target
884 # 901 #
885 # This target creates an Android APK containing java code, resources, assets, 902 # This target creates an Android APK containing java code, resources, assets,
886 # and (possibly) native libraries. 903 # and (possibly) native libraries.
887 # 904 #
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 # native_libs = [ 944 # native_libs = [
928 # native_lib_path 945 # native_lib_path
929 # ] 946 # ]
930 # } 947 # }
931 template("android_apk") { 948 template("android_apk") {
932 if (defined(invoker.testonly)) { testonly = invoker.testonly } 949 if (defined(invoker.testonly)) { testonly = invoker.testonly }
933 950
934 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name)) 951 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name))
935 gen_dir = "$target_gen_dir/$target_name" 952 gen_dir = "$target_gen_dir/$target_name"
936 base_path = "$gen_dir/$target_name" 953 base_path = "$gen_dir/$target_name"
937 build_config = "$base_path.build_config" 954 _build_config = "$base_path.build_config"
938 resources_zip_path = "$base_path.resources.zip" 955 resources_zip_path = "$base_path.resources.zip"
939 all_resources_zip_path = "$base_path.resources.all.zip" 956 all_resources_zip_path = "$base_path.resources.all.zip"
940 jar_path = "$base_path.jar" 957 jar_path = "$base_path.jar"
941 final_dex_path = "$gen_dir/classes.dex" 958 final_dex_path = "$gen_dir/classes.dex"
942 _template_name = target_name 959 _template_name = target_name
943 _final_apk_path = "" 960 _final_apk_path = ""
944 if (defined(invoker.final_apk_path)) { 961 if (defined(invoker.final_apk_path)) {
945 _final_apk_path = invoker.final_apk_path 962 _final_apk_path = invoker.final_apk_path
946 } else if (defined(invoker.apk_name)) { 963 } else if (defined(invoker.apk_name)) {
947 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk" 964 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 } 1003 }
987 1004
988 _enable_relocation_packing = false 1005 _enable_relocation_packing = false
989 if (defined(invoker.enable_relocation_packing) && 1006 if (defined(invoker.enable_relocation_packing) &&
990 invoker.enable_relocation_packing) { 1007 invoker.enable_relocation_packing) {
991 _enable_relocation_packing = relocation_packing_supported 1008 _enable_relocation_packing = relocation_packing_supported
992 assert(_use_chromium_linker, "Relocation packing requires use of the" + 1009 assert(_use_chromium_linker, "Relocation packing requires use of the" +
993 " Chromium linker.") 1010 " Chromium linker.")
994 } 1011 }
995 1012
996 _native_libs = invoker.native_libs 1013 _native_libs = process_file_template(
1014 invoker.native_libs,
1015 "$root_build_dir/lib.stripped/{{source_file_part}}")
1016
997 _native_libs_dir = base_path + "/libs" 1017 _native_libs_dir = base_path + "/libs"
998 1018
999 if (_use_chromium_linker) { 1019 if (_use_chromium_linker) {
1000 _native_libs += [ 1020 _native_libs += [
1001 "$root_build_dir/lib.stripped/libchromium_android_linker.so" 1021 "$root_build_dir/lib.stripped/libchromium_android_linker.so"
1002 ] 1022 ]
1003 } 1023 }
1004 1024
1005 _enable_relocation_packing = false 1025 _enable_relocation_packing = false
1006 if (_use_chromium_linker && defined(invoker.enable_relocation_packing) && 1026 if (_use_chromium_linker && defined(invoker.enable_relocation_packing) &&
1007 invoker.enable_relocation_packing) { 1027 invoker.enable_relocation_packing) {
1008 _enable_relocation_packing = true 1028 _enable_relocation_packing = true
1009 } 1029 }
1010 } 1030 }
1011 1031
1012 _rebased_build_config = rebase_path(build_config, root_build_dir) 1032 _rebased_build_config = rebase_path(_build_config, root_build_dir)
1013 1033
1014 write_build_config("${_template_name}__build_config") { 1034 write_build_config("${_template_name}__build_config") {
1015 type = "android_apk" 1035 type = "android_apk"
1016 dex_path = final_dex_path 1036 dex_path = final_dex_path
1017 resources_zip = resources_zip_path 1037 resources_zip = resources_zip_path
1038 build_config = _build_config
1018 1039
1019 if (defined(invoker.deps)) { 1040 if (defined(invoker.deps)) {
1020 deps = invoker.deps 1041 deps = invoker.deps
1021 } 1042 }
1022 1043
1023 native_libs = _native_libs 1044 native_libs = _native_libs
1024 } 1045 }
1025 1046
1026 final_deps = [] 1047 final_deps = []
1027 1048
1028 final_deps += [":${_template_name}__process_resources"] 1049 final_deps += [":${_template_name}__process_resources"]
1029 process_resources("${_template_name}__process_resources") { 1050 process_resources("${_template_name}__process_resources") {
1030 srcjar_path = "${target_gen_dir}/${target_name}.srcjar" 1051 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
1031 android_manifest = invoker.android_manifest 1052 android_manifest = invoker.android_manifest
1032 resource_dirs = ["//build/android/ant/empty/res"] 1053 resource_dirs = ["//build/android/ant/empty/res"]
1033 zip_path = resources_zip_path 1054 zip_path = resources_zip_path
1034 generate_constant_ids = true 1055 generate_constant_ids = true
1056 build_config = _build_config
1035 } 1057 }
1036 _srcjar_deps += [":${_template_name}__process_resources"] 1058 _srcjar_deps += [":${_template_name}__process_resources"]
1037 1059
1038 if (_native_libs != []) { 1060 if (_native_libs != []) {
1039 _enable_chromium_linker_tests = false 1061 _enable_chromium_linker_tests = false
1040 if (defined(invoker.enable_chromium_linker_tests)) { 1062 if (defined(invoker.enable_chromium_linker_tests)) {
1041 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests 1063 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
1042 } 1064 }
1043 1065
1044 _native_lib_version_name = "" 1066 _native_lib_version_name = ""
1045 1067
1046 java_cpp_template("${_template_name}__native_libraries_java") { 1068 java_cpp_template("${_template_name}__native_libraries_java") {
1047 package_name = "org/chromium/base/library_loader" 1069 package_name = "org/chromium/base/library_loader"
1048 sources = [ 1070 sources = [
1049 "//base/android/java/templates/NativeLibraries.template", 1071 "//base/android/java/templates/NativeLibraries.template",
1050 ] 1072 ]
1051 inputs = [ 1073 inputs = [
1052 build_config, 1074 _build_config,
1053 ] 1075 ]
1054 1076
1055 defines = [ 1077 defines = [
1056 "NATIVE_LIBRARIES_LIST=" + 1078 "NATIVE_LIBRARIES_LIST=" +
1057 "@FileArg($_rebased_build_config:native:java_libraries_list)", 1079 "@FileArg($_rebased_build_config:native:java_libraries_list)",
1058 "NATIVE_LIBRARIES_VERSION_NUMBER=\"$_native_lib_version_name\"", 1080 "NATIVE_LIBRARIES_VERSION_NUMBER=\"$_native_lib_version_name\"",
1059 ] 1081 ]
1060 if (_use_chromium_linker) { 1082 if (_use_chromium_linker) {
1061 defines += ["ENABLE_CHROMIUM_LINKER"] 1083 defines += ["ENABLE_CHROMIUM_LINKER"]
1062 } 1084 }
1063 if (_load_library_from_apk) { 1085 if (_load_library_from_apk) {
1064 defines += ["ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE"] 1086 defines += ["ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE"]
1065 } 1087 }
1066 if (_enable_chromium_linker_tests) { 1088 if (_enable_chromium_linker_tests) {
1067 defines += ["ENABLE_CHROMIUM_LINKER_TESTS"] 1089 defines += ["ENABLE_CHROMIUM_LINKER_TESTS"]
1068 } 1090 }
1069 } 1091 }
1070 _srcjar_deps += [ ":${_template_name}__native_libraries_java" ] 1092 _srcjar_deps += [ ":${_template_name}__native_libraries_java" ]
1071 } 1093 }
1072 1094
1073 final_deps += [ ":${_template_name}__java" ] 1095 final_deps += [ ":${_template_name}__java" ]
1074 android_java_library("${_template_name}__java") { 1096 java_library_impl("${_template_name}__java") {
1097 supports_android = true
1098 requires_android = true
1099 override_build_config = _build_config
1075 android_manifest = invoker.android_manifest 1100 android_manifest = invoker.android_manifest
1101 chromium_code = true
1076 if (defined(invoker.java_files)) { 1102 if (defined(invoker.java_files)) {
1077 java_files = invoker.java_files 1103 java_files = invoker.java_files
1078 } else if (defined(invoker.DEPRECATED_java_in_dir)) { 1104 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
1079 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir 1105 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
1080 } else { 1106 } else {
1081 java_files = [] 1107 java_files = []
1082 } 1108 }
1083 srcjar_deps = _srcjar_deps 1109 srcjar_deps = _srcjar_deps
1084 dex_path = base_path + ".dex.jar" 1110 dex_path = base_path + ".dex.jar"
1085 } 1111 }
1086 1112
1087 if (_dist_jar_path != "") { 1113 if (_dist_jar_path != "") {
1088 final_deps += [ ":${_template_name}__create_dist_jar" ] 1114 final_deps += [ ":${_template_name}__create_dist_jar" ]
1089 # TODO(cjhopman): This is only ever needed to calculate the list of tests to 1115 # TODO(cjhopman): This is only ever needed to calculate the list of tests to
1090 # run. See build/android/pylib/instrumentation/test_jar.py. We should be 1116 # run. See build/android/pylib/instrumentation/test_jar.py. We should be
1091 # able to just do that calculation at build time instead. 1117 # able to just do that calculation at build time instead.
1092 action("${_template_name}__create_dist_jar") { 1118 action("${_template_name}__create_dist_jar") {
1093 script = "//build/android/gyp/create_dist_jar.py" 1119 script = "//build/android/gyp/create_dist_jar.py"
1094 depfile = "$target_gen_dir/$target_name.d" 1120 depfile = "$target_gen_dir/$target_name.d"
1095 inputs = [ build_config ] 1121 inputs = [ _build_config ]
1096 outputs = [ 1122 outputs = [
1097 depfile, 1123 depfile,
1098 _dist_jar_path, 1124 _dist_jar_path,
1099 ] 1125 ]
1100 args = [ 1126 args = [
1101 "--depfile", rebase_path(depfile, root_build_dir), 1127 "--depfile", rebase_path(depfile, root_build_dir),
1102 "--output", rebase_path(_dist_jar_path, root_build_dir), 1128 "--output", rebase_path(_dist_jar_path, root_build_dir),
1103 "--inputs=@FileArg($_rebased_build_config:dist_jar:dependency_jars)", 1129 "--inputs=@FileArg($_rebased_build_config:dist_jar:dependency_jars)",
1104 ] 1130 ]
1105 inputs += [ jar_path ] 1131 inputs += [ jar_path ]
1106 _rebased_jar_path = rebase_path([ jar_path ], root_build_dir) 1132 _rebased_jar_path = rebase_path([ jar_path ], root_build_dir)
1107 args += [ 1133 args += [
1108 "--inputs=$_rebased_jar_path", 1134 "--inputs=$_rebased_jar_path",
1109 ] 1135 ]
1110 } 1136 }
1111 } 1137 }
1112 1138
1113 final_deps += [":${_template_name}__final_dex"] 1139 final_deps += [":${_template_name}__final_dex"]
1114 dex("${_template_name}__final_dex") { 1140 dex("${_template_name}__final_dex") {
1115 deps = [ ":${_template_name}__java" ] 1141 deps = [ ":${_template_name}__java" ]
1116 sources = [ jar_path ] 1142 sources = [ jar_path ]
1117 inputs = [ build_config ] 1143 inputs = [ _build_config ]
1118 output = final_dex_path 1144 output = final_dex_path
1119 dex_arg_key = "${_rebased_build_config}:apk_dex:dependency_dex_files" 1145 dex_arg_key = "${_rebased_build_config}:apk_dex:dependency_dex_files"
1120 args = [ "--inputs=@FileArg($dex_arg_key)" ] 1146 args = [ "--inputs=@FileArg($dex_arg_key)" ]
1121 } 1147 }
1122 1148
1123 if (_native_libs != []) { 1149 if (_native_libs != []) {
1124 action("${_template_name}__prepare_native") { 1150 action("${_template_name}__prepare_native") {
1125 script = "//build/android/gyp/pack_arm_relocations.py" 1151 script = "//build/android/gyp/pack_arm_relocations.py"
1126 packed_libraries_dir = "$_native_libs_dir/$android_app_abi" 1152 packed_libraries_dir = "$_native_libs_dir/$android_app_abi"
1127 depfile = "$target_gen_dir/$target_name.d" 1153 depfile = "$target_gen_dir/$target_name.d"
1128 outputs = [ 1154 outputs = [
1129 depfile 1155 depfile
1130 ] 1156 ]
1131 inputs = [ 1157 inputs = [
1132 build_config 1158 _build_config
1133 ] 1159 ]
1134 deps = [] 1160 deps = []
1135 skip_packing_list = [ 1161 skip_packing_list = [
1136 "gdbserver", 1162 "gdbserver",
1137 "libchromium_android_linker.so", 1163 "libchromium_android_linker.so",
1138 ] 1164 ]
1139 1165
1140 enable_packing_arg = 0 1166 enable_packing_arg = 0
1141 if (_enable_relocation_packing) { 1167 if (_enable_relocation_packing) {
1142 enable_packing_arg = 1 1168 enable_packing_arg = 1
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 # Declare an Android gtest apk 1239 # Declare an Android gtest apk
1214 # 1240 #
1215 # This target creates an Android apk for running gtest-based unittests. 1241 # This target creates an Android apk for running gtest-based unittests.
1216 # 1242 #
1217 # Variables 1243 # Variables
1218 # deps: Specifies the dependencies of this target. These will be passed to 1244 # deps: Specifies the dependencies of this target. These will be passed to
1219 # the underlying android_apk invocation and should include the java and 1245 # the underlying android_apk invocation and should include the java and
1220 # resource dependencies of the apk. 1246 # resource dependencies of the apk.
1221 # unittests_dep: This should be the label of the gtest native target. This 1247 # unittests_dep: This should be the label of the gtest native target. This
1222 # target must be defined previously in the same file. 1248 # target must be defined previously in the same file.
1223 # unittests_binary: The name of the binary produced by the unittests_dep 1249 # unittests_binary: The basename of the library produced by the unittests_dep
1224 # target, relative to the root build directory. If unspecified, it assumes 1250 # target. If unspecified, it assumes the name of the unittests_dep target
1225 # the name of the unittests_dep target (which will be correct unless that 1251 # (which will be correct unless that target specifies an "output_name".
1226 # target specifies an "output_name".
1227 # TODO(brettw) make this automatic by allowing get_target_outputs to 1252 # TODO(brettw) make this automatic by allowing get_target_outputs to
1228 # support executables. 1253 # support executables.
1229 # 1254 #
1230 # Example 1255 # Example
1231 # unittest_apk("foo_unittests_apk") { 1256 # unittest_apk("foo_unittests_apk") {
1232 # deps = [ ":foo_java", ":foo_resources" ] 1257 # deps = [ ":foo_java", ":foo_resources" ]
1233 # unittests_dep = ":foo_unittests" 1258 # unittests_dep = ":foo_unittests"
1234 # } 1259 # }
1235 template("unittest_apk") { 1260 template("unittest_apk") {
1236 testonly = true 1261 testonly = true
1237 1262
1238 assert(defined(invoker.unittests_dep), "Need unittests_dep for $target_name") 1263 assert(defined(invoker.unittests_dep), "Need unittests_dep for $target_name")
1239 1264
1240 test_suite_name = get_label_info(invoker.unittests_dep, "name") 1265 test_suite_name = get_label_info(invoker.unittests_dep, "name")
1241 1266
1242 if (defined(invoker.unittests_binary)) { 1267 if (defined(invoker.unittests_binary)) {
1243 unittests_binary = root_out_dir + "/" + invoker.unittests_binary 1268 unittests_binary = invoker.unittests_binary
1244 } else { 1269 } else {
1245 unittests_binary = root_out_dir + "/lib.stripped/lib" + test_suite_name + ". so" 1270 unittests_binary = "lib" + test_suite_name + ".so"
1246 } 1271 }
1247 1272
1248 android_apk(target_name) { 1273 android_apk(target_name) {
1249 _apk_name = test_suite_name 1274 _apk_name = test_suite_name
1250 final_apk_path = "$root_build_dir/${_apk_name}_apk/${_apk_name}-debug.apk" 1275 final_apk_path = "$root_build_dir/${_apk_name}_apk/${_apk_name}-debug.apk"
1251 java_files = [ 1276 java_files = [
1252 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv ity.java" 1277 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv ity.java"
1253 ] 1278 ]
1254 android_manifest = "//testing/android/java/AndroidManifest.xml" 1279 android_manifest = "//testing/android/java/AndroidManifest.xml"
1255 unittests_outputs = [ unittests_binary ] 1280 native_libs = [ unittests_binary ]
1256 native_libs = [unittests_outputs[0]]
1257 deps = [ "//base:base_java" ] 1281 deps = [ "//base:base_java" ]
1258 if (defined(invoker.deps)) { 1282 if (defined(invoker.deps)) {
1259 deps += invoker.deps 1283 deps += invoker.deps
1260 } 1284 }
1261 datadeps = [ 1285 datadeps = [
1262 "//tools/android/forwarder2", 1286 "//tools/android/forwarder2",
1263 "//tools/android/md5sum", 1287 "//tools/android/md5sum",
1264 ] 1288 ]
1265 } 1289 }
1266 } 1290 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 } 1493 }
1470 1494
1471 # TODO(GYP): implement this. 1495 # TODO(GYP): implement this.
1472 template("uiautomator_test") { 1496 template("uiautomator_test") {
1473 if (defined(invoker.testonly)) { testonly = invoker.testonly } 1497 if (defined(invoker.testonly)) { testonly = invoker.testonly }
1474 assert(target_name != "") 1498 assert(target_name != "")
1475 assert(invoker.deps != [] || true) 1499 assert(invoker.deps != [] || true)
1476 group(target_name) { 1500 group(target_name) {
1477 } 1501 }
1478 } 1502 }
OLDNEW
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | build/config/compiler/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698