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

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

Issue 670183003: Update from chromium 62675d9fb31fb8cedc40f68e78e8445a74f362e7 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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 | « build/config/android/internal_rules.gni ('k') | build/config/features.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("//base/android/linker/config.gni")
5 import("//build/config/android/config.gni") 6 import("//build/config/android/config.gni")
6 import("//build/config/android/internal_rules.gni") 7 import("//build/config/android/internal_rules.gni")
7 import("//tools/grit/grit_rule.gni") 8 import("//tools/grit/grit_rule.gni")
9 import("//tools/relocation_packer/config.gni")
8 10
9 assert(is_android) 11 assert(is_android)
10 12
11
12 # Declare a jni target 13 # Declare a jni target
13 # 14 #
14 # This target generates the native jni bindings for a set of .java files. 15 # This target generates the native jni bindings for a set of .java files.
15 # 16 #
16 # See base/android/jni_generator/jni_generator.py for more info about the 17 # See base/android/jni_generator/jni_generator.py for more info about the
17 # format of generating JNI bindings. 18 # format of generating JNI bindings.
18 # 19 #
19 # Variables 20 # Variables
20 # sources: list of .java files to generate jni for 21 # sources: list of .java files to generate jni for
21 # jni_package: subdirectory path for generated bindings 22 # jni_package: subdirectory path for generated bindings
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (defined(invoker.public_deps)) { 180 if (defined(invoker.public_deps)) {
180 public_deps = invoker.public_deps 181 public_deps = invoker.public_deps
181 } 182 }
182 public_configs = [ ":jni_includes_${target_name}" ] 183 public_configs = [ ":jni_includes_${target_name}" ]
183 } 184 }
184 } 185 }
185 186
186 187
187 # Declare a target for c-preprocessor-generated java files 188 # Declare a target for c-preprocessor-generated java files
188 # 189 #
190 # NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum
191 # rule instead.
192 #
189 # This target generates java files using the host C pre-processor. Each file in 193 # This target generates java files using the host C pre-processor. Each file in
190 # sources will be compiled using the C pre-processor. If include_path is 194 # sources will be compiled using the C pre-processor. If include_path is
191 # specified, it will be passed (with --I) to the pre-processor. 195 # specified, it will be passed (with --I) to the pre-processor.
192 # 196 #
193 # This target will create a single .srcjar. Adding this target to an 197 # This target will create a single .srcjar. Adding this target to an
194 # android_library target's srcjar_deps will make the generated java files be 198 # android_library target's srcjar_deps will make the generated java files be
195 # included in that library's final outputs. 199 # included in that library's final outputs.
196 # 200 #
197 # Variables 201 # Variables
198 # sources: list of files to be processed by the C pre-processor. For each 202 # sources: list of files to be processed by the C pre-processor. For each
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 729
726 if (defined(invoker.srcjar_deps)) { 730 if (defined(invoker.srcjar_deps)) {
727 srcjar_deps = invoker.srcjar_deps 731 srcjar_deps = invoker.srcjar_deps
728 } 732 }
729 if (defined(invoker.srcjars)) { 733 if (defined(invoker.srcjars)) {
730 srcjars = invoker.srcjars 734 srcjars = invoker.srcjars
731 } 735 }
732 } 736 }
733 } 737 }
734 738
739 template("java_library") {
740 if (defined(invoker.testonly)) { testonly = invoker.testonly }
741
742 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
743 || defined(invoker.srcjars))
744
745 _srcjar_deps = []
746 if (defined(invoker.srcjar_deps)) {
747 _srcjar_deps = invoker.srcjar_deps
748 }
749
750 _srcjars = []
751 if (defined(invoker.srcjars)) {
752 _srcjars = invoker.srcjars
753 }
754
755 _java_files = []
756 if (defined(invoker.java_files)) {
757 _java_files = invoker.java_files
758 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
759 _src_dir = invoker.DEPRECATED_java_in_dir + "/src"
760 _src_dir_exists = exec_script("//build/dir_exists.py",
761 [ rebase_path(_src_dir, root_build_dir) ],
762 "string")
763 assert(_src_dir_exists == "False",
764 "In GN, java_in_dir should be the fully specified java directory " +
765 "(i.e. including the trailing \"/src\")")
766
767 _java_files_build_rel = exec_script(
768 "//build/android/gyp/find.py",
769 [
770 "--pattern",
771 "*.java",
772 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir)
773 ],
774 "list lines"
775 )
776 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
777 }
778 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
779
780 # TODO(cjhopman): Write a proper build config so that java library
781 # dependencies work correctly.
782 _build_config = "$target_gen_dir/$target_name.build_config"
783 write_file(
784 _build_config,
785 "{ \"javac\": { \"classpath\": [], \"srcjars\": [] } }")
786
787 _jar_path = "$root_build_dir/lib.java/$target_name.jar"
788 if (defined(invoker.jar_path)) {
789 _jar_path = invoker.jar_path
790 }
791
792 compile_java(target_name) {
793 build_config = _build_config
794 jar_path = _jar_path
795 java_files = _java_files
796 srcjar_deps = _srcjar_deps
797 srcjars = _srcjars
798 }
799 }
800
735 801
736 # Declare an Android library target for a prebuilt jar 802 # Declare an Android library target for a prebuilt jar
737 # 803 #
738 # This target creates an Android library containing java code and Android 804 # This target creates an Android library containing java code and Android
739 # resources. 805 # resources.
740 # 806 #
741 # Variables 807 # Variables
742 # deps: Specifies the dependencies of this target. Java targets in this list 808 # deps: Specifies the dependencies of this target. Java targets in this list
743 # will be added to the javac classpath. Android resources in dependencies 809 # will be added to the javac classpath. Android resources in dependencies
744 # will be used when building this library. 810 # will be used when building this library.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 } else if (defined(invoker.apk_name)) { 934 } else if (defined(invoker.apk_name)) {
869 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk" 935 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk"
870 } 936 }
871 _dist_jar_path_list = process_file_template( 937 _dist_jar_path_list = process_file_template(
872 [ _final_apk_path ], 938 [ _final_apk_path ],
873 "$root_build_dir/test.lib.java/{{source_name_part}}.jar" 939 "$root_build_dir/test.lib.java/{{source_name_part}}.jar"
874 ) 940 )
875 _dist_jar_path = _dist_jar_path_list[0] 941 _dist_jar_path = _dist_jar_path_list[0]
876 942
877 _native_libs = [] 943 _native_libs = []
944
945 _keystore_path = android_default_keystore_path
946 _keystore_name = android_default_keystore_name
947 _keystore_password = android_default_keystore_password
948
949 if (defined(invoker.keystore_path)) {
950 _keystore_path = invoker.keystore_path
951 _keystore_name = invoker.keystore_name
952 _keystore_password = invoker.keystore_password
953 }
954
955 _srcjar_deps = []
956 if (defined(invoker.srcjar_deps)) {
957 _srcjar_deps += invoker.srcjar_deps
958 }
959
960 _load_library_from_apk = false
961
878 if (defined(invoker.native_libs)) { 962 if (defined(invoker.native_libs)) {
879 _use_chromium_linker = false 963 _use_chromium_linker = false
880 if (defined(invoker.use_chromium_linker)) { 964 if (defined(invoker.use_chromium_linker)) {
881 _use_chromium_linker = invoker.use_chromium_linker 965 _use_chromium_linker = (invoker.use_chromium_linker &&
966 chromium_linker_supported)
882 } 967 }
883 968
884 # TODO(GYP) add "|| profiling_full_stack_frames 969 if (defined(invoker.load_library_from_apk) &&
885 # Only enable the chromium linker on regular builds, since the 970 invoker.load_library_from_apk) {
886 # component build crashes on Android 4.4. See b/11379966 971 _load_library_from_apk = true
887 if (is_component_build || cpu_arch == "arm64" || cpu_arch == "x64") { 972 assert(_use_chromium_linker, "Loading library from the apk requires use" +
888 _use_chromium_linker = false 973 " of the Chromium linker.")
974 }
975
976 _enable_relocation_packing = false
977 if (defined(invoker.enable_relocation_packing) &&
978 invoker.enable_relocation_packing) {
979 _enable_relocation_packing = relocation_packing_supported
980 assert(_use_chromium_linker, "Relocation packing requires use of the" +
981 " Chromium linker.")
889 } 982 }
890 983
891 _native_libs = invoker.native_libs 984 _native_libs = invoker.native_libs
892 _native_libs_dir = base_path + "/libs" 985 _native_libs_dir = base_path + "/libs"
893 986
894 if (_use_chromium_linker) { 987 if (_use_chromium_linker) {
895 _native_libs += [ 988 _native_libs += [
896 "$root_build_dir/lib.stripped/libchromium_android_linker.so" 989 "$root_build_dir/lib.stripped/libchromium_android_linker.so"
897 ] 990 ]
898 } 991 }
899 } 992 }
900 993
901 _keystore_path = android_default_keystore_path
902 _keystore_name = android_default_keystore_name
903 _keystore_password = android_default_keystore_password
904
905 if (defined(invoker.keystore_path)) {
906 _keystore_path = invoker.keystore_path
907 _keystore_name = invoker.keystore_name
908 _keystore_password = invoker.keystore_password
909 }
910
911 _srcjar_deps = []
912 if (defined(invoker.srcjar_deps)) {
913 _srcjar_deps += invoker.srcjar_deps
914 }
915
916 _rebased_build_config = rebase_path(build_config, root_build_dir) 994 _rebased_build_config = rebase_path(build_config, root_build_dir)
917 995
918 write_build_config("${_template_name}__build_config") { 996 write_build_config("${_template_name}__build_config") {
919 type = "android_apk" 997 type = "android_apk"
920 dex_path = final_dex_path 998 dex_path = final_dex_path
921 resources_zip = resources_zip_path 999 resources_zip = resources_zip_path
922 1000
923 if (defined(invoker.deps)) { 1001 if (defined(invoker.deps)) {
924 deps = invoker.deps 1002 deps = invoker.deps
925 } 1003 }
(...skipping 12 matching lines...) Expand all
938 generate_constant_ids = true 1016 generate_constant_ids = true
939 } 1017 }
940 _srcjar_deps += [":${_template_name}__process_resources"] 1018 _srcjar_deps += [":${_template_name}__process_resources"]
941 1019
942 if (_native_libs != []) { 1020 if (_native_libs != []) {
943 _enable_chromium_linker_tests = false 1021 _enable_chromium_linker_tests = false
944 if (defined(invoker.enable_chromium_linker_tests)) { 1022 if (defined(invoker.enable_chromium_linker_tests)) {
945 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests 1023 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
946 } 1024 }
947 1025
948 _load_library_from_apk = false
949 _native_lib_version_name = "" 1026 _native_lib_version_name = ""
950 1027
951 java_cpp_template("${_template_name}__native_libraries_java") { 1028 java_cpp_template("${_template_name}__native_libraries_java") {
952 package_name = "org/chromium/base/library_loader" 1029 package_name = "org/chromium/base/library_loader"
953 sources = [ 1030 sources = [
954 "//base/android/java/templates/NativeLibraries.template", 1031 "//base/android/java/templates/NativeLibraries.template",
955 ] 1032 ]
956 inputs = [ 1033 inputs = [
957 build_config, 1034 build_config,
958 ] 1035 ]
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 dex("${_template_name}__final_dex") { 1095 dex("${_template_name}__final_dex") {
1019 deps = [ ":${_template_name}__java" ] 1096 deps = [ ":${_template_name}__java" ]
1020 sources = [ jar_path ] 1097 sources = [ jar_path ]
1021 inputs = [ build_config ] 1098 inputs = [ build_config ]
1022 output = final_dex_path 1099 output = final_dex_path
1023 dex_arg_key = "${_rebased_build_config}:apk_dex:dependency_dex_files" 1100 dex_arg_key = "${_rebased_build_config}:apk_dex:dependency_dex_files"
1024 args = [ "--inputs=@FileArg($dex_arg_key)" ] 1101 args = [ "--inputs=@FileArg($dex_arg_key)" ]
1025 } 1102 }
1026 1103
1027 if (_native_libs != []) { 1104 if (_native_libs != []) {
1028 copy_ex("${_template_name}__prepare_native") { 1105 action("${_template_name}__prepare_native") {
1029 clear_dir = true 1106 script = "//build/android/gyp/pack_arm_relocations.py"
1107 packed_libraries_dir = "$_native_libs_dir/$android_app_abi"
1108 depfile = "$target_gen_dir/$target_name.d"
1109 outputs = [
1110 depfile
1111 ]
1030 inputs = [ 1112 inputs = [
1031 build_config 1113 build_config
1032 ] 1114 ]
1033 dest = "$_native_libs_dir/$android_app_abi" 1115 deps = []
1116 skip_packing_list = [
1117 "gdbserver",
1118 "libchromium_android_linker.so",
1119 ]
1120
1121 enable_packing_arg = 0
1122 if (_enable_relocation_packing) {
1123 enable_packing_arg = 1
1124 deps += [
1125 relocation_packer_target
1126 ]
1127 }
1128
1034 args = [ 1129 args = [
1035 "--files=@FileArg(${_rebased_build_config}:native:libraries)", 1130 "--depfile", rebase_path(depfile, root_build_dir),
1131 "--enable-packing=$enable_packing_arg",
1132 "--has-relocations-with-addends=$relocations_have_addends",
1133 "--exclude-packing-list=$skip_packing_list",
1134 "--android-pack-relocations", rebase_path(relocation_packer_exe, root_bu ild_dir),
1135 "--android-objcopy", rebase_path(android_objcopy, root_build_dir),
1136 "--stripped-libraries-dir", rebase_path(root_build_dir, root_build_dir),
1137 "--packed-libraries-dir", rebase_path(packed_libraries_dir, root_build_d ir),
1138 "--libraries=@FileArg(${_rebased_build_config}:native:libraries)",
1139 "--clear-dir"
1036 ] 1140 ]
1141
1037 if (is_debug) { 1142 if (is_debug) {
1038 rebased_gdbserver = rebase_path(android_gdbserver, root_build_dir) 1143 rebased_gdbserver = rebase_path([ android_gdbserver ], root_build_dir)
1144 inputs += [ android_gdbserver ]
1039 args += [ 1145 args += [
1040 "--files=[\"$rebased_gdbserver\"]" 1146 "--libraries=$rebased_gdbserver"
1041 ] 1147 ]
1042 } 1148 }
1043 } 1149 }
1044 } 1150 }
1045 1151
1046 final_deps += [":${_template_name}__create"] 1152 final_deps += [":${_template_name}__create"]
1047 create_apk("${_template_name}__create") { 1153 create_apk("${_template_name}__create") {
1048 apk_path = _final_apk_path 1154 apk_path = _final_apk_path
1049 android_manifest = invoker.android_manifest 1155 android_manifest = invoker.android_manifest
1050 resources_zip = all_resources_zip_path 1156 resources_zip = all_resources_zip_path
1051 dex_path = final_dex_path 1157 dex_path = final_dex_path
1158 load_library_from_apk = _load_library_from_apk
1052 1159
1053 if (defined(invoker.asset_location)) { 1160 if (defined(invoker.asset_location)) {
1054 asset_location = invoker.asset_location 1161 asset_location = invoker.asset_location
1055 } 1162 }
1056 1163
1057 keystore_name = _keystore_name 1164 keystore_name = _keystore_name
1058 keystore_path = _keystore_path 1165 keystore_path = _keystore_path
1059 keystore_password = _keystore_password 1166 keystore_password = _keystore_password
1060 1167
1061 if (_native_libs != []) { 1168 if (_native_libs != []) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 } 1439 }
1333 1440
1334 # TODO(GYP): implement this. 1441 # TODO(GYP): implement this.
1335 template("uiautomator_test") { 1442 template("uiautomator_test") {
1336 if (defined(invoker.testonly)) { testonly = invoker.testonly } 1443 if (defined(invoker.testonly)) { testonly = invoker.testonly }
1337 assert(target_name != "") 1444 assert(target_name != "")
1338 assert(invoker.deps != [] || true) 1445 assert(invoker.deps != [] || true)
1339 group(target_name) { 1446 group(target_name) {
1340 } 1447 }
1341 } 1448 }
OLDNEW
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | build/config/features.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698