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

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

Issue 778093004: GN + Android: extract android_standalone_library rule. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Chris's comments. Created 6 years 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 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)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 "--enable", 59 "--enable",
60 ] 60 ]
61 } 61 }
62 } 62 }
63 63
64 template("dex") { 64 template("dex") {
65 if (defined(invoker.testonly)) { 65 if (defined(invoker.testonly)) {
66 testonly = invoker.testonly 66 testonly = invoker.testonly
67 } 67 }
68 68
69 assert(defined(invoker.sources))
70 assert(defined(invoker.output)) 69 assert(defined(invoker.output))
71 action(target_name) { 70 action(target_name) {
72 script = "//build/android/gyp/dex.py" 71 script = "//build/android/gyp/dex.py"
73 depfile = "$target_gen_dir/$target_name.d" 72 depfile = "$target_gen_dir/$target_name.d"
74 sources = invoker.sources 73 if (defined(invoker.sources)) {
74 sources = invoker.sources
75 }
75 outputs = [ 76 outputs = [
76 depfile, 77 depfile,
77 invoker.output, 78 invoker.output,
78 ] 79 ]
79 if (defined(invoker.inputs)) { 80 if (defined(invoker.inputs)) {
80 inputs = invoker.inputs 81 inputs = invoker.inputs
81 } 82 }
82 83
83 if (defined(invoker.deps)) { 84 if (defined(invoker.deps)) {
84 deps = invoker.deps 85 deps = invoker.deps
(...skipping 11 matching lines...) Expand all
96 ] 97 ]
97 98
98 if (defined(invoker.no_locals) && invoker.no_locals) { 99 if (defined(invoker.no_locals) && invoker.no_locals) {
99 args += [ "--no-locals=1" ] 100 args += [ "--no-locals=1" ]
100 } 101 }
101 102
102 if (defined(invoker.args)) { 103 if (defined(invoker.args)) {
103 args += invoker.args 104 args += invoker.args
104 } 105 }
105 106
106 args += rebase_path(invoker.sources, root_build_dir) 107 if (defined(invoker.sources)) {
108 args += rebase_path(invoker.sources, root_build_dir)
109 }
107 } 110 }
108 } 111 }
109 112
110 # Creates a zip archive of the inputs. 113 # Creates a zip archive of the inputs.
111 # If base_dir is provided, the archive paths will be relative to it. 114 # If base_dir is provided, the archive paths will be relative to it.
112 template("zip") { 115 template("zip") {
113 if (defined(invoker.testonly)) { 116 if (defined(invoker.testonly)) {
114 testonly = invoker.testonly 117 testonly = invoker.testonly
115 } 118 }
116 119
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 testonly = invoker.testonly 159 testonly = invoker.testonly
157 } 160 }
158 161
159 assert(defined(invoker.type)) 162 assert(defined(invoker.type))
160 assert(defined(invoker.build_config)) 163 assert(defined(invoker.build_config))
161 164
162 type = invoker.type 165 type = invoker.type
163 build_config = invoker.build_config 166 build_config = invoker.build_config
164 167
165 assert(type == "android_apk" || type == "java_library" || 168 assert(type == "android_apk" || type == "java_library" ||
166 type == "android_resources") 169 type == "android_resources" || type == "deps_dex")
167 170
168 action(target_name) { 171 action(target_name) {
169 script = "//build/android/gyp/write_build_config.py" 172 script = "//build/android/gyp/write_build_config.py"
170 depfile = "$target_gen_dir/$target_name.d" 173 depfile = "$target_gen_dir/$target_name.d"
171 inputs = [] 174 inputs = []
172 175
173 deps = [] 176 deps = []
174 if (defined(invoker.deps)) { 177 if (defined(invoker.deps)) {
175 deps += invoker.deps 178 deps += invoker.deps
176 } 179 }
(...skipping 17 matching lines...) Expand all
194 "--depfile", 197 "--depfile",
195 rebase_path(depfile, root_build_dir), 198 rebase_path(depfile, root_build_dir),
196 "--possible-deps-configs=$rebase_possible_deps_configs", 199 "--possible-deps-configs=$rebase_possible_deps_configs",
197 "--build-config", 200 "--build-config",
198 rebase_path(build_config, root_build_dir), 201 rebase_path(build_config, root_build_dir),
199 ] 202 ]
200 203
201 is_java_library = type == "java_library" 204 is_java_library = type == "java_library"
202 is_apk = type == "android_apk" 205 is_apk = type == "android_apk"
203 is_android_resources = type == "android_resources" 206 is_android_resources = type == "android_resources"
207 is_deps_dex = type == "deps_dex"
204 208
205 supports_android = is_apk || is_android_resources || 209 supports_android = is_apk || is_android_resources || is_deps_dex ||
206 (is_java_library && defined(invoker.supports_android) && 210 (is_java_library && defined(invoker.supports_android) &&
207 invoker.supports_android) 211 invoker.supports_android)
208 requires_android = is_apk || is_android_resources || 212 requires_android = is_apk || is_android_resources || is_deps_dex ||
209 (is_java_library && defined(invoker.requires_android) && 213 (is_java_library && defined(invoker.requires_android) &&
210 invoker.requires_android) 214 invoker.requires_android)
211 215
212 assert(!requires_android || supports_android, 216 assert(!requires_android || supports_android,
213 "requires_android requires" + " supports_android") 217 "requires_android requires" + " supports_android")
214 218
215 # Mark these variables as used. 219 # Mark these variables as used.
216 assert(is_java_library || true) 220 assert(is_java_library || true)
217 assert(is_apk || true) 221 assert(is_apk || true)
218 assert(is_android_resources || true) 222 assert(is_android_resources || true)
223 assert(is_deps_dex || true)
219 224
220 if (is_java_library || is_apk) { 225 if (is_java_library || is_apk) {
221 args += [ 226 args += [
222 "--jar-path", 227 "--jar-path",
223 rebase_path(invoker.jar_path, root_build_dir), 228 rebase_path(invoker.jar_path, root_build_dir),
224 ] 229 ]
225 } 230 }
226 231
227 if (is_apk || (is_java_library && supports_android)) { 232 if (is_apk || is_deps_dex || (is_java_library && supports_android)) {
228 args += [ 233 args += [
229 "--dex-path", 234 "--dex-path",
230 rebase_path(invoker.dex_path, root_build_dir), 235 rebase_path(invoker.dex_path, root_build_dir),
231 ] 236 ]
232 } 237 }
233 if (supports_android) { 238 if (supports_android) {
234 args += [ "--supports-android" ] 239 args += [ "--supports-android" ]
235 } 240 }
236 if (requires_android) { 241 if (requires_android) {
237 args += [ "--requires-android" ] 242 args += [ "--requires-android" ]
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 } 896 }
892 } 897 }
893 898
894 _final_deps += [ ":${_template_name}__dex" ] 899 _final_deps += [ ":${_template_name}__dex" ]
895 dex("${_template_name}__dex") { 900 dex("${_template_name}__dex") {
896 sources = [ 901 sources = [
897 _jar_path, 902 _jar_path,
898 ] 903 ]
899 output = _dex_path 904 output = _dex_path
900 } 905 }
901
902 if (defined(invoker.standalone_dex_path)) {
903 _final_deps += [ ":${_template_name}__standalone_dex" ]
904 _rebased_build_config = rebase_path(_build_config, root_build_dir)
905 dex("${_template_name}__standalone_dex") {
906 sources = [
907 _jar_path,
908 ]
909 inputs = [
910 _build_config,
911 ]
912 output = invoker.standalone_dex_path
913 dex_arg_key = "${_rebased_build_config}:final_dex:dependency_dex_files"
914 args = [ "--inputs=@FileArg($dex_arg_key)" ]
915 }
916 }
917 } 906 }
918 907
919 group(target_name) { 908 group(target_name) {
920 if (defined(invoker.visibility)) { 909 if (defined(invoker.visibility)) {
921 visibility = invoker.visibility 910 visibility = invoker.visibility
922 } 911 }
923 deps = _final_deps 912 deps = _final_deps
924 datadeps = _final_datadeps 913 datadeps = _final_datadeps
925 } 914 }
926 } 915 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 1043
1055 if (defined(invoker.clear_dir) && invoker.clear_dir) { 1044 if (defined(invoker.clear_dir) && invoker.clear_dir) {
1056 args += [ "--clear" ] 1045 args += [ "--clear" ]
1057 } 1046 }
1058 1047
1059 if (defined(invoker.args)) { 1048 if (defined(invoker.args)) {
1060 args += invoker.args 1049 args += invoker.args
1061 } 1050 }
1062 } 1051 }
1063 } 1052 }
1053
1054 # Produces a single .dex.jar out of a set of Java dependencies.
1055 template("deps_dex") {
1056 build_config = "$target_gen_dir/${target_name}.build_config"
1057 write_build_config("${target_name}__build_config") {
1058 type = "deps_dex"
1059 deps = invoker.deps
1060
1061 build_config = build_config
1062 dex_path = invoker.standalone_dex_path
1063 }
1064
1065 rebased_build_config = rebase_path(build_config, root_build_dir)
1066 dex(target_name) {
1067 inputs = [
1068 build_config,
1069 ]
1070 output = invoker.standalone_dex_path
1071 dex_arg_key = "${rebased_build_config}:final_dex:dependency_dex_files"
1072 args = [ "--inputs=@FileArg($dex_arg_key)" ]
1073 }
1074 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698