Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / build / config / android / internal_rules.gni
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
3 # found in the LICENSE file.
4
5 import("//build/config/android/config.gni")
6
7 assert(is_android)
8
9
10 rebased_android_sdk = rebase_path(android_sdk, 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_build_dir)
13
14 android_sdk_jar = "$android_sdk/android.jar"
15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
16
17 template("android_lint") {
18   if (defined(invoker.testonly)) { testonly = invoker.testonly }
19
20   jar_path = invoker.jar_path
21   android_manifest = invoker.android_manifest
22   java_files = invoker.java_files
23   base_path = "$target_gen_dir/$target_name"
24
25   action(target_name) {
26     script = "//build/android/gyp/lint.py"
27     result_path = base_path + "/result.xml"
28     config_path = base_path + "/config.xml"
29     suppressions_file = "//build/android/lint/suppressions.xml"
30     inputs = [
31       suppressions_file,
32       android_manifest,
33       jar_path,
34     ] + java_files
35
36     outputs = [
37       config_path,
38       result_path
39     ]
40
41     rebased_java_files = rebase_path(java_files, root_build_dir)
42
43     args = [
44       "--lint-path=$rebased_android_sdk_root/tools/lint",
45       "--config-path", rebase_path(suppressions_file, root_build_dir),
46       "--manifest-path", rebase_path(android_manifest, root_build_dir),
47       "--product-dir=.",
48       "--jar-path", rebase_path(jar_path, root_build_dir),
49       "--processed-config-path", rebase_path(config_path, root_build_dir),
50       "--result-path", rebase_path(result_path, root_build_dir),
51       "--java-files=$rebased_java_files",
52       "--enable",
53     ]
54   }
55 }
56
57
58 # Write the target's .build_config file. This is a json file that contains a
59 # dictionary of information about how to build this target (things that
60 # require knowledge about this target's dependencies and cannot be calculated
61 # at gn-time). There is a special syntax to add a value in that dictionary to
62 # an action/action_foreachs args:
63 #   --python-arg=@FileArg($rebased_build_config_path:key0:key1)
64 # At runtime, such an arg will be replaced by the value in the build_config.
65 # See build/android/gyp/write_build_config.py and
66 # build/android/gyp/util/build_utils.py:ExpandFileArgs
67 template("write_build_config") {
68   if (defined(invoker.testonly)) { testonly = invoker.testonly }
69
70   assert(defined(invoker.type))
71   assert(defined(invoker.build_config))
72
73   type = invoker.type
74   build_config = invoker.build_config
75
76   assert(type == "android_apk" || type == "android_library" || type == "android_resources")
77
78   action(target_name) {
79     script = "//build/android/gyp/write_build_config.py"
80     depfile = "$target_gen_dir/$target_name.d"
81     inputs = []
82
83     deps = []
84     if (defined(invoker.deps)) {
85       deps += invoker.deps
86     }
87
88     possible_deps_configs = []
89     foreach(d, deps) {
90       dep_gen_dir = get_label_info(d, "target_gen_dir")
91       dep_name = get_label_info(d, "name")
92       possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ]
93     }
94     rebase_possible_deps_configs = rebase_path(possible_deps_configs)
95
96     outputs = [
97       depfile,
98       build_config
99     ]
100
101     args = [
102       "--type", type,
103       "--depfile", rebase_path(depfile, root_build_dir),
104       "--possible-deps-configs=$rebase_possible_deps_configs",
105       "--build-config", rebase_path(build_config, root_build_dir),
106     ]
107
108     if (type == "android_library" || type == "android_apk") {
109       args += [
110         "--jar-path", rebase_path(invoker.jar_path, root_build_dir),
111         "--dex-path", rebase_path(invoker.dex_path, root_build_dir),
112       ]
113     }
114
115     if (type == "android_resources" || type == "android_apk") {
116       assert(defined(invoker.resources_zip))
117       args += [
118         "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir),
119       ]
120       if (defined(invoker.android_manifest)) {
121         inputs += [
122           invoker.android_manifest
123         ]
124         args += [
125           "--android-manifest", rebase_path(invoker.android_manifest, root_build_dir),
126         ]
127       }
128       if (defined(invoker.custom_package)) {
129         args += [
130           "--package-name", invoker.custom_package
131         ]
132       }
133     }
134
135     if (type == "android_apk") {
136       if (defined(invoker.native_libs)) {
137         rebased_native_libs = rebase_path(invoker.native_libs, root_build_dir)
138         rebased_android_readelf = rebase_path(android_readelf, root_build_dir)
139         args += [
140           "--native-libs=$rebased_native_libs",
141           "--readelf-path=$rebased_android_readelf",
142         ]
143       }
144     }
145
146     if (defined(invoker.srcjar)) {
147       args += [
148         "--srcjar", rebase_path(invoker.srcjar, root_build_dir)
149       ]
150     }
151   }
152 }
153
154
155 # Creates a zip archive of the inputs.
156 # If base_dir is provided, the archive paths will be relative to it.
157 template("zip") {
158   if (defined(invoker.testonly)) { testonly = invoker.testonly }
159
160   assert(defined(invoker.inputs))
161   assert(defined(invoker.output))
162
163   rebase_inputs = rebase_path(invoker.inputs, root_build_dir)
164   rebase_output = rebase_path(invoker.output, root_build_dir)
165   action(target_name) {
166     script = "//build/android/gn/zip.py"
167     depfile = "$target_gen_dir/$target_name.d"
168     inputs = invoker.inputs
169     outputs = [
170       depfile,
171       invoker.output
172     ]
173     args = [
174       "--depfile", rebase_path(depfile, root_build_dir),
175       "--inputs=$rebase_inputs",
176       "--output=$rebase_output",
177     ]
178     if (defined(invoker.base_dir)) {
179       args += [
180         "--base-dir", rebase_path(invoker.base_dir, root_build_dir)
181       ]
182     }
183   }
184 }
185
186 template("dex") {
187   if (defined(invoker.testonly)) { testonly = invoker.testonly }
188
189   assert(defined(invoker.sources))
190   assert(defined(invoker.output))
191   action(target_name) {
192     script = "//build/android/gyp/dex.py"
193     depfile = "$target_gen_dir/$target_name.d"
194     sources = invoker.sources
195     outputs = [depfile, invoker.output]
196     if (defined(invoker.inputs)) {
197       inputs = invoker.inputs
198     }
199
200     if (defined(invoker.deps)) {
201       deps = invoker.deps
202     }
203
204     rebased_output = rebase_path(invoker.output, root_build_dir)
205
206     args = [
207       "--depfile", rebase_path(depfile, root_build_dir),
208       "--android-sdk-tools", rebased_android_sdk_build_tools,
209       "--dex-path", rebased_output,
210     ]
211
212     if (defined(invoker.no_locals) && invoker.no_locals) {
213       args += [
214         "--no-locals=1"
215       ]
216     }
217
218     if (defined(invoker.args)) {
219       args += invoker.args
220     }
221
222     args += rebase_path(invoker.sources, root_build_dir)
223   }
224 }
225
226 # Packages resources, assets, dex, and native libraries into an apk. Signs and
227 # zipaligns the apk.
228 template("create_apk") {
229   if (defined(invoker.testonly)) { testonly = invoker.testonly }
230
231   _android_manifest = invoker.android_manifest
232   _base_path = invoker.base_path
233   _final_apk_path = invoker.apk_path
234   _resources_zip = invoker.resources_zip
235   _dex_path = invoker.dex_path
236   _keystore_path = invoker.keystore_path
237   _keystore_name = invoker.keystore_name
238   _keystore_password = invoker.keystore_password
239   _load_library_from_apk = invoker.load_library_from_apk
240
241   _deps = []
242   if (defined(invoker.deps)) {
243     _deps = invoker.deps
244   }
245
246   _native_libs_dir = "//build/android/empty/res"
247   if (defined(invoker.native_libs_dir)) {
248       _native_libs_dir = invoker.native_libs_dir
249   }
250
251   _asset_location = "//build/android/empty/res"
252   if (defined(invoker.asset_location)) {
253     _asset_location = invoker.asset_location
254   }
255
256   _version_code = invoker.version_code
257   _version_name = invoker.version_name
258
259   _base_apk_path = _base_path + ".apk_intermediates"
260
261   _resource_packaged_apk_path = _base_apk_path + ".ap_"
262   _packaged_apk_path = _base_apk_path + ".unfinished.apk"
263
264
265   _configuration_name = "Release"
266   if (is_debug) {
267     _configuration_name = "Debug"
268   }
269
270   action("${target_name}__package_resources") {
271     deps = _deps
272
273     script = "//build/android/gyp/package_resources.py"
274     depfile = "${target_gen_dir}/${target_name}.d"
275     inputs = [
276       _android_manifest,
277       _resources_zip,
278     ]
279     outputs = [depfile, _resource_packaged_apk_path]
280
281     _rebased_resources_zips = [rebase_path(_resources_zip, root_build_dir)]
282     args = [
283         "--depfile", rebase_path(depfile, root_build_dir),
284         "--android-sdk", rebased_android_sdk,
285         "--android-sdk-tools", rebased_android_sdk_build_tools,
286
287         "--configuration-name=$_configuration_name",
288
289         "--android-manifest", rebase_path(_android_manifest, root_build_dir),
290         "--version-code", _version_code,
291         "--version-name", _version_name,
292
293         "--asset-dir", rebase_path(_asset_location, root_build_dir),
294         "--resource-zips=$_rebased_resources_zips",
295
296         "--apk-path", rebase_path(_resource_packaged_apk_path, root_build_dir),
297       ]
298   }
299
300   action("${target_name}__package") {
301     script = "//build/android/gyp/ant.py"
302     _ant_script = "//build/android/ant/apk-package.xml"
303
304     depfile = "$target_gen_dir/$target_name.d"
305
306     inputs = [
307       _dex_path,
308       _resource_packaged_apk_path,
309       _ant_script
310     ]
311
312     outputs = [
313       depfile,
314       _packaged_apk_path,
315     ]
316
317     _rebased_emma_jar = ""
318     _rebased_resource_packaged_apk_path = rebase_path(
319         _resource_packaged_apk_path, root_build_dir)
320     _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir)
321     _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir)
322     _rebased_dex_path = rebase_path(_dex_path, root_build_dir)
323     args = [
324       "--depfile", rebase_path(depfile, root_build_dir),
325       "--",
326       "-quiet",
327       "-DANDROID_SDK_ROOT=$rebased_android_sdk_root",
328       "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools",
329       "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path",
330       "-DCONFIGURATION_NAME=$_configuration_name",
331       "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir",
332       "-DOUT_DIR=",
333       "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path",
334       "-DEMMA_INSTRUMENT=0",
335       "-DEMMA_DEVICE_JAR=$_rebased_emma_jar",
336       "-DDEX_FILE_PATH=$_rebased_dex_path",
337
338       "-Dbasedir=.",
339       "-buildfile", rebase_path(_ant_script, root_build_dir)
340     ]
341   }
342
343   action("${target_name}__finalize") {
344     script = "//build/android/gyp/finalize_apk.py"
345     depfile = "$target_gen_dir/$target_name.d"
346
347     sources = [_packaged_apk_path]
348     inputs = [_keystore_path]
349     outputs = [depfile, _final_apk_path]
350
351     args = [
352       "--depfile", rebase_path(depfile, root_build_dir),
353       "--zipalign-path", rebase_path(zipalign_path, root_build_dir),
354       "--unsigned-apk-path", rebase_path(_packaged_apk_path, root_build_dir),
355       "--final-apk-path", rebase_path(_final_apk_path, root_build_dir),
356       "--key-path", rebase_path(_keystore_path, root_build_dir),
357       "--key-name", _keystore_name,
358       "--key-passwd", _keystore_password,
359     ]
360     if (_load_library_from_apk) {
361       _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar"
362       inputs += [
363         _rezip_jar_path
364       ]
365       args += [
366         "--load-library-from-zip-file=1",
367         "--rezip-apk-jar-path", rebase_path(_rezip_jar_path, root_build_dir)
368       ]
369     }
370   }
371
372   group(target_name) {
373     deps = [":${target_name}__finalize"]
374   }
375 }
376
377 template("java_prebuilt") {
378   if (defined(invoker.testonly)) { testonly = invoker.testonly }
379
380   _input_jar_path = invoker.input_jar_path
381   _output_jar_path = invoker.output_jar_path
382   _jar_toc_path = _output_jar_path + ".TOC"
383
384   assert(invoker.build_config != "")
385
386   if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
387     _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar"
388     _proguard_config_path = invoker.proguard_config
389     _build_config = invoker.build_config
390     _rebased_build_config = rebase_path(_build_config, root_build_dir)
391     action("${target_name}__proguard_process") {
392       script = "//build/android/gyp/proguard.py"
393       inputs = [
394         android_sdk_jar,
395         _proguard_jar_path,
396         _build_config,
397         _input_jar_path,
398         _proguard_config_path,
399       ]
400       depfile = "${target_gen_dir}/${target_name}.d"
401       outputs = [
402         depfile,
403         _output_jar_path,
404       ]
405       args = [
406         "--depfile", rebase_path(depfile, root_build_dir),
407         "--proguard-path", rebase_path(_proguard_jar_path, root_build_dir),
408         "--input-path", rebase_path(_input_jar_path, root_build_dir),
409         "--output-path", rebase_path(_output_jar_path, root_build_dir),
410         "--proguard-config", rebase_path(_proguard_config_path, root_build_dir),
411         "--classpath", rebased_android_sdk_jar,
412         "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
413       ]
414     }
415   } else {
416     copy("${target_name}__copy_jar") {
417       sources = [_input_jar_path]
418       outputs = [_output_jar_path]
419     }
420   }
421
422   action("${target_name}__jar_toc") {
423     script = "//build/android/gyp/jar_toc.py"
424     depfile = "$target_gen_dir/$target_name.d"
425     outputs = [
426       depfile,
427       _jar_toc_path,
428       _jar_toc_path + ".md5.stamp"
429     ]
430     inputs = [ _output_jar_path ]
431     args = [
432       "--depfile", rebase_path(depfile, root_build_dir),
433       "--jar-path", rebase_path(_output_jar_path, root_build_dir),
434       "--toc-path", rebase_path(_jar_toc_path, root_build_dir),
435     ]
436   }
437
438   group(target_name) {
439     deps = [
440       ":${target_name}__jar_toc"
441     ]
442   }
443 }
444
445 # Compiles and jars a set of java files.
446 #
447 # Outputs:
448 #  $jar_path.jar
449 #  $jar_path.jar.TOC
450 #
451 # Variables
452 #   java_files: List of .java files to compile.
453 #   java_deps: List of java dependencies. These should all have a .jar output
454 #     at "${target_gen_dir}/${target_name}.jar.
455 #   chromium_code: If true, enable extra warnings.
456 #   srcjar_deps: List of srcjar dependencies. The .java files contained in the
457 #     dependencies srcjar outputs will be compiled and added to the output jar.
458 #   jar_path: Use this to explicitly set the output jar path. Defaults to
459 #     "${target_gen_dir}/${target_name}.jar.
460 template("compile_java") {
461   if (defined(invoker.testonly)) { testonly = invoker.testonly }
462
463   assert(defined(invoker.java_files))
464   assert(defined(invoker.build_config))
465   assert(defined(invoker.jar_path))
466
467   _java_files = invoker.java_files
468   _final_jar_path = invoker.jar_path
469   _intermediate_jar_path = "$target_gen_dir/$target_name.initial.jar"
470
471   _build_config = invoker.build_config
472
473   _jar_excluded_patterns = []
474   if (defined(invoker.jar_excluded_patterns)) {
475     _jar_excluded_patterns += invoker.jar_excluded_patterns
476   }
477
478   _chromium_code = false
479   if (defined(invoker.chromium_code)) {
480     _chromium_code = invoker.chromium_code
481   }
482
483   _srcjar_deps = []
484   if (defined(invoker.srcjar_deps)) {
485     _srcjar_deps += invoker.srcjar_deps
486   }
487
488   _java_srcjars = []
489   if (defined(invoker.srcjars)) {
490     _java_srcjars = invoker.srcjars
491   }
492   foreach(dep, _srcjar_deps) {
493     _dep_gen_dir = get_label_info(dep, "target_gen_dir")
494     _dep_name = get_label_info(dep, "name")
495     _java_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ]
496   }
497   # Mark srcjar_deps as used.
498   assert(_srcjar_deps == [] || true)
499
500   _system_jars = [ android_sdk_jar ]
501   action("${target_name}__javac") {
502     script = "//build/android/gyp/javac.py"
503     depfile = "$target_gen_dir/$target_name.d"
504     outputs = [
505       depfile,
506       _intermediate_jar_path,
507       _intermediate_jar_path + ".md5.stamp"
508     ]
509     sources = _java_files + _java_srcjars
510     inputs = _system_jars + [ _build_config ]
511
512     _rebased_system_jars = rebase_path(_system_jars, root_build_dir)
513     _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir)
514     _rebased_build_config = rebase_path(_build_config, root_build_dir)
515     _rebased_depfile = rebase_path(depfile, root_build_dir)
516     _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir)
517     args = [
518       "--depfile=$_rebased_depfile",
519       "--classpath=$_rebased_system_jars",
520       "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
521       "--jar-path=$_rebased_jar_path",
522       "--java-srcjars=$_rebased_java_srcjars",
523       "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)",
524       "--jar-excluded-classes=$_jar_excluded_patterns",
525     ]
526     if (_chromium_code) {
527       args += [ "--chromium-code" ]
528     }
529
530     args += rebase_path(_java_files, root_build_dir)
531   }
532
533   java_prebuilt("${target_name}__finish") {
534     build_config = _build_config
535     input_jar_path = _intermediate_jar_path
536     output_jar_path = _final_jar_path
537     if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
538       proguard_preprocess = invoker.proguard_preprocess
539       proguard_config = invoker.proguard_config
540     }
541   }
542
543   group(target_name) {
544     deps = [
545       ":${target_name}__javac",
546       ":${target_name}__finish",
547     ]
548   }
549 }
550
551
552 # This adds Android-specific parts to the java_library template.
553 #
554 # Runs Android lint against the compiled java files.
555 # Dexes the output jar for inclusion in an APK.
556 template("android_java_library") {
557   if (defined(invoker.testonly)) { testonly = invoker.testonly }
558
559   assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
560       || defined(invoker.srcjars) || defined(invoker.srcjar_deps))
561   assert(defined(invoker.build_config))
562   assert(defined(invoker.jar_path))
563   assert(defined(invoker.dex_path))
564
565   _srcjar_deps = []
566   if (defined(invoker.srcjar_deps)) {
567     _srcjar_deps = invoker.srcjar_deps
568   }
569
570   _srcjars = []
571   if (defined(invoker.srcjars)) {
572     _srcjars = invoker.srcjars
573   }
574
575   _java_files = []
576   if (defined(invoker.java_files)) {
577     _java_files = invoker.java_files
578   } else if (defined(invoker.DEPRECATED_java_in_dir)) {
579     _src_dir = invoker.DEPRECATED_java_in_dir + "/src"
580     _src_dir_exists = exec_script("//build/dir_exists.py",
581           [ rebase_path(_src_dir, root_build_dir) ],
582           "string")
583     assert(_src_dir_exists == "False",
584         "In GN, java_in_dir should be the fully specified java directory " +
585         "(i.e. including the trailing \"/src\")")
586
587     _java_files_build_rel = exec_script(
588         "//build/android/gyp/find.py",
589         [
590           "--pattern",
591           "*.java",
592           rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir)
593         ],
594         "list lines"
595         )
596     _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
597   }
598   assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
599
600   _jar_path = invoker.jar_path
601   _dex_path = invoker.dex_path
602
603   _android_manifest = "//build/android/AndroidManifest.xml"
604   if (defined(invoker.android_manifest)) {
605     _android_manifest = invoker.android_manifest
606   }
607   assert(_android_manifest != "")
608
609   _final_deps = []
610   _final_datadeps = []
611
612   compile_java("${target_name}__compile_java") {
613     jar_path = _jar_path
614     if (defined(invoker.jar_excluded_patterns)) {
615       jar_excluded_patterns = invoker.jar_excluded_patterns
616     }
617     build_config = invoker.build_config
618     java_files = _java_files
619     srcjar_deps = _srcjar_deps
620     srcjars = _srcjars
621
622     if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
623       proguard_preprocess = invoker.proguard_preprocess
624       proguard_config = invoker.proguard_config
625     }
626
627     if (defined(invoker.dist_jar_path)) {
628       dist_jar_path = invoker.dist_jar_path
629     }
630   }
631
632   if (defined(invoker.chromium_code) && invoker.chromium_code) {
633     _final_datadeps += [ ":${target_name}__lint" ]
634     android_lint("${target_name}__lint") {
635       android_manifest = _android_manifest
636       jar_path = _jar_path
637       java_files = _java_files
638     }
639   }
640
641   dex("${target_name}__dex") {
642     sources = [_jar_path]
643     output = _dex_path
644   }
645
646   group(target_name) {
647     deps = [
648       ":${target_name}__compile_java",
649       ":${target_name}__dex",
650     ] + _final_deps + _final_datadeps
651   }
652 }
653
654 # Runs process_resources.py
655 template("process_resources") {
656   if (defined(invoker.testonly)) { testonly = invoker.testonly }
657
658   zip_path = invoker.zip_path
659   srcjar_path = invoker.srcjar_path
660   build_config = invoker.build_config
661   resource_dirs = invoker.resource_dirs
662   android_manifest = invoker.android_manifest
663
664   non_constant_id = true
665   if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) {
666     non_constant_id = false
667   }
668
669   action(target_name) {
670     script = "//build/android/gyp/process_resources.py"
671
672     depfile = "$target_gen_dir/$target_name.d"
673     outputs = [
674       depfile,
675       zip_path,
676       srcjar_path,
677     ]
678
679     sources_build_rel = exec_script(
680         "//build/android/gyp/find.py",
681         rebase_path(resource_dirs, root_build_dir),
682         "list lines"
683         )
684     sources = rebase_path(sources_build_rel, ".", root_build_dir)
685
686     inputs = [
687       build_config,
688       android_manifest,
689     ]
690
691     rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir)
692     rebase_build_config = rebase_path(build_config, root_build_dir)
693     args = [
694       "--depfile", rebase_path(depfile, root_build_dir),
695       "--android-sdk", rebase_path(android_sdk, root_build_dir),
696       "--android-sdk-tools", rebase_path(android_sdk_build_tools, root_build_dir),
697       "--android-manifest", rebase_path(android_manifest, root_build_dir),
698
699       "--resource-dirs=$rebase_resource_dirs",
700       "--srcjar-out", rebase_path(srcjar_path, root_build_dir),
701       "--resource-zip-out", rebase_path(zip_path, root_build_dir),
702
703       "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependency_zips)",
704       "--extra-res-packages=@FileArg($rebase_build_config:resources:extra_package_names)",
705     ]
706
707     if (non_constant_id) {
708       args += [ "--non-constant-id" ]
709     }
710
711     if (defined(invoker.custom_package)) {
712       args += [
713         "--custom-package", invoker.custom_package,
714       ]
715     }
716
717     if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) {
718       args += ["--v14-verify-only"]
719     }
720
721     if (defined(invoker.all_resources_zip_path)) {
722       all_resources_zip = invoker.all_resources_zip_path
723       outputs += [ all_resources_zip ]
724       args += [
725         "--all-resources-zip-out", rebase_path(all_resources_zip, root_build_dir)
726       ]
727     }
728
729     if (defined(invoker.args)) {
730       args += invoker.args
731     }
732   }
733 }
734
735 template("copy_ex") {
736   if (defined(invoker.testonly)) { testonly = invoker.testonly }
737
738   action(target_name) {
739     script = "//build/android/gyp/copy_ex.py"
740
741     if (defined(invoker.deps)) { deps = invoker.deps }
742
743     sources = []
744     if (defined(invoker.sources)) {
745       sources += invoker.sources
746     }
747
748     inputs = []
749     if (defined(invoker.inputs)) {
750       inputs += invoker.inputs
751     }
752
753     depfile = "$target_gen_dir/$target_name.d"
754     outputs = [
755       depfile,
756     ]
757
758     args = [
759       "--depfile", rebase_path(depfile, root_build_dir),
760       "--dest", rebase_path(invoker.dest, root_build_dir),
761     ]
762     rebased_sources = rebase_path(sources, root_build_dir)
763     args += [ "--files=$rebased_sources" ]
764
765     if (defined(invoker.clear_dir) && invoker.clear_dir) {
766       args += ["--clear"]
767     }
768
769     if (defined(invoker.args)) {
770       args += invoker.args
771     }
772   }
773 }