Enable the Omnibox search button flag on Linux.
[chromium-blink-merge.git] / build / java_apk.gypi
blob57af7efad012402fe5fab79c18b307089da18d98
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.
5 # This file is meant to be included into a target to provide a rule
6 # to build Android APKs in a consistent manner.
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 # }
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 #  java_strings_grd - The name of the grd file from which to generate localized
48 #    strings.xml files, if any.
49 #  use_chromium_linker - Enable the content dynamic linker that allows sharing the
50 #    RELRO section of the native libraries between the different processes.
51 #  enable_chromium_linker_tests - Enable the content dynamic linker test support
52 #    code. This allows a test APK to inject a Linker.TestRunner instance at
53 #    runtime. Should only be used by the chromium_linker_test_apk target!!
54 #  never_lint - Set to 1 to not run lint on this target.
56   'variables': {
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     'proguard_enabled%': 'false',
65     'proguard_flags_paths%': ['<(DEPTH)/build/android/empty_proguard.flags'],
66     'jar_name': 'chromium_apk_<(_target_name).jar',
67     'resource_dir%':'<(DEPTH)/build/android/ant/empty/res',
68     'R_package%':'',
69     'additional_R_text_files': [],
70     'additional_res_dirs': [],
71     'additional_res_packages': [],
72     'is_test_apk%': 0,
73     'java_strings_grd%': '',
74     'resource_input_paths': [],
75     'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)',
76     'asset_location%': '<(intermediate_dir)/assets',
77     'codegen_stamp': '<(intermediate_dir)/codegen.stamp',
78     'package_input_paths': [],
79     'ordered_libraries_file': '<(intermediate_dir)/native_libraries.json',
80     'native_libraries_template': '<(DEPTH)/base/android/java/templates/NativeLibraries.template',
81     'native_libraries_java_dir': '<(intermediate_dir)/native_libraries_java/',
82     'native_libraries_java_file': '<(native_libraries_java_dir)/NativeLibraries.java',
83     'native_libraries_java_stamp': '<(intermediate_dir)/native_libraries_java.stamp',
84     'native_libraries_template_data_dir': '<(intermediate_dir)/native_libraries/',
85     'native_libraries_template_data_file': '<(native_libraries_template_data_dir)/native_libraries_array.h',
86     'native_libraries_template_version_file': '<(native_libraries_template_data_dir)/native_libraries_version.h',
87     'compile_stamp': '<(intermediate_dir)/compile.stamp',
88     'lint_stamp': '<(intermediate_dir)/lint.stamp',
89     'lint_result': '<(intermediate_dir)/lint_result.xml',
90     'lint_config': '<(intermediate_dir)/lint_config.xml',
91     'never_lint%': 0,
92     'instr_stamp': '<(intermediate_dir)/instr.stamp',
93     'jar_stamp': '<(intermediate_dir)/jar.stamp',
94     'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp',
95     'strip_stamp': '<(intermediate_dir)/strip.stamp',
96     'classes_dir': '<(intermediate_dir)/classes',
97     'classes_final_dir': '<(intermediate_dir)/classes_instr',
98     'javac_includes': [],
99     'jar_excluded_classes': [],
100     'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
101     'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar',
102     'dex_path': '<(intermediate_dir)/classes.dex',
103     'emma_device_jar': '<(android_sdk_root)/tools/lib/emma_device.jar',
104     'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml',
105     'push_stamp': '<(intermediate_dir)/push.stamp',
106     'link_stamp': '<(intermediate_dir)/link.stamp',
107     'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp',
108     'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk',
109     'final_apk_path%': '<(PRODUCT_DIR)/apks/<(apk_name).apk',
110     'incomplete_apk_path': '<(intermediate_dir)/<(apk_name)-incomplete.apk',
111     'apk_install_record': '<(intermediate_dir)/apk_install.record.stamp',
112     'device_intermediate_dir': '/data/local/tmp/chromium/<(_target_name)/<(CONFIGURATION_NAME)',
113     'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh',
114     'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh',
115     'create_standalone_apk%': 1,
116     'variables': {
117       'variables': {
118         'native_lib_target%': '',
119         'native_lib_version_name%': '',
120         'use_chromium_linker%' : 0,
121         'enable_chromium_linker_tests%': 0,
122         'is_test_apk%': 0,
123       },
124       'conditions': [
125         ['gyp_managed_install == 1 and native_lib_target != ""', {
126           'unsigned_standalone_apk_path': '<(intermediate_dir)/<(apk_name)-standalone-unsigned.apk',
127         }, {
128           'unsigned_standalone_apk_path': '<(unsigned_apk_path)',
129         }],
130         ['gyp_managed_install == 1', {
131           'apk_package_native_libs_dir': '<(intermediate_dir)/libs.managed',
132         }, {
133           'apk_package_native_libs_dir': '<(intermediate_dir)/libs',
134         }],
135         ['is_test_apk == 0 and emma_coverage != 0', {
136           'emma_instrument%': 1,
137         },{
138           'emma_instrument%': 0,
139         }],
140       ],
141     },
142     'native_lib_target%': '',
143     'native_lib_version_name%': '',
144     'use_chromium_linker%' : 0,
145     'enable_chromium_linker_tests%': 0,
146     'emma_instrument%': '<(emma_instrument)',
147     'apk_package_native_libs_dir': '<(apk_package_native_libs_dir)',
148     'unsigned_standalone_apk_path': '<(unsigned_standalone_apk_path)',
149     'extra_native_libs': [],
150   },
151   # Pass the jar path to the apk's "fake" jar target.  This would be better as
152   # direct_dependent_settings, but a variable set by a direct_dependent_settings
153   # cannot be lifted in a dependent to all_dependent_settings.
154   'all_dependent_settings': {
155     'variables': {
156       'apk_output_jar_path': '<(jar_path)',
157     },
158   },
159   'conditions': [
160     ['resource_dir!=""', {
161       'variables': {
162         'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ]
163       },
164     }],
165     ['R_package != ""', {
166       'variables': {
167         # We generate R.java in package R_package (in addition to the package
168         # listed in the AndroidManifest.xml, which is unavoidable).
169         'additional_res_dirs': ['<(DEPTH)/build/android/ant/empty/res'],
170         'additional_res_packages': ['<(R_package)'],
171         'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'],
172       },
173     }],
174     ['native_lib_target != "" and component == "shared_library"', {
175       'dependencies': [
176         '<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
177       ],
178     }],
179     ['use_chromium_linker == 1', {
180       'dependencies': [
181         '<(DEPTH)/base/base.gyp:chromium_android_linker',
182       ],
183     }],
184     ['native_lib_target != ""', {
185       'variables': {
186         'generated_src_dirs': [ '<(native_libraries_java_dir)' ],
187         'native_libs_paths': [
188           '<(SHARED_LIB_DIR)/<(native_lib_target).>(android_product_extension)'
189         ],
190         'package_input_paths': [
191           '<(apk_package_native_libs_dir)/<(android_app_abi)/gdbserver',
192         ],
193       },
194       'copies': [
195         {
196           # gdbserver is always copied into the APK's native libs dir. The ant
197           # build scripts (apkbuilder task) will only include it in a debug
198           # build.
199           'destination': '<(apk_package_native_libs_dir)/<(android_app_abi)',
200           'files': [
201             '<(android_gdbserver)',
202           ],
203         },
204       ],
205       'actions': [
206         {
207           'variables': {
208             'conditions': [
209               ['use_chromium_linker == 1', {
210                 'variables': {
211                   'linker_input_libraries': [
212                     '<(SHARED_LIB_DIR)/libchromium_android_linker.>(android_product_extension)',
213                   ],
214                 }
215               }, {
216                 'variables': {
217                   'linker_input_libraries': [],
218                 },
219               }],
220             ],
221             'input_libraries': [
222               '<@(native_libs_paths)',
223               '<@(extra_native_libs)',
224               '<@(linker_input_libraries)',
225             ],
226           },
227           'includes': ['../build/android/write_ordered_libraries.gypi'],
228         },
229         {
230           'action_name': 'native_libraries_template_data_<(_target_name)',
231           'message': 'Creating native_libraries_list.h for <(_target_name)',
232           'inputs': [
233             '<(DEPTH)/build/android/gyp/util/build_utils.py',
234             '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
235             '<(ordered_libraries_file)',
236           ],
237           'outputs': [
238             '<(native_libraries_template_data_file)',
239             '<(native_libraries_template_version_file)',
240           ],
241           'action': [
242             'python', '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
243             '--ordered-libraries=<(ordered_libraries_file)',
244             '--version-name=<(native_lib_version_name)',
245             '--native-library-list=<(native_libraries_template_data_file)',
246             '--version-output=<(native_libraries_template_version_file)',
247           ],
248         },
249         {
250           'action_name': 'native_libraries_<(_target_name)',
251           'variables': {
252             'conditions': [
253               ['use_chromium_linker == 1', {
254                 'variables': {
255                   'linker_gcc_preprocess_defines': [
256                     '--defines', 'ENABLE_CHROMIUM_LINKER',
257                   ],
258                 }
259               }, {
260                 'variables': {
261                   'linker_gcc_preprocess_defines': [],
262                 },
263               }],
264               ['enable_chromium_linker_tests == 1', {
265                 'variables': {
266                   'linker_tests_gcc_preprocess_defines': [
267                     '--defines', 'ENABLE_CHROMIUM_LINKER_TESTS',
268                   ],
269                 }
270               }, {
271                 'variables': {
272                   'linker_tests_gcc_preprocess_defines': [],
273                 },
274               }],
275             ],
276             'gcc_preprocess_defines': [
277               '<@(linker_gcc_preprocess_defines)',
278               '<@(linker_tests_gcc_preprocess_defines)',
279             ],
280           },
281           'message': 'Creating NativeLibraries.java for <(_target_name)',
282           'inputs': [
283             '<(DEPTH)/build/android/gyp/util/build_utils.py',
284             '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
285             '<(native_libraries_template_data_file)',
286             '<(native_libraries_template_version_file)',
287             '<(native_libraries_template)',
288           ],
289           'outputs': [
290             '<(native_libraries_java_stamp)',
291           ],
292           'action': [
293             'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
294             '--include-path=<(native_libraries_template_data_dir)',
295             '--output=<(native_libraries_java_file)',
296             '--template=<(native_libraries_template)',
297             '--stamp=<(native_libraries_java_stamp)',
298             '<@(gcc_preprocess_defines)',
299           ],
300         },
301         {
302           'action_name': 'strip_native_libraries',
303           'variables': {
304             'ordered_libraries_file%': '<(ordered_libraries_file)',
305             'stripped_libraries_dir': '<(libraries_source_dir)',
306             'input_paths': [
307               '<@(native_libs_paths)',
308               '<@(extra_native_libs)',
309             ],
310             'stamp': '<(strip_stamp)'
311           },
312           'includes': ['../build/android/strip_native_libraries.gypi'],
313         },
314       ],
315       'conditions': [
316         ['gyp_managed_install == 1', {
317           'variables': {
318             'libraries_top_dir': '<(intermediate_dir)/lib.stripped',
319             'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)',
320             'device_library_dir': '<(device_intermediate_dir)/lib.stripped',
321             'configuration_name': '<(CONFIGURATION_NAME)',
322           },
323           'dependencies': [
324             '<(DEPTH)/build/android/setup.gyp:get_build_device_configurations',
325           ],
326           'actions': [
327             {
328               'includes': ['../build/android/push_libraries.gypi'],
329             },
330             {
331               'action_name': 'create device library symlinks',
332               'message': 'Creating links on device for <(_target_name)',
333               'inputs': [
334                 '<(DEPTH)/build/android/gyp/util/build_utils.py',
335                 '<(DEPTH)/build/android/gyp/create_device_library_links.py',
336                 '<(apk_install_record)',
337                 '<(build_device_config_path)',
338                 '<(ordered_libraries_file)',
339               ],
340               'outputs': [
341                 '<(link_stamp)'
342               ],
343               'action': [
344                 'python', '<(DEPTH)/build/android/gyp/create_device_library_links.py',
345                 '--build-device-configuration=<(build_device_config_path)',
346                 '--libraries-json=<(ordered_libraries_file)',
347                 '--script-host-path=<(symlink_script_host_path)',
348                 '--script-device-path=<(symlink_script_device_path)',
349                 '--target-dir=<(device_library_dir)',
350                 '--apk=<(incomplete_apk_path)',
351                 '--stamp=<(link_stamp)',
352                 '--configuration-name=<(CONFIGURATION_NAME)',
353               ],
354             },
355           ],
356           'conditions': [
357             ['create_standalone_apk == 1', {
358               'actions': [
359                 {
360                   'action_name': 'create standalone APK',
361                   'variables': {
362                     'inputs': [
363                       '<(ordered_libraries_file)',
364                       '<(strip_stamp)',
365                     ],
366                     'input_apk_path': '<(unsigned_apk_path)',
367                     'output_apk_path': '<(unsigned_standalone_apk_path)',
368                     'libraries_top_dir%': '<(libraries_top_dir)',
369                   },
370                   'includes': [ 'android/create_standalone_apk_action.gypi' ],
371                 },
372               ],
373             }],
374           ],
375         }, {
376           # gyp_managed_install != 1
377           'variables': {
378             'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_app_abi)',
379             'package_input_paths': [ '<(strip_stamp)' ],
380           },
381         }],
382       ],
383     }], # native_lib_target != ''
384     ['gyp_managed_install == 0 or create_standalone_apk == 1', {
385       'actions': [
386         {
387           'action_name': 'finalize standalone apk',
388           'variables': {
389             'input_apk_path': '<(unsigned_standalone_apk_path)',
390             'output_apk_path': '<(final_apk_path)',
391           },
392           'includes': [ 'android/finalize_apk_action.gypi']
393         },
394       ],
395     }],
396     ['java_strings_grd != ""', {
397       'variables': {
398         'res_grit_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res_grit',
399         'additional_res_dirs': ['<(res_grit_dir)'],
400         # grit_grd_file is used by grit_action.gypi, included below.
401         'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)',
402         'resource_input_paths': [
403           '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(res_grit_dir)" <(grit_grd_file))'
404         ],
405       },
406       'actions': [
407         {
408           'action_name': 'generate_localized_strings_xml',
409           'variables': {
410             'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=false'],
411             'grit_out_dir': '<(res_grit_dir)',
412             # resource_ids is unneeded since we don't generate .h headers.
413             'grit_resource_ids': '',
414           },
415           'includes': ['../build/grit_action.gypi'],
416         },
417       ],
418     }],
419     ['gyp_managed_install == 1', {
420       'actions': [
421         {
422           'action_name': 'finalize incomplete apk',
423           'variables': {
424             'input_apk_path': '<(unsigned_apk_path)',
425             'output_apk_path': '<(incomplete_apk_path)',
426           },
427           'includes': [ 'android/finalize_apk_action.gypi']
428         },
429         {
430           'action_name': 'apk_install_<(_target_name)',
431           'message': 'Installing <(apk_name).apk',
432           'inputs': [
433             '<(DEPTH)/build/android/gyp/util/build_utils.py',
434             '<(DEPTH)/build/android/gyp/apk_install.py',
435             '<(build_device_config_path)',
436             '<(incomplete_apk_path)',
437           ],
438           'outputs': [
439             '<(apk_install_record)',
440           ],
441           'action': [
442             'python', '<(DEPTH)/build/android/gyp/apk_install.py',
443             '--apk-path=<(incomplete_apk_path)',
444             '--build-device-configuration=<(build_device_config_path)',
445             '--install-record=<(apk_install_record)',
446             '--configuration-name=<(CONFIGURATION_NAME)',
447           ],
448         },
449       ],
450     }],
451     ['is_test_apk == 1', {
452       'dependencies': [
453         '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
454       ]
455     }],
456   ],
457   'dependencies': [
458     '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum',
459   ],
460   'actions': [
461     {
462       'action_name': 'ant_codegen_<(_target_name)',
463       'message': 'Generating R.java for <(_target_name)',
464       'conditions': [
465         ['is_test_apk == 1', {
466           'variables': {
467             'additional_res_dirs=': [],
468             'additional_res_packages=': [],
469           }
470         }],
471       ],
472       'variables': {
473         # Write the inputs list to a file, so that its mtime is updated when
474         # the list of inputs changes.
475         'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))'
476       },
477       'inputs': [
478         '<(DEPTH)/build/android/ant/apk-codegen.xml',
479         '<(DEPTH)/build/android/gyp/util/build_utils.py',
480         '<(DEPTH)/build/android/gyp/ant.py',
481         '<(android_manifest_path)',
482         '>@(additional_input_paths)',
483         '>@(resource_input_paths)',
484         '>(inputs_list_file)',
485       ],
486       'outputs': [
487         '<(codegen_stamp)',
488       ],
489       'action': [
490         'python', '<(DEPTH)/build/android/gyp/ant.py',
491         '-quiet',
492         '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)',
493         '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)',
494         '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)',
495         '-DANDROID_MANIFEST=<(android_manifest_path)',
496         '-DANDROID_SDK_JAR=<(android_sdk_jar)',
497         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
498         '-DANDROID_SDK_VERSION=<(android_sdk_version)',
499         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
500         '-DOUT_DIR=<(intermediate_dir)',
501         '-DRESOURCE_DIR=<(resource_dir)',
503         '-DSTAMP=<(codegen_stamp)',
504         '-Dbasedir=.',
505         '-buildfile',
506         '<(DEPTH)/build/android/ant/apk-codegen.xml',
507       ],
508     },
509     {
510       'action_name': 'javac_<(_target_name)',
511       'message': 'Compiling java for <(_target_name)',
512       'variables': {
513         'gen_src_dirs': [
514           '<(intermediate_dir)/gen',
515           '>@(generated_src_dirs)',
516         ],
517         # If there is a separate find for additional_src_dirs, it will find the
518         # wrong .java files when additional_src_dirs is empty.
519         # TODO(thakis): Gyp caches >! evaluation by command. Both java.gypi and
520         # java_apk.gypi evaluate the same command, and at the moment two targets
521         # set java_in_dir to "java". Add a dummy comment here to make sure
522         # that the two targets (one uses java.gypi, the other java_apk.gypi)
523         # get distinct source lists. Medium-term, make targets list all their
524         # Java files instead of using find. (As is, this will be broken if two
525         # targets use the same java_in_dir and both use java_apk.gypi or
526         # both use java.gypi.)
527         'java_sources': ['>!@(find >(java_in_dir)/src >(additional_src_dirs) -name "*.java"  # apk)'],
529       },
530       'inputs': [
531         '<(DEPTH)/build/android/gyp/util/build_utils.py',
532         '<(DEPTH)/build/android/gyp/javac.py',
533         '>@(java_sources)',
534         '>@(input_jars_paths)',
535         '<(codegen_stamp)',
536       ],
537       'conditions': [
538         ['native_lib_target != ""', {
539           'inputs': [ '<(native_libraries_java_stamp)' ],
540         }],
541       ],
542       'outputs': [
543         '<(compile_stamp)',
544       ],
545       'action': [
546         'python', '<(DEPTH)/build/android/gyp/javac.py',
547         '--output-dir=<(classes_dir)',
548         '--classpath=>(input_jars_paths) <(android_sdk_jar)',
549         '--src-gendirs=>(gen_src_dirs)',
550         '--javac-includes=<(javac_includes)',
551         '--chromium-code=<(chromium_code)',
552         '--stamp=<(compile_stamp)',
553         '>@(java_sources)',
554       ],
555     },
556     {
557       'variables': {
558         'src_dirs': [
559           '<(java_in_dir)/src',
560           '>@(additional_src_dirs)',
561         ],
562         'stamp_path': '<(lint_stamp)',
563         'result_path': '<(lint_result)',
564         'config_path': '<(lint_config)',
565       },
566       'inputs': [
567         '<(compile_stamp)',
568       ],
569       'outputs': [
570         '<(lint_stamp)',
571       ],
572       'includes': [ 'android/lint_action.gypi' ],
573     },
574     {
575       'action_name': 'instr_classes_<(_target_name)',
576       'message': 'Instrumenting <(_target_name) classes',
577       'variables': {
578         'input_path': '<(classes_dir)',
579         'output_path': '<(classes_final_dir)',
580         'stamp_path': '<(instr_stamp)',
581         'instr_type': 'classes',
582       },
583       'inputs': [
584         '<(compile_stamp)',
585       ],
586       'outputs': [
587         '<(instr_stamp)',
588       ],
589       'includes': [ 'android/instr_action.gypi' ],
590     },
591     {
592       'action_name': 'jar_<(_target_name)',
593       'message': 'Creating <(_target_name) jar',
594       'inputs': [
595         '<(DEPTH)/build/android/gyp/util/build_utils.py',
596         '<(DEPTH)/build/android/gyp/util/md5_check.py',
597         '<(DEPTH)/build/android/gyp/jar.py',
598         '<(instr_stamp)',
599       ],
600       'outputs': [
601         '<(jar_stamp)',
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': 'ant_obfuscate_<(_target_name)',
613       'message': 'Obfuscating <(_target_name)',
614       'inputs': [
615         '<(DEPTH)/build/android/ant/apk-obfuscate.xml',
616         '<(DEPTH)/build/android/gyp/util/build_utils.py',
617         '<(DEPTH)/build/android/gyp/ant.py',
618         '<(android_manifest_path)',
619         '>@(proguard_flags_paths)',
620         '<(instr_stamp)',
621       ],
622       'outputs': [
623         # This lists obfuscate_stamp instead of obfuscated_jar_path because
624         # ant only writes the latter if the md5 of the inputs changes.
625         '<(obfuscate_stamp)',
626       ],
627       'action': [
628         'python', '<(DEPTH)/build/android/gyp/ant.py',
629         '-quiet',
630         '-DANDROID_MANIFEST=<(android_manifest_path)',
631         '-DANDROID_SDK_JAR=<(android_sdk_jar)',
632         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
633         '-DANDROID_SDK_VERSION=<(android_sdk_version)',
634         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
635         '-DAPK_NAME=<(apk_name)',
636         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
637         '-DINPUT_JARS_PATHS=>(input_jars_paths)',
638         '-DIS_TEST_APK=<(is_test_apk)',
639         '-DOBFUSCATED_JAR_PATH=<(obfuscated_jar_path)',
640         '-DOUT_DIR=<(intermediate_dir)',
641         '-DPROGUARD_ENABLED=<(proguard_enabled)',
642         '-DPROGUARD_FLAGS=<(proguard_flags_paths)',
643         '-DTEST_JAR_PATH=<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar',
645         '-DSTAMP=<(obfuscate_stamp)',
646         '-Dbasedir=.',
647         '-buildfile',
648         '<(DEPTH)/build/android/ant/apk-obfuscate.xml',
649       ],
650     },
651     {
652       'action_name': 'dex_<(_target_name)',
653       'variables': {
654         'conditions': [
655           ['emma_instrument != 0', {
656             'dex_no_locals': 1,
657             'dex_input_paths': [ '<(emma_device_jar)' ],
658           }],
659         ],
660         'dex_input_paths': [ '>@(library_dexed_jars_paths)' ],
661         'dex_generated_input_dirs': [ '<(classes_final_dir)' ],
662         'output_path': '<(dex_path)',
663         'proguard_enabled_input_path': '<(obfuscated_jar_path)',
664       },
665       'conditions': [
666         ['proguard_enabled == "true"', { 'inputs': [ '<(obfuscate_stamp)' ] },
667                                        { 'inputs': [ '<(instr_stamp)' ] }],
668       ],
669       'includes': [ 'android/dex_action.gypi' ],
670     },
671     {
672       'action_name': 'ant package resources',
673       'message': 'Packaging resources for <(_target_name) APK',
674       'inputs': [
675         '<(DEPTH)/build/android/ant/apk-package-resources.xml',
676         '<(DEPTH)/build/android/gyp/util/build_utils.py',
677         '<(DEPTH)/build/android/gyp/ant.py',
678         '<(android_manifest_path)',
679         '<(codegen_stamp)',
680         # TODO: This isn't always rerun correctly, http://crbug.com/351928
682         '>@(additional_input_paths)',
683       ],
684       'conditions': [
685         ['is_test_apk == 1', {
686           'variables': {
687             'additional_res_dirs=': [],
688             'additional_res_packages=': [],
689           }
690         }],
691       ],
692       'outputs': [
693         '<(package_resources_stamp)',
694       ],
695       'action': [
696         'python', '<(DEPTH)/build/android/gyp/ant.py',
697         '-quiet',
698         '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)',
699         '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)',
700         '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)',
701         '-DANDROID_MANIFEST=<(android_manifest_path)',
702         '-DANDROID_SDK_JAR=<(android_sdk_jar)',
703         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
704         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
705         '-DAPK_NAME=<(apk_name)',
706         '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)',
707         '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)',
708         '-DASSET_DIR=<(asset_location)',
709         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
710         '-DOUT_DIR=<(intermediate_dir)',
711         '-DRESOURCE_DIR=<(resource_dir)',
713         '-DSTAMP=<(package_resources_stamp)',
715         '-Dbasedir=.',
716         '-buildfile',
717         '<(DEPTH)/build/android/ant/apk-package-resources.xml',
718       ]
719     },
720     {
721       'action_name': 'ant_package_<(_target_name)',
722       'message': 'Packaging <(_target_name)',
723       'variables': {
724         # Write the inputs list to a file, so that its mtime is updated when
725         # the list of inputs changes.
726         'inputs_list_file': '>|(apk_package.<(_target_name).gypcmd >@(package_input_paths))'
727       },
728       'inputs': [
729         '<(DEPTH)/build/android/ant/apk-package.xml',
730         '<(DEPTH)/build/android/gyp/util/build_utils.py',
731         '<(DEPTH)/build/android/gyp/ant.py',
732         '<(dex_path)',
733         '<(codegen_stamp)',
734         '<(obfuscate_stamp)',
735         '<(package_resources_stamp)',
736         '>@(package_input_paths)',
737         '>(inputs_list_file)',
738       ],
739       'outputs': [
740         '<(unsigned_apk_path)',
741       ],
742       'action': [
743         'python', '<(DEPTH)/build/android/gyp/ant.py',
744         '-quiet',
745         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
746         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
747         '-DAPK_NAME=<(apk_name)',
748         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
749         '-DNATIVE_LIBS_DIR=<(apk_package_native_libs_dir)',
750         '-DOUT_DIR=<(intermediate_dir)',
751         '-DUNSIGNED_APK_PATH=<(unsigned_apk_path)',
752         '-DEMMA_INSTRUMENT=<(emma_instrument)',
753         '-DEMMA_DEVICE_JAR=<(emma_device_jar)',
755         '-Dbasedir=.',
756         '-buildfile',
757         '<(DEPTH)/build/android/ant/apk-package.xml',
758       ]
759     },
760   ],