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

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

Issue 379333003: Add beginnings of android_apk and unittest_apk templates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-filearg
Patch Set: 80-column lines Created 6 years, 5 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
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 9
10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) 10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
11 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) 11 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir)
12 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil d_dir) 12 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil d_dir)
13 13
14 14
15 # Write the target's .build_config file. This is a json file that contains a 15 # Write the target's .build_config file. This is a json file that contains a
16 # dictionary of information about how to build this target (things that 16 # dictionary of information about how to build this target (things that
17 # require knowledge about this target's dependencies and cannot be calculated 17 # require knowledge about this target's dependencies and cannot be calculated
18 # at gn-time). There is a special syntax to add a value in that dictionary to 18 # at gn-time). There is a special syntax to add a value in that dictionary to
19 # an action/action_foreachs args: 19 # an action/action_foreachs args:
20 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) 20 # --python-arg=@FileArg($rebased_build_config_path:key0:key1)
21 # At runtime, such an arg will be replaced by the value in the build_config. 21 # At runtime, such an arg will be replaced by the value in the build_config.
22 # See build/android/gyp/write_build_config.py and 22 # See build/android/gyp/write_build_config.py and
23 # build/android/gyp/util/build_utils.py:ExpandFileArgs 23 # build/android/gyp/util/build_utils.py:ExpandFileArgs
24 template("write_build_config") { 24 template("write_build_config") {
25 assert(defined(invoker.type)) 25 assert(defined(invoker.type))
26 assert(defined(invoker.base_path)) 26 assert(defined(invoker.build_config))
27 27
28 base_path = invoker.base_path
29 type = invoker.type 28 type = invoker.type
30 build_config = base_path + ".build_config" 29 build_config = invoker.build_config
31 30
32 assert(type == "android_binary" || type == "android_library" || type == "andro id_resources") 31 assert(type == "android_apk" || type == "android_library" || type == "android_ resources")
33 32
34 action(target_name) { 33 action(target_name) {
35 script = "//build/android/gyp/write_build_config.py" 34 script = "//build/android/gyp/write_build_config.py"
36 depfile = "$target_gen_dir/$target_name.d" 35 depfile = "$target_gen_dir/$target_name.d"
37 36
38 deps = [] 37 deps = []
39 if (defined(invoker.deps)) { 38 if (defined(invoker.deps)) {
40 deps += invoker.deps 39 deps += invoker.deps
41 } 40 }
42 41
43 outputs = [ 42 outputs = [
44 depfile, 43 depfile,
45 build_config 44 build_config
46 ] 45 ]
47 46
48 possible_deps_configs = [] 47 possible_deps_configs = []
49 foreach(d, deps) { 48 foreach(d, deps) {
50 dep_gen_dir = get_label_info(d, "target_gen_dir") 49 dep_gen_dir = get_label_info(d, "target_gen_dir")
51 dep_name = get_label_info(d, "name") 50 dep_name = get_label_info(d, "name")
52 possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ] 51 possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ]
53 } 52 }
54 rebase_possible_deps_configs = rebase_path(possible_deps_configs) 53 rebase_possible_deps_configs = rebase_path(possible_deps_configs)
54
55 args = [ 55 args = [
56 "--type", type, 56 "--type", type,
57 "--depfile", rebase_path(depfile, root_build_dir), 57 "--depfile", rebase_path(depfile, root_build_dir),
58 "--possible-deps-configs=$rebase_possible_deps_configs", 58 "--possible-deps-configs=$rebase_possible_deps_configs",
59 "--build-config", rebase_path(build_config, root_build_dir), 59 "--build-config", rebase_path(build_config, root_build_dir),
60 ] 60 ]
61 61
62 if (type == "android_library") { 62 if (type == "android_library" || type == "android_apk") {
63 jar_path = base_path + ".jar"
64 args += [ 63 args += [
65 "--jar-path", rebase_path(jar_path, root_build_dir), 64 "--jar-path", rebase_path(invoker.jar_path, root_build_dir),
66 ] 65 ]
67 } 66 }
68 67
69 if (type == "android_resources") { 68 if (type == "android_resources" || type == "android_apk") {
70 assert(defined(invoker.resources_zip)) 69 assert(defined(invoker.resources_zip))
71 args += [ 70 args += [
72 "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir), 71 "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir),
73 ] 72 ]
74 if (defined(invoker.srcjar)) { 73 }
75 args += [ 74
76 "--srcjar", rebase_path(invoker.srcjar, root_build_dir) 75 if (defined(invoker.srcjar)) {
77 ] 76 args += [
78 } 77 "--srcjar", rebase_path(invoker.srcjar, root_build_dir)
78 ]
79 } 79 }
80 } 80 }
81 } 81 }
82 82
83 83
84 # Creates a zip archive of the inputs. 84 # Creates a zip archive of the inputs.
85 # If base_dir is provided, the archive paths will be relative to it. 85 # If base_dir is provided, the archive paths will be relative to it.
86 template("zip") { 86 template("zip") {
87 assert(defined(invoker.inputs)) 87 assert(defined(invoker.inputs))
88 assert(defined(invoker.output)) 88 assert(defined(invoker.output))
(...skipping 14 matching lines...) Expand all
103 "--output=$rebase_output", 103 "--output=$rebase_output",
104 ] 104 ]
105 if (defined(invoker.base_dir)) { 105 if (defined(invoker.base_dir)) {
106 args += [ 106 args += [
107 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) 107 "--base-dir", rebase_path(invoker.base_dir, root_build_dir)
108 ] 108 ]
109 } 109 }
110 } 110 }
111 } 111 }
112 112
113
114 # Compiles and jars a set of java files. 113 # Compiles and jars a set of java files.
115 # 114 #
116 # Outputs: 115 # Outputs:
117 # $jar_path.jar 116 # $jar_path.jar
118 # $jar_path.jar.TOC 117 # $jar_path.jar.TOC
119 # 118 #
120 # Variables 119 # Variables
121 # java_files: List of .java files to compile. 120 # java_files: List of .java files to compile.
122 # java_deps: List of java dependencies. These should all have a .jar output 121 # java_deps: List of java dependencies. These should all have a .jar output
123 # at "${target_gen_dir}/${target_name}.jar. 122 # at "${target_gen_dir}/${target_name}.jar.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 221 }
223 } 222 }
224 223
225 224
226 # This adds Android-specific parts to the java_library template. 225 # This adds Android-specific parts to the java_library template.
227 # 226 #
228 # Runs Android lint against the compiled java files. 227 # Runs Android lint against the compiled java files.
229 # Dexes the output jar for inclusion in an APK. 228 # Dexes the output jar for inclusion in an APK.
230 template("android_java_library") { 229 template("android_java_library") {
231 assert(defined(invoker.java_files)) 230 assert(defined(invoker.java_files))
232
233 assert(defined(invoker.build_config)) 231 assert(defined(invoker.build_config))
234 assert(defined(invoker.jar_path)) 232 assert(defined(invoker.jar_path))
235 233
234 jar_path = invoker.jar_path
newt (away) 2014/07/17 20:11:47 is jar_path still visible to the java_library temp
cjhopman 2014/07/18 00:58:01 It is. As discussed, I've changed it to make it mo
235
236 java_library("${target_name}__java_library") { 236 java_library("${target_name}__java_library") {
237 if (defined(invoker.jar_excluded_patterns)) { 237 if (defined(invoker.jar_excluded_patterns)) {
238 jar_excluded_patterns = invoker.jar_excluded_patterns 238 jar_excluded_patterns = invoker.jar_excluded_patterns
239 } 239 }
240 build_config = invoker.build_config 240 build_config = invoker.build_config
241 java_files = invoker.java_files 241 java_files = invoker.java_files
242 jar_path = invoker.jar_path
243 242
244 if (defined(invoker.srcjar_deps)) { 243 if (defined(invoker.srcjar_deps)) {
245 srcjar_deps = invoker.srcjar_deps 244 srcjar_deps = invoker.srcjar_deps
246 } 245 }
247 } 246 }
248 247
249 # TODO(cjhopman): lint 248 # TODO(cjhopman): lint
250 # TODO(cjhopman): dex 249 # TODO(cjhopman): dex
251 250
252 group(target_name) { 251 group(target_name) {
253 deps = [ 252 deps = [
254 ":${target_name}__java_library" 253 ":${target_name}__java_library"
255 ] 254 ]
256 } 255 }
257 } 256 }
258 257
259 258
260 # Runs process_resources.py 259 # Runs process_resources.py
261 template("process_resources") { 260 template("process_resources") {
262 zip_path = invoker.zip_path 261 zip_path = invoker.zip_path
263 srcjar_path = invoker.srcjar_path 262 srcjar_path = invoker.srcjar_path
264 build_config = invoker.build_config 263 build_config = invoker.build_config
265 resource_dirs = invoker.resource_dirs 264 resource_dirs = invoker.resource_dirs
266 android_manifest = invoker.android_manifest 265 android_manifest = invoker.android_manifest
267 266
267 non_constant_id = true
268 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) {
269 non_constant_id = false
270 }
271
268 action(target_name) { 272 action(target_name) {
269 script = "//build/android/gyp/process_resources.py" 273 script = "//build/android/gyp/process_resources.py"
270 274
271 depfile = "$target_gen_dir/$target_name.d" 275 depfile = "$target_gen_dir/$target_name.d"
272 outputs = [ 276 outputs = [
273 depfile, 277 depfile,
274 zip_path, 278 zip_path,
275 srcjar_path, 279 srcjar_path,
276 ] 280 ]
277 281
278 sources_build_rel = exec_script( 282 sources_build_rel = exec_script(
279 "//build/android/gyp/find.py", 283 "//build/android/gyp/find.py",
280 rebase_path(resource_dirs, root_build_dir), 284 rebase_path(resource_dirs, root_build_dir),
281 "list lines" 285 "list lines"
282 ) 286 )
283 sources = rebase_path(sources_build_rel, ".", root_build_dir) 287 sources = rebase_path(sources_build_rel, ".", root_build_dir)
284 288
285 source_prereqs = [ 289 source_prereqs = [
286 build_config, 290 build_config,
287 android_manifest, 291 android_manifest,
288 ] 292 ]
289 293
290 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir) 294 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir)
291 rebase_build_config = rebase_path(build_config, root_build_dir) 295 rebase_build_config = rebase_path(build_config, root_build_dir)
292 args = [ 296 args = [
293 "--depfile", rebase_path(depfile, root_build_dir), 297 "--depfile", rebase_path(depfile, root_build_dir),
294 "--android-sdk", rebase_path(android_sdk, root_build_dir), 298 "--android-sdk", rebase_path(android_sdk, root_build_dir),
295 "--android-sdk-tools", rebase_path(android_sdk_build_tools, root_build_dir ), 299 "--android-sdk-tools", rebase_path(android_sdk_build_tools, root_build_dir ),
296 "--non-constant-id",
297 "--android-manifest", rebase_path(android_manifest, root_build_dir), 300 "--android-manifest", rebase_path(android_manifest, root_build_dir),
298 301
299 "--resource-dirs=$rebase_resource_dirs", 302 "--resource-dirs=$rebase_resource_dirs",
300 "--srcjar-out", rebase_path(srcjar_path, root_build_dir), 303 "--srcjar-out", rebase_path(srcjar_path, root_build_dir),
301 "--resource-zip-out", rebase_path(zip_path, root_build_dir), 304 "--resource-zip-out", rebase_path(zip_path, root_build_dir),
302 305
303 "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependenc y_zips)", 306 "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependenc y_zips)",
304 ] 307 ]
305 308
309 if (non_constant_id) {
310 args += [ "--non-constant-id" ]
311 }
312
306 if (defined(invoker.custom_package)) { 313 if (defined(invoker.custom_package)) {
307 args += [ 314 args += [
308 "--custom-package", invoker.custom_package, 315 "--custom-package", invoker.custom_package,
309 ] 316 ]
310 } 317 }
311 318
312 if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) { 319 if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) {
313 args += ["--v14-verify-only"] 320 args += ["--v14-verify-only"]
314 } 321 }
322
323 if (defined(invoker.all_resources_zip_path)) {
324 all_resources_zip = invoker.all_resources_zip_path
325 outputs += [ all_resources_zip ]
326 args += [
327 "--all-resources-zip-out", rebase_path(all_resources_zip, root_build_dir )
328 ]
329 }
330
331 if (defined(invoker.args)) {
332 args += invoker.args
333 }
315 } 334 }
316 } 335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698