92c8cfa0b5e29bb8a70644562bc4182a721e1c59
[platform/framework/web/crosswalk.git] / src / build / java_apk.gypi
1 # Copyright (c) 2012 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 # This file is meant to be included into a target to provide a rule
6 # to build Android APKs in a consistent manner.
7 #
8 # To use this, create a gyp target with the following form:
9 # {
10 #   'target_name': 'my_package_apk',
11 #   'type': 'none',
12 #   'variables': {
13 #     'apk_name': 'MyPackage',
14 #     'java_in_dir': 'path/to/package/root',
15 #     'resource_dir': 'path/to/package/root/res',
16 #   },
17 #   'includes': ['path/to/this/gypi/file'],
18 # }
19 #
20 # Required variables:
21 #  apk_name - The final apk will be named <apk_name>.apk
22 #  java_in_dir - The top-level java directory. The src should be in
23 #    <(java_in_dir)/src.
24 # Optional/automatic variables:
25 #  additional_input_paths - These paths will be included in the 'inputs' list to
26 #    ensure that this target is rebuilt when one of these paths changes.
27 #  additional_res_dirs - Additional directories containing Android resources.
28 #  additional_res_packages - Package names of the R.java files corresponding to
29 #    each directory in additional_res_dirs.
30 #  additional_src_dirs - Additional directories with .java files to be compiled
31 #    and included in the output of this target.
32 #  asset_location - The directory where assets are located.
33 #  generated_src_dirs - Same as additional_src_dirs except used for .java files
34 #    that are generated at build time. This should be set automatically by a
35 #    target's dependencies. The .java files in these directories are not
36 #    included in the 'inputs' list (unlike additional_src_dirs).
37 #  input_jars_paths - The path to jars to be included in the classpath. This
38 #    should be filled automatically by depending on the appropriate targets.
39 #  is_test_apk - Set to 1 if building a test apk.  This prevents resources from
40 #    dependencies from being re-included.
41 #  native_lib_target - The target_name of the target which generates the final
42 #    shared library to be included in this apk. A stripped copy of the
43 #    library will be included in the apk.
44 #  resource_dir - The directory for resources.
45 #  R_package - A custom Java package to generate the resource file R.java in.
46 #    By default, the package given in AndroidManifest.xml will be used.
47 #  use_chromium_linker - Enable the content dynamic linker that allows sharing the
48 #    RELRO section of the native libraries between the different processes.
49 #  enable_chromium_linker_tests - Enable the content dynamic linker test support
50 #    code. This allows a test APK to inject a Linker.TestRunner instance at
51 #    runtime. Should only be used by the chromium_linker_test_apk target!!
52 #  never_lint - Set to 1 to not run lint on this target.
53 {
54   'variables': {
55     'tested_apk_obfuscated_jar_path%': '/',
56     'tested_apk_dex_path%': '/',
57     'additional_input_paths': [],
58     'input_jars_paths': [],
59     'library_dexed_jars_paths': [],
60     'additional_src_dirs': [],
61     'generated_src_dirs': [],
62     'app_manifest_version_name%': '<(android_app_version_name)',
63     'app_manifest_version_code%': '<(android_app_version_code)',
64     # aapt generates this proguard.txt.
65     'generated_proguard_file': '<(intermediate_dir)/proguard.txt',
66     'proguard_enabled%': 'false',
67     'proguard_flags_paths': ['<(generated_proguard_file)'],
68     'jar_name': 'chromium_apk_<(_target_name).jar',
69     'resource_dir%':'<(DEPTH)/build/android/ant/empty/res',
70     'R_package%':'',
71     'additional_R_text_files': [],
72     'dependencies_res_zip_paths': [],
73     'additional_res_packages': [],
74     'is_test_apk%': 0,
75     'resource_input_paths': [],
76     'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)',
77     'asset_location%': '<(intermediate_dir)/assets',
78     'codegen_stamp': '<(intermediate_dir)/codegen.stamp',
79     'package_input_paths': [],
80     'ordered_libraries_file': '<(intermediate_dir)/native_libraries.json',
81     'native_libraries_template': '<(DEPTH)/base/android/java/templates/NativeLibraries.template',
82     'native_libraries_java_dir': '<(intermediate_dir)/native_libraries_java/',
83     'native_libraries_java_file': '<(native_libraries_java_dir)/NativeLibraries.java',
84     'native_libraries_java_stamp': '<(intermediate_dir)/native_libraries_java.stamp',
85     'native_libraries_template_data_dir': '<(intermediate_dir)/native_libraries/',
86     'native_libraries_template_data_file': '<(native_libraries_template_data_dir)/native_libraries_array.h',
87     'native_libraries_template_version_file': '<(native_libraries_template_data_dir)/native_libraries_version.h',
88     'compile_stamp': '<(intermediate_dir)/compile.stamp',
89     'lint_stamp': '<(intermediate_dir)/lint.stamp',
90     'lint_result': '<(intermediate_dir)/lint_result.xml',
91     'lint_config': '<(intermediate_dir)/lint_config.xml',
92     'never_lint%': 0,
93     'instr_stamp': '<(intermediate_dir)/instr.stamp',
94     'jar_stamp': '<(intermediate_dir)/jar.stamp',
95     'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp',
96     'strip_stamp': '<(intermediate_dir)/strip.stamp',
97     'classes_dir': '<(intermediate_dir)/classes',
98     'classes_final_dir': '<(intermediate_dir)/classes_instr',
99     'javac_includes': [],
100     'jar_excluded_classes': [],
101     'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
102     'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar',
103     'test_jar_path': '<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar',
104     'dex_path': '<(intermediate_dir)/classes.dex',
105     'emma_device_jar': '<(android_sdk_root)/tools/lib/emma_device.jar',
106     'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml',
107     'push_stamp': '<(intermediate_dir)/push.stamp',
108     'link_stamp': '<(intermediate_dir)/link.stamp',
109     'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp',
110     'resource_zip_path': '<(intermediate_dir)/<(_target_name).resources.zip',
111     'resource_packaged_apk_name': '<(apk_name)-resources.ap_',
112     'resource_packaged_apk_path': '<(intermediate_dir)/<(resource_packaged_apk_name)',
113     'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk',
114     'final_apk_path%': '<(PRODUCT_DIR)/apks/<(apk_name).apk',
115     'incomplete_apk_path': '<(intermediate_dir)/<(apk_name)-incomplete.apk',
116     'apk_install_record': '<(intermediate_dir)/apk_install.record.stamp',
117     'device_intermediate_dir': '/data/data/org.chromium.gyp_managed_install/<(_target_name)/<(CONFIGURATION_NAME)',
118     'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh',
119     'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh',
120     'create_standalone_apk%': 1,
121     'res_v14_verify_only%': 0,
122     'variables': {
123       'variables': {
124         'native_lib_target%': '',
125         'native_lib_version_name%': '',
126         'use_chromium_linker%' : 0,
127         'enable_chromium_linker_tests%': 0,
128         'is_test_apk%': 0,
129       },
130       'conditions': [
131         ['gyp_managed_install == 1 and native_lib_target != ""', {
132           'unsigned_standalone_apk_path': '<(intermediate_dir)/<(apk_name)-standalone-unsigned.apk',
133         }, {
134           'unsigned_standalone_apk_path': '<(unsigned_apk_path)',
135         }],
136         ['gyp_managed_install == 1', {
137           'apk_package_native_libs_dir': '<(intermediate_dir)/libs.managed',
138         }, {
139           'apk_package_native_libs_dir': '<(intermediate_dir)/libs',
140         }],
141         ['is_test_apk == 0 and emma_coverage != 0', {
142           'emma_instrument%': 1,
143         },{
144           'emma_instrument%': 0,
145         }],
146       ],
147     },
148     'native_lib_target%': '',
149     'native_lib_version_name%': '',
150     'use_chromium_linker%' : 0,
151     'enable_chromium_linker_tests%': 0,
152     'emma_instrument%': '<(emma_instrument)',
153     'apk_package_native_libs_dir': '<(apk_package_native_libs_dir)',
154     'unsigned_standalone_apk_path': '<(unsigned_standalone_apk_path)',
155     'extra_native_libs': [],
156     'apk_dex_input_paths': [ '>@(library_dexed_jars_paths)' ],
157   },
158   # Pass the jar path to the apk's "fake" jar target.  This would be better as
159   # direct_dependent_settings, but a variable set by a direct_dependent_settings
160   # cannot be lifted in a dependent to all_dependent_settings.
161   'all_dependent_settings': {
162     'conditions': [
163       ['proguard_enabled == "true"', {
164         'variables': {
165           'proguard_enabled': 'true',
166         }
167       }],
168     ],
169     'variables': {
170       'apk_output_jar_path': '<(jar_path)',
171       'tested_apk_obfuscated_jar_path': '<(obfuscated_jar_path)',
172       'tested_apk_dex_path': '<(dex_path)',
173     },
174   },
175   'conditions': [
176     ['resource_dir!=""', {
177       'variables': {
178         'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ]
179       },
180     }],
181     ['R_package != ""', {
182       'variables': {
183         # We generate R.java in package R_package (in addition to the package
184         # listed in the AndroidManifest.xml, which is unavoidable).
185         'additional_res_packages': ['<(R_package)'],
186         'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'],
187       },
188     }],
189     ['native_lib_target != "" and component == "shared_library"', {
190       'dependencies': [
191         '<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
192       ],
193     }],
194     ['use_chromium_linker == 1', {
195       'dependencies': [
196         '<(DEPTH)/base/base.gyp:chromium_android_linker',
197       ],
198     }],
199     ['native_lib_target != ""', {
200       'variables': {
201         'generated_src_dirs': [ '<(native_libraries_java_dir)' ],
202         'native_libs_paths': [
203           '<(SHARED_LIB_DIR)/<(native_lib_target).>(android_product_extension)'
204         ],
205         'package_input_paths': [
206           '<(apk_package_native_libs_dir)/<(android_app_abi)/gdbserver',
207         ],
208       },
209       'copies': [
210         {
211           # gdbserver is always copied into the APK's native libs dir. The ant
212           # build scripts (apkbuilder task) will only include it in a debug
213           # build.
214           'destination': '<(apk_package_native_libs_dir)/<(android_app_abi)',
215           'files': [
216             '<(android_gdbserver)',
217           ],
218         },
219       ],
220       'actions': [
221         {
222           'variables': {
223             'conditions': [
224               ['use_chromium_linker == 1', {
225                 'variables': {
226                   'linker_input_libraries': [
227                     '<(SHARED_LIB_DIR)/libchromium_android_linker.>(android_product_extension)',
228                   ],
229                 }
230               }, {
231                 'variables': {
232                   'linker_input_libraries': [],
233                 },
234               }],
235             ],
236             'input_libraries': [
237               '<@(native_libs_paths)',
238               '<@(extra_native_libs)',
239               '<@(linker_input_libraries)',
240             ],
241           },
242           'includes': ['../build/android/write_ordered_libraries.gypi'],
243         },
244         {
245           'action_name': 'native_libraries_template_data_<(_target_name)',
246           'message': 'Creating native_libraries_list.h for <(_target_name)',
247           'inputs': [
248             '<(DEPTH)/build/android/gyp/util/build_utils.py',
249             '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
250             '<(ordered_libraries_file)',
251           ],
252           'outputs': [
253             '<(native_libraries_template_data_file)',
254             '<(native_libraries_template_version_file)',
255           ],
256           'action': [
257             'python', '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
258             '--ordered-libraries=<(ordered_libraries_file)',
259             '--version-name=<(native_lib_version_name)',
260             '--native-library-list=<(native_libraries_template_data_file)',
261             '--version-output=<(native_libraries_template_version_file)',
262           ],
263         },
264         {
265           'action_name': 'native_libraries_<(_target_name)',
266           'variables': {
267             'conditions': [
268               ['use_chromium_linker == 1', {
269                 'variables': {
270                   'linker_gcc_preprocess_defines': [
271                     '--defines', 'ENABLE_CHROMIUM_LINKER',
272                   ],
273                 }
274               }, {
275                 'variables': {
276                   'linker_gcc_preprocess_defines': [],
277                 },
278               }],
279               ['enable_chromium_linker_tests == 1', {
280                 'variables': {
281                   'linker_tests_gcc_preprocess_defines': [
282                     '--defines', 'ENABLE_CHROMIUM_LINKER_TESTS',
283                   ],
284                 }
285               }, {
286                 'variables': {
287                   'linker_tests_gcc_preprocess_defines': [],
288                 },
289               }],
290             ],
291             'gcc_preprocess_defines': [
292               '<@(linker_gcc_preprocess_defines)',
293               '<@(linker_tests_gcc_preprocess_defines)',
294             ],
295           },
296           'message': 'Creating NativeLibraries.java for <(_target_name)',
297           'inputs': [
298             '<(DEPTH)/build/android/gyp/util/build_utils.py',
299             '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
300             '<(native_libraries_template_data_file)',
301             '<(native_libraries_template_version_file)',
302             '<(native_libraries_template)',
303           ],
304           'outputs': [
305             '<(native_libraries_java_stamp)',
306           ],
307           'action': [
308             'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
309             '--include-path=<(native_libraries_template_data_dir)',
310             '--output=<(native_libraries_java_file)',
311             '--template=<(native_libraries_template)',
312             '--stamp=<(native_libraries_java_stamp)',
313             '<@(gcc_preprocess_defines)',
314           ],
315         },
316         {
317           'action_name': 'strip_native_libraries',
318           'variables': {
319             'ordered_libraries_file%': '<(ordered_libraries_file)',
320             'stripped_libraries_dir': '<(libraries_source_dir)',
321             'input_paths': [
322               '<@(native_libs_paths)',
323               '<@(extra_native_libs)',
324             ],
325             'stamp': '<(strip_stamp)'
326           },
327           'includes': ['../build/android/strip_native_libraries.gypi'],
328         },
329       ],
330       'conditions': [
331         ['gyp_managed_install == 1', {
332           'variables': {
333             'libraries_top_dir': '<(intermediate_dir)/lib.stripped',
334             'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)',
335             'device_library_dir': '<(device_intermediate_dir)/lib.stripped',
336             'configuration_name': '<(CONFIGURATION_NAME)',
337           },
338           'dependencies': [
339             '<(DEPTH)/build/android/setup.gyp:get_build_device_configurations',
340           ],
341           'actions': [
342             {
343               'includes': ['../build/android/push_libraries.gypi'],
344             },
345             {
346               'action_name': 'create device library symlinks',
347               'message': 'Creating links on device for <(_target_name)',
348               'inputs': [
349                 '<(DEPTH)/build/android/gyp/util/build_utils.py',
350                 '<(DEPTH)/build/android/gyp/create_device_library_links.py',
351                 '<(apk_install_record)',
352                 '<(build_device_config_path)',
353                 '<(ordered_libraries_file)',
354               ],
355               'outputs': [
356                 '<(link_stamp)'
357               ],
358               'action': [
359                 'python', '<(DEPTH)/build/android/gyp/create_device_library_links.py',
360                 '--build-device-configuration=<(build_device_config_path)',
361                 '--libraries-json=<(ordered_libraries_file)',
362                 '--script-host-path=<(symlink_script_host_path)',
363                 '--script-device-path=<(symlink_script_device_path)',
364                 '--target-dir=<(device_library_dir)',
365                 '--apk=<(incomplete_apk_path)',
366                 '--stamp=<(link_stamp)',
367                 '--configuration-name=<(CONFIGURATION_NAME)',
368               ],
369             },
370           ],
371           'conditions': [
372             ['create_standalone_apk == 1', {
373               'actions': [
374                 {
375                   'action_name': 'create standalone APK',
376                   'variables': {
377                     'inputs': [
378                       '<(ordered_libraries_file)',
379                       '<(strip_stamp)',
380                     ],
381                     'input_apk_path': '<(unsigned_apk_path)',
382                     'output_apk_path': '<(unsigned_standalone_apk_path)',
383                     'libraries_top_dir%': '<(libraries_top_dir)',
384                   },
385                   'includes': [ 'android/create_standalone_apk_action.gypi' ],
386                 },
387               ],
388             }],
389           ],
390         }, {
391           # gyp_managed_install != 1
392           'variables': {
393             'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_app_abi)',
394             'package_input_paths': [ '<(strip_stamp)' ],
395           },
396         }],
397       ],
398     }], # native_lib_target != ''
399     ['gyp_managed_install == 0 or create_standalone_apk == 1', {
400       'actions': [
401         {
402           'action_name': 'finalize standalone apk',
403           'variables': {
404             'input_apk_path': '<(unsigned_standalone_apk_path)',
405             'output_apk_path': '<(final_apk_path)',
406           },
407           'includes': [ 'android/finalize_apk_action.gypi']
408         },
409       ],
410     }],
411     ['gyp_managed_install == 1', {
412       'actions': [
413         {
414           'action_name': 'finalize incomplete apk',
415           'variables': {
416             'input_apk_path': '<(unsigned_apk_path)',
417             'output_apk_path': '<(incomplete_apk_path)',
418           },
419           'includes': [ 'android/finalize_apk_action.gypi']
420         },
421         {
422           'action_name': 'apk_install_<(_target_name)',
423           'message': 'Installing <(apk_name).apk',
424           'inputs': [
425             '<(DEPTH)/build/android/gyp/util/build_utils.py',
426             '<(DEPTH)/build/android/gyp/apk_install.py',
427             '<(build_device_config_path)',
428             '<(incomplete_apk_path)',
429           ],
430           'outputs': [
431             '<(apk_install_record)',
432           ],
433           'action': [
434             'python', '<(DEPTH)/build/android/gyp/apk_install.py',
435             '--apk-path=<(incomplete_apk_path)',
436             '--build-device-configuration=<(build_device_config_path)',
437             '--install-record=<(apk_install_record)',
438             '--configuration-name=<(CONFIGURATION_NAME)',
439           ],
440         },
441       ],
442     }],
443     ['is_test_apk == 1', {
444       'dependencies': [
445         '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
446       ]
447     }],
448   ],
449   'dependencies': [
450     '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum',
451   ],
452   'actions': [
453     {
454       'action_name': 'process_resources',
455       'message': 'processing resources for <(_target_name)',
456       'variables': {
457         # Write the inputs list to a file, so that its mtime is updated when
458         # the list of inputs changes.
459         'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))',
460         'process_resources_options': [],
461         'conditions': [
462           ['is_test_apk == 1', {
463             'dependencies_res_zip_paths=': [],
464             'additional_res_packages=': [],
465           }],
466           ['res_v14_verify_only == 1', {
467             'process_resources_options': ['--v14-verify-only']
468           }],
469         ],
470       },
471       'inputs': [
472         '<(DEPTH)/build/android/gyp/util/build_utils.py',
473         '<(DEPTH)/build/android/gyp/process_resources.py',
474         '<(android_manifest_path)',
475         '>@(additional_input_paths)',
476         '>@(resource_input_paths)',
477         '>@(dependencies_res_zip_paths)',
478         '>(inputs_list_file)',
479       ],
480       'outputs': [
481         '<(resource_zip_path)',
482         '<(generated_proguard_file)',
483         '<(codegen_stamp)',
484       ],
485       'action': [
486         'python', '<(DEPTH)/build/android/gyp/process_resources.py',
487         '--android-sdk', '<(android_sdk)',
488         '--android-sdk-tools', '<(android_sdk_tools)',
489
490         '--android-manifest', '<(android_manifest_path)',
491         '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
492
493         '--extra-res-packages', '>(additional_res_packages)',
494         '--extra-r-text-files', '>(additional_R_text_files)',
495
496         '--proguard-file', '<(generated_proguard_file)',
497
498         '--resource-dir', '<(resource_dir)',
499         '--resource-zip-out', '<(resource_zip_path)',
500
501         '--R-dir', '<(intermediate_dir)/gen',
502
503         '--stamp', '<(codegen_stamp)',
504
505         '<@(process_resources_options)',
506       ],
507     },
508     {
509       'action_name': 'javac_<(_target_name)',
510       'message': 'Compiling java for <(_target_name)',
511       'variables': {
512         'gen_src_dirs': [
513           '<(intermediate_dir)/gen',
514           '>@(generated_src_dirs)',
515         ],
516         # If there is a separate find for additional_src_dirs, it will find the
517         # wrong .java files when additional_src_dirs is empty.
518         # TODO(thakis): Gyp caches >! evaluation by command. Both java.gypi and
519         # java_apk.gypi evaluate the same command, and at the moment two targets
520         # set java_in_dir to "java". Add a dummy comment here to make sure
521         # that the two targets (one uses java.gypi, the other java_apk.gypi)
522         # get distinct source lists. Medium-term, make targets list all their
523         # Java files instead of using find. (As is, this will be broken if two
524         # targets use the same java_in_dir and both use java_apk.gypi or
525         # both use java.gypi.)
526         'java_sources': ['>!@(find >(java_in_dir)/src >(additional_src_dirs) -name "*.java"  # apk)'],
527
528       },
529       'inputs': [
530         '<(DEPTH)/build/android/gyp/util/build_utils.py',
531         '<(DEPTH)/build/android/gyp/javac.py',
532         '>@(java_sources)',
533         '>@(input_jars_paths)',
534         '<(codegen_stamp)',
535       ],
536       'conditions': [
537         ['native_lib_target != ""', {
538           'inputs': [ '<(native_libraries_java_stamp)' ],
539         }],
540       ],
541       'outputs': [
542         '<(compile_stamp)',
543       ],
544       'action': [
545         'python', '<(DEPTH)/build/android/gyp/javac.py',
546         '--output-dir=<(classes_dir)',
547         '--classpath=>(input_jars_paths) <(android_sdk_jar)',
548         '--src-gendirs=>(gen_src_dirs)',
549         '--javac-includes=<(javac_includes)',
550         '--chromium-code=<(chromium_code)',
551         '--stamp=<(compile_stamp)',
552         '>@(java_sources)',
553       ],
554     },
555     {
556       'variables': {
557         'src_dirs': [
558           '<(java_in_dir)/src',
559           '>@(additional_src_dirs)',
560         ],
561         'stamp_path': '<(lint_stamp)',
562         'result_path': '<(lint_result)',
563         'config_path': '<(lint_config)',
564       },
565       'inputs': [
566         '<(compile_stamp)',
567       ],
568       'outputs': [
569         '<(lint_stamp)',
570       ],
571       'includes': [ 'android/lint_action.gypi' ],
572     },
573     {
574       'action_name': 'instr_classes_<(_target_name)',
575       'message': 'Instrumenting <(_target_name) classes',
576       'variables': {
577         'input_path': '<(classes_dir)',
578         'output_path': '<(classes_final_dir)',
579         'stamp_path': '<(instr_stamp)',
580         'instr_type': 'classes',
581       },
582       'inputs': [
583         '<(compile_stamp)',
584       ],
585       'outputs': [
586         '<(instr_stamp)',
587       ],
588       'includes': [ 'android/instr_action.gypi' ],
589     },
590     {
591       'action_name': 'jar_<(_target_name)',
592       'message': 'Creating <(_target_name) jar',
593       'inputs': [
594         '<(DEPTH)/build/android/gyp/util/build_utils.py',
595         '<(DEPTH)/build/android/gyp/util/md5_check.py',
596         '<(DEPTH)/build/android/gyp/jar.py',
597         '<(instr_stamp)',
598       ],
599       'outputs': [
600         '<(jar_stamp)',
601         '<(jar_path)',
602       ],
603       'action': [
604         'python', '<(DEPTH)/build/android/gyp/jar.py',
605         '--classes-dir=<(classes_final_dir)',
606         '--jar-path=<(jar_path)',
607         '--excluded-classes=<(jar_excluded_classes)',
608         '--stamp=<(jar_stamp)',
609       ]
610     },
611     {
612       'action_name': 'obfuscate_<(_target_name)',
613       'message': 'Obfuscating <(_target_name)',
614       'variables': {
615         'additional_obfuscate_options': [],
616         'additional_obfuscate_input_paths': [],
617         'proguard_out_dir': '<(intermediate_dir)/proguard',
618         'proguard_input_jar_paths': [
619           '>@(input_jars_paths)',
620           '<(jar_path)',
621         ],
622         'target_conditions': [
623           ['is_test_apk == 1', {
624             'additional_obfuscate_options': [
625               '--testapp',
626             ],
627           }],
628           ['is_test_apk == 1 and tested_apk_obfuscated_jar_path != "/"', {
629             'additional_obfuscate_options': [
630               '--tested-apk-obfuscated-jar-path', '>(tested_apk_obfuscated_jar_path)',
631             ],
632             'additional_obfuscate_input_paths': [
633               '>(tested_apk_obfuscated_jar_path).info',
634             ],
635           }],
636           ['proguard_enabled == "true"', {
637             'additional_obfuscate_options': [
638               '--proguard-enabled',
639             ],
640           }],
641         ],
642         'obfuscate_input_jars_paths': [
643           '>@(input_jars_paths)',
644           '<(jar_path)',
645         ],
646       },
647       'conditions': [
648         ['is_test_apk == 1', {
649           'outputs': [
650             '<(test_jar_path)',
651           ],
652         }],
653       ],
654       'inputs': [
655         '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
656         '<(DEPTH)/build/android/gyp/util/build_utils.py',
657         '>@(proguard_flags_paths)',
658         '>@(obfuscate_input_jars_paths)',
659         '>@(additional_obfuscate_input_paths)',
660         '<(instr_stamp)',
661       ],
662       'outputs': [
663         '<(obfuscate_stamp)',
664
665         # In non-Release builds, these paths will all be empty files.
666         '<(obfuscated_jar_path)',
667         '<(obfuscated_jar_path).info',
668         '<(obfuscated_jar_path).dump',
669         '<(obfuscated_jar_path).seeds',
670         '<(obfuscated_jar_path).mapping',
671         '<(obfuscated_jar_path).usage',
672       ],
673       'action': [
674         'python', '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
675
676         '--configuration-name', '<(CONFIGURATION_NAME)',
677
678         '--android-sdk', '<(android_sdk)',
679         '--android-sdk-tools', '<(android_sdk_tools)',
680         '--android-sdk-jar', '<(android_sdk_jar)',
681
682         '--input-jars-paths=>(proguard_input_jar_paths)',
683         '--proguard-configs=>(proguard_flags_paths)',
684
685
686         '--test-jar-path', '<(test_jar_path)',
687         '--obfuscated-jar-path', '<(obfuscated_jar_path)',
688
689         '--proguard-jar-path', '<(android_sdk_root)/tools/proguard/lib/proguard.jar',
690
691         '--stamp', '<(obfuscate_stamp)',
692
693         '>@(additional_obfuscate_options)',
694       ],
695     },
696     {
697       'action_name': 'dex_<(_target_name)',
698       'variables': {
699         'output_path': '<(dex_path)',
700         'dex_input_paths': [
701           '>@(apk_dex_input_paths)',
702           '<(jar_path)',
703         ],
704         'proguard_enabled_input_path': '<(obfuscated_jar_path)',
705       },
706       'target_conditions': [
707         ['emma_instrument != 0', {
708           'dex_no_locals': 1,
709           'dex_input_paths': [
710             '<(emma_device_jar)'
711           ],
712         }],
713         ['is_test_apk == 1 and tested_apk_dex_path != "/"', {
714           'variables': {
715             'dex_additional_options': [
716               '--excluded-paths-file', '>(tested_apk_dex_path).inputs'
717             ],
718           },
719           'inputs': [
720             '>(tested_apk_dex_path).inputs',
721           ],
722         }],
723         ['proguard_enabled == "true"', {
724           'inputs': [ '<(obfuscate_stamp)' ]
725         }, {
726           'inputs': [ '<(instr_stamp)' ]
727         }],
728       ],
729       'includes': [ 'android/dex_action.gypi' ],
730     },
731     {
732       'action_name': 'package_resources',
733       'message': 'packaging resources for <(_target_name)',
734       'variables': {
735         'package_resource_zip_input_paths': [
736           '<(resource_zip_path)',
737           '>@(dependencies_res_zip_paths)',
738         ],
739       },
740       'conditions': [
741         ['is_test_apk == 1', {
742           'variables': {
743             'dependencies_res_zip_paths=': [],
744             'additional_res_packages=': [],
745           }
746         }],
747       ],
748       'inputs': [
749         # TODO: This isn't always rerun correctly, http://crbug.com/351928
750         '<(DEPTH)/build/android/gyp/util/build_utils.py',
751         '<(DEPTH)/build/android/gyp/package_resources.py',
752         '<(android_manifest_path)',
753
754         '>@(package_resource_zip_input_paths)',
755
756         '<(codegen_stamp)',
757       ],
758       'outputs': [
759         '<(resource_packaged_apk_path)',
760       ],
761       'action': [
762         'python', '<(DEPTH)/build/android/gyp/package_resources.py',
763         '--android-sdk', '<(android_sdk)',
764         '--android-sdk-tools', '<(android_sdk_tools)',
765
766         '--configuration-name', '<(CONFIGURATION_NAME)',
767
768         '--android-manifest', '<(android_manifest_path)',
769         '--version-code', '<(app_manifest_version_code)',
770         '--version-name', '<(app_manifest_version_name)',
771
772         '--asset-dir', '<(asset_location)',
773         '--resource-zips', '>(package_resource_zip_input_paths)',
774
775         '--apk-path', '<(resource_packaged_apk_path)',
776       ],
777     },
778     {
779       'action_name': 'ant_package_<(_target_name)',
780       'message': 'Packaging <(_target_name)',
781       'variables': {
782         # Write the inputs list to a file, so that its mtime is updated when
783         # the list of inputs changes.
784         'inputs_list_file': '>|(apk_package.<(_target_name).gypcmd >@(package_input_paths))'
785       },
786       'inputs': [
787         '<(DEPTH)/build/android/ant/apk-package.xml',
788         '<(DEPTH)/build/android/gyp/util/build_utils.py',
789         '<(DEPTH)/build/android/gyp/ant.py',
790         '<(dex_path)',
791         '<(codegen_stamp)',
792         '<(obfuscate_stamp)',
793         '<(resource_packaged_apk_path)',
794         '>@(package_input_paths)',
795         '>(inputs_list_file)',
796       ],
797       'outputs': [
798         '<(unsigned_apk_path)',
799       ],
800       'action': [
801         'python', '<(DEPTH)/build/android/gyp/ant.py',
802         '-quiet',
803         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
804         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
805         '-DRESOURCE_PACKAGED_APK_NAME=<(resource_packaged_apk_name)',
806         '-DAPK_NAME=<(apk_name)',
807         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
808         '-DNATIVE_LIBS_DIR=<(apk_package_native_libs_dir)',
809         '-DOUT_DIR=<(intermediate_dir)',
810         '-DUNSIGNED_APK_PATH=<(unsigned_apk_path)',
811         '-DEMMA_INSTRUMENT=<(emma_instrument)',
812         '-DEMMA_DEVICE_JAR=<(emma_device_jar)',
813
814         '-Dbasedir=.',
815         '-buildfile',
816         '<(DEPTH)/build/android/ant/apk-package.xml',
817       ]
818     },
819   ],
820 }