Revert 250826 "Remove Profile dependency from apps::ShellWindow"
[chromium-blink-merge.git] / build / java_apk.gypi
blobbf841fe90616551277e0103aeed0581f3a472e69
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 #  library_manifest_paths'- Paths to additional AndroidManifest.xml files from
50 #    libraries.
51 #  use_chromium_linker - Enable the content dynamic linker that allows sharing the
52 #    RELRO section of the native libraries between the different processes.
53 #  enable_chromium_linker_tests - Enable the content dynamic linker test support
54 #    code. This allows a test APK to inject a Linker.TestRunner instance at
55 #    runtime. Should only be used by the chromium_linker_test_apk target!!
56 #  never_lint - Set to 1 to not run lint on this target.
58   'variables': {
59     'additional_input_paths': [],
60     'input_jars_paths': [],
61     'library_dexed_jars_paths': [],
62     'additional_src_dirs': [],
63     'generated_src_dirs': [],
64     'app_manifest_version_name%': '<(android_app_version_name)',
65     'app_manifest_version_code%': '<(android_app_version_code)',
66     'proguard_enabled%': 'false',
67     'proguard_flags_paths%': ['<(DEPTH)/build/android/empty_proguard.flags'],
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     'additional_res_dirs': [],
73     'additional_res_packages': [],
74     'is_test_apk%': 0,
75     'java_strings_grd%': '',
76     'library_manifest_paths' : [],
77     'resource_input_paths': [],
78     'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)',
79     'asset_location%': '<(intermediate_dir)/assets',
80     'codegen_stamp': '<(intermediate_dir)/codegen.stamp',
81     'compile_input_paths': [],
82     'package_input_paths': [],
83     'ordered_libraries_file': '<(intermediate_dir)/native_libraries.json',
84     'native_libraries_template': '<(DEPTH)/base/android/java/templates/NativeLibraries.template',
85     'native_libraries_java_dir': '<(intermediate_dir)/native_libraries_java/',
86     'native_libraries_java_file': '<(native_libraries_java_dir)/NativeLibraries.java',
87     'native_libraries_java_stamp': '<(intermediate_dir)/native_libraries_java.stamp',
88     'native_libraries_template_data_dir': '<(intermediate_dir)/native_libraries/',
89     'native_libraries_template_data_file': '<(native_libraries_template_data_dir)/native_libraries_array.h',
90     'native_libraries_template_version_file': '<(native_libraries_template_data_dir)/native_libraries_version.h',
91     'compile_stamp': '<(intermediate_dir)/compile.stamp',
92     'lint_stamp': '<(intermediate_dir)/lint.stamp',
93     'lint_result': '<(intermediate_dir)/lint_result.xml',
94     'lint_config': '<(intermediate_dir)/lint_config.xml',
95     'never_lint%': 0,
96     'instr_stamp': '<(intermediate_dir)/instr.stamp',
97     'jar_stamp': '<(intermediate_dir)/jar.stamp',
98     'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp',
99     'strip_stamp': '<(intermediate_dir)/strip.stamp',
100     'classes_dir': '<(intermediate_dir)/classes',
101     'classes_final_dir': '<(intermediate_dir)/classes_instr',
102     'javac_includes': [],
103     'jar_excluded_classes': [],
104     'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
105     'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar',
106     'dex_path': '<(intermediate_dir)/classes.dex',
107     'emma_device_jar': '<(android_sdk_root)/tools/lib/emma_device.jar',
108     'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml',
109     'push_stamp': '<(intermediate_dir)/push.stamp',
110     'link_stamp': '<(intermediate_dir)/link.stamp',
111     'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp',
112     'codegen_input_paths': [],
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     'source_dir': '<(java_in_dir)/src',
117     'apk_install_record': '<(intermediate_dir)/apk_install.record.stamp',
118     'device_intermediate_dir': '/data/local/tmp/chromium/<(_target_name)/<(CONFIGURATION_NAME)',
119     'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh',
120     'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh',
121     'create_standalone_apk%': 1,
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   },
157   # Pass the jar path to the apk's "fake" jar target.  This would be better as
158   # direct_dependent_settings, but a variable set by a direct_dependent_settings
159   # cannot be lifted in a dependent to all_dependent_settings.
160   'all_dependent_settings': {
161     'variables': {
162       'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
163     },
164   },
165   'conditions': [
166     ['resource_dir!=""', {
167       'variables': {
168         'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ]
169       },
170     }],
171     ['R_package != ""', {
172       'variables': {
173         # We generate R.java in package R_package (in addition to the package
174         # listed in the AndroidManifest.xml, which is unavoidable).
175         'additional_res_dirs': ['<(DEPTH)/build/android/ant/empty/res'],
176         'additional_res_packages': ['<(R_package)'],
177         'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'],
178       },
179     }],
180     ['native_lib_target != "" and component == "shared_library"', {
181       'dependencies': [
182         '<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
183       ],
184     }],
185     ['use_chromium_linker == 1', {
186       'dependencies': [
187         '<(DEPTH)/base/base.gyp:chromium_android_linker',
188       ],
189     }],
190     ['native_lib_target != ""', {
191       'variables': {
192         'compile_input_paths': [ '<(native_libraries_java_stamp)' ],
193         'generated_src_dirs': [ '<(native_libraries_java_dir)' ],
194         'native_libs_paths': [
195           '<(SHARED_LIB_DIR)/<(native_lib_target).>(android_product_extension)'
196         ],
197         'package_input_paths': [
198           '<(apk_package_native_libs_dir)/<(android_app_abi)/gdbserver',
199         ],
200       },
201       'copies': [
202         {
203           # gdbserver is always copied into the APK's native libs dir. The ant
204           # build scripts (apkbuilder task) will only include it in a debug
205           # build.
206           'destination': '<(apk_package_native_libs_dir)/<(android_app_abi)',
207           'files': [
208             '<(android_gdbserver)',
209             '<@(extra_native_libs)',
210           ],
211         },
212       ],
213       'actions': [
214         {
215           'variables': {
216             'conditions': [
217               ['use_chromium_linker == 1', {
218                 'variables': {
219                   'linker_input_libraries': [
220                     '<(SHARED_LIB_DIR)/libchromium_android_linker.>(android_product_extension)',
221                   ],
222                 }
223               }, {
224                 'variables': {
225                   'linker_input_libraries': [],
226                 },
227               }],
228             ],
229             'input_libraries': [
230               '<@(native_libs_paths)',
231               '<@(extra_native_libs)',
232               '<@(linker_input_libraries)',
233             ],
234           },
235           'includes': ['../build/android/write_ordered_libraries.gypi'],
236         },
237         {
238           'action_name': 'native_libraries_template_data_<(_target_name)',
239           'message': 'Creating native_libraries_list.h for <(_target_name)',
240           'inputs': [
241             '<(DEPTH)/build/android/gyp/util/build_utils.py',
242             '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
243             '<(ordered_libraries_file)',
244           ],
245           'outputs': [
246             '<(native_libraries_template_data_file)',
247             '<(native_libraries_template_version_file)',
248           ],
249           'action': [
250             'python', '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
251             '--ordered-libraries=<(ordered_libraries_file)',
252             '--version-name=<(native_lib_version_name)',
253             '--native-library-list=<(native_libraries_template_data_file)',
254             '--version-output=<(native_libraries_template_version_file)',
255           ],
256         },
257         {
258           'action_name': 'native_libraries_<(_target_name)',
259           'variables': {
260             'conditions': [
261               ['use_chromium_linker == 1', {
262                 'variables': {
263                   'linker_gcc_preprocess_defines': [
264                     '--defines', 'ENABLE_CHROMIUM_LINKER',
265                   ],
266                 }
267               }, {
268                 'variables': {
269                   'linker_gcc_preprocess_defines': [],
270                 },
271               }],
272               ['enable_chromium_linker_tests == 1', {
273                 'variables': {
274                   'linker_tests_gcc_preprocess_defines': [
275                     '--defines', 'ENABLE_CHROMIUM_LINKER_TESTS',
276                   ],
277                 }
278               }, {
279                 'variables': {
280                   'linker_tests_gcc_preprocess_defines': [],
281                 },
282               }],
283             ],
284             'gcc_preprocess_defines': [
285               '<@(linker_gcc_preprocess_defines)',
286               '<@(linker_tests_gcc_preprocess_defines)',
287             ],
288           },
289           'message': 'Creating NativeLibraries.java for <(_target_name)',
290           'inputs': [
291             '<(DEPTH)/build/android/gyp/util/build_utils.py',
292             '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
293             '<(native_libraries_template_data_file)',
294             '<(native_libraries_template_version_file)',
295             '<(native_libraries_template)',
296           ],
297           'outputs': [
298             '<(native_libraries_java_stamp)',
299           ],
300           'action': [
301             'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
302             '--include-path=<(native_libraries_template_data_dir)',
303             '--output=<(native_libraries_java_file)',
304             '--template=<(native_libraries_template)',
305             '--stamp=<(native_libraries_java_stamp)',
306             '<@(gcc_preprocess_defines)',
307           ],
308         },
309         {
310           'action_name': 'strip_native_libraries',
311           'variables': {
312             'ordered_libraries_file%': '<(ordered_libraries_file)',
313             'stripped_libraries_dir': '<(libraries_source_dir)',
314             'input_paths': [
315               '<@(native_libs_paths)',
316               '<@(extra_native_libs)',
317             ],
318             'stamp': '<(strip_stamp)'
319           },
320           'includes': ['../build/android/strip_native_libraries.gypi'],
321         },
322       ],
323       'conditions': [
324         ['gyp_managed_install == 1', {
325           'variables': {
326             'libraries_top_dir': '<(intermediate_dir)/lib.stripped',
327             'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)',
328             'device_library_dir': '<(device_intermediate_dir)/lib.stripped',
329             'configuration_name': '<(CONFIGURATION_NAME)',
330           },
331           'dependencies': [
332             '<(DEPTH)/build/android/setup.gyp:get_build_device_configurations',
333           ],
334           'actions': [
335             {
336               'includes': ['../build/android/push_libraries.gypi'],
337             },
338             {
339               'action_name': 'create device library symlinks',
340               'message': 'Creating links on device for <(_target_name)',
341               'inputs': [
342                 '<(DEPTH)/build/android/gyp/util/build_utils.py',
343                 '<(DEPTH)/build/android/gyp/create_device_library_links.py',
344                 '<(apk_install_record)',
345                 '<(build_device_config_path)',
346                 '<(ordered_libraries_file)',
347               ],
348               'outputs': [
349                 '<(link_stamp)'
350               ],
351               'action': [
352                 'python', '<(DEPTH)/build/android/gyp/create_device_library_links.py',
353                 '--build-device-configuration=<(build_device_config_path)',
354                 '--libraries-json=<(ordered_libraries_file)',
355                 '--script-host-path=<(symlink_script_host_path)',
356                 '--script-device-path=<(symlink_script_device_path)',
357                 '--target-dir=<(device_library_dir)',
358                 '--apk=<(incomplete_apk_path)',
359                 '--stamp=<(link_stamp)',
360                 '--configuration-name=<(CONFIGURATION_NAME)',
361               ],
362             },
363           ],
364           'conditions': [
365             ['create_standalone_apk == 1', {
366               'actions': [
367                 {
368                   'action_name': 'create standalone APK',
369                   'variables': {
370                     'inputs': [
371                       '<(ordered_libraries_file)',
372                       '<(strip_stamp)',
373                     ],
374                     'input_apk_path': '<(unsigned_apk_path)',
375                     'output_apk_path': '<(unsigned_standalone_apk_path)',
376                     'libraries_top_dir%': '<(libraries_top_dir)',
377                   },
378                   'includes': [ 'android/create_standalone_apk_action.gypi' ],
379                 },
380               ],
381             }],
382           ],
383         }, {
384           # gyp_managed_install != 1
385           'variables': {
386             'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_app_abi)',
387             'package_input_paths': [ '<(strip_stamp)' ],
388           },
389         }],
390       ],
391     }], # native_lib_target != ''
392     ['gyp_managed_install == 0 or create_standalone_apk == 1', {
393       'actions': [
394         {
395           'action_name': 'finalize standalone apk',
396           'variables': {
397             'input_apk_path': '<(unsigned_standalone_apk_path)',
398             'output_apk_path': '<(final_apk_path)',
399           },
400           'includes': [ 'android/finalize_apk_action.gypi']
401         },
402       ],
403     }],
404     ['java_strings_grd != ""', {
405       'variables': {
406         'res_grit_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res_grit',
407         'additional_res_dirs': ['<(res_grit_dir)'],
408         # grit_grd_file is used by grit_action.gypi, included below.
409         'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)',
410         'resource_input_paths': [
411           '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(res_grit_dir)" <(grit_grd_file))'
412         ],
413       },
414       'actions': [
415         {
416           'action_name': 'generate_localized_strings_xml',
417           'variables': {
418             'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=false'],
419             'grit_out_dir': '<(res_grit_dir)',
420             # resource_ids is unneeded since we don't generate .h headers.
421             'grit_resource_ids': '',
422           },
423           'includes': ['../build/grit_action.gypi'],
424         },
425       ],
426     }],
427     ['gyp_managed_install == 1', {
428       'actions': [
429         {
430           'action_name': 'finalize incomplete apk',
431           'variables': {
432             'input_apk_path': '<(unsigned_apk_path)',
433             'output_apk_path': '<(incomplete_apk_path)',
434           },
435           'includes': [ 'android/finalize_apk_action.gypi']
436         },
437         {
438           'action_name': 'apk_install_<(_target_name)',
439           'message': 'Installing <(apk_name).apk',
440           'inputs': [
441             '<(DEPTH)/build/android/gyp/util/build_utils.py',
442             '<(DEPTH)/build/android/gyp/apk_install.py',
443             '<(build_device_config_path)',
444             '<(incomplete_apk_path)',
445           ],
446           'outputs': [
447             '<(apk_install_record)',
448           ],
449           'action': [
450             'python', '<(DEPTH)/build/android/gyp/apk_install.py',
451             '--apk-path=<(incomplete_apk_path)',
452             '--build-device-configuration=<(build_device_config_path)',
453             '--install-record=<(apk_install_record)',
454             '--configuration-name=<(CONFIGURATION_NAME)',
455           ],
456         },
457       ],
458     }],
459     ['is_test_apk == 1', {
460       'dependencies': [
461         '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
462       ]
463     }],
464   ],
465   'dependencies': [
466     '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum',
467   ],
468   'actions': [
469     {
470       'action_name': 'ant_codegen_<(_target_name)',
471       'message': 'Generating R.java for <(_target_name)',
472       'conditions': [
473         ['is_test_apk == 1', {
474           'variables': {
475             'additional_res_dirs=': [],
476             'additional_res_packages=': [],
477           }
478         }],
479       ],
480       'inputs': [
481         '<(DEPTH)/build/android/ant/apk-codegen.xml',
482         '<(DEPTH)/build/android/gyp/util/build_utils.py',
483         '<(DEPTH)/build/android/gyp/ant.py',
484         '<(android_manifest_path)',
485         '>@(additional_input_paths)',
486         '>@(codegen_input_paths)',
487         '>@(library_manifest_paths)',
488         '>@(resource_input_paths)',
489       ],
490       'outputs': [
491         '<(codegen_stamp)',
492       ],
493       'action': [
494         'python', '<(DEPTH)/build/android/gyp/ant.py',
495         '-quiet',
496         '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)',
497         '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)',
498         '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)',
499         '-DANDROID_MANIFEST=<(android_manifest_path)',
500         '-DANDROID_SDK_JAR=<(android_sdk_jar)',
501         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
502         '-DANDROID_SDK_VERSION=<(android_sdk_version)',
503         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
504         '-DLIBRARY_MANIFEST_PATHS=>(library_manifest_paths)',
505         '-DOUT_DIR=<(intermediate_dir)',
506         '-DRESOURCE_DIR=<(resource_dir)',
508         '-DSTAMP=<(codegen_stamp)',
509         '-Dbasedir=.',
510         '-buildfile',
511         '<(DEPTH)/build/android/ant/apk-codegen.xml',
513         # Add list of inputs to the command line, so if inputs change
514         # (e.g. if a Java file is removed), the command will be re-run.
515         # TODO(newt): remove this once crbug.com/177552 is fixed in ninja.
516         '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)',
517       ],
518     },
519     {
520       'action_name': 'javac_<(_target_name)',
521       'message': 'Compiling java for <(_target_name)',
522       'variables': {
523         'all_src_dirs': [
524           '<(java_in_dir)/src',
525           '<(intermediate_dir)/gen',
526           '>@(additional_src_dirs)',
527           '>@(generated_src_dirs)',
528         ],
529       },
530       'inputs': [
531         '<(DEPTH)/build/android/gyp/util/build_utils.py',
532         '<(DEPTH)/build/android/gyp/javac.py',
533         # If there is a separate find for additional_src_dirs, it will find the
534         # wrong .java files when additional_src_dirs is empty.
535         '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")',
536         '>@(input_jars_paths)',
537         '<(codegen_stamp)',
538         '>@(compile_input_paths)',
539       ],
540       'outputs': [
541         '<(compile_stamp)',
542       ],
543       'action': [
544         'python', '<(DEPTH)/build/android/gyp/javac.py',
545         '--output-dir=<(classes_dir)',
546         '--classpath=>(input_jars_paths) <(android_sdk_jar)',
547         '--src-dirs=>(all_src_dirs)',
548         '--javac-includes=<(javac_includes)',
549         '--chromium-code=<(chromium_code)',
550         '--stamp=<(compile_stamp)',
552         # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
553         '--ignore=>!(echo \'>(_inputs)\' | md5sum)',
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         '<(instr_stamp)',
596         '<(DEPTH)/build/android/gyp/util/build_utils.py',
597         '<(DEPTH)/build/android/gyp/util/md5_check.py',
598         '<(DEPTH)/build/android/gyp/jar.py',
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)',
610         # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
611         '--ignore=>!(echo \'>(_inputs)\' | md5sum)',
612       ]
613     },
614     {
615       'action_name': 'ant_obfuscate_<(_target_name)',
616       'message': 'Obfuscating <(_target_name)',
617       'inputs': [
618         '<(DEPTH)/build/android/ant/apk-obfuscate.xml',
619         '<(DEPTH)/build/android/ant/create-test-jar.js',
620         '<(DEPTH)/build/android/gyp/util/build_utils.py',
621         '<(DEPTH)/build/android/gyp/ant.py',
622         '<(instr_stamp)',
623         '>@(proguard_flags_paths)',
624       ],
625       'outputs': [
626         '<(obfuscate_stamp)',
627       ],
628       'action': [
629         'python', '<(DEPTH)/build/android/gyp/ant.py',
630         '-quiet',
631         '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)',
632         '-DANDROID_SDK_JAR=<(android_sdk_jar)',
633         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
634         '-DANDROID_SDK_VERSION=<(android_sdk_version)',
635         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
636         '-DAPK_NAME=<(apk_name)',
637         '-DCREATE_TEST_JAR_PATH=<(DEPTH)/build/android/ant/create-test-jar.js',
638         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
639         '-DGENERATED_SRC_DIRS=>(generated_src_dirs)',
640         '-DINPUT_JARS_PATHS=>(input_jars_paths)',
641         '-DIS_TEST_APK=<(is_test_apk)',
642         '-DJAR_PATH=<(PRODUCT_DIR)/lib.java/<(jar_name)',
643         '-DOBFUSCATED_JAR_PATH=<(obfuscated_jar_path)',
644         '-DOUT_DIR=<(intermediate_dir)',
645         '-DPROGUARD_ENABLED=<(proguard_enabled)',
646         '-DPROGUARD_FLAGS=<(proguard_flags_paths)',
647         '-DTEST_JAR_PATH=<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar',
649         '-DSTAMP=<(obfuscate_stamp)',
650         '-Dbasedir=.',
651         '-buildfile',
652         '<(DEPTH)/build/android/ant/apk-obfuscate.xml',
654         # Add list of inputs to the command line, so if inputs change
655         # (e.g. if a Java file is removed), the command will be re-run.
656         # TODO(newt): remove this once crbug.com/177552 is fixed in ninja.
657         '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)',
658       ],
659     },
660     {
661       'action_name': 'dex_<(_target_name)',
662       'variables': {
663         'conditions': [
664           ['proguard_enabled == "true"', {
665             'input_paths': [ '<(obfuscate_stamp)' ],
666             'proguard_enabled_input_path': '<(obfuscated_jar_path)',
667           }],
668           ['emma_instrument != 0', {
669             'dex_no_locals': 1,
670           }],
671           ['emma_instrument != 0 and is_test_apk == 0', {
672             'dex_input_paths': [ '<(emma_device_jar)' ],
673           }],
674         ],
675         'input_paths': [ '<(instr_stamp)' ],
676         'dex_input_paths': [ '>@(library_dexed_jars_paths)' ],
677         'dex_generated_input_dirs': [ '<(classes_final_dir)' ],
678         'output_path': '<(dex_path)',
679       },
680       'includes': [ 'android/dex_action.gypi' ],
681     },
682     {
683       'action_name': 'ant package resources',
684       'message': 'Packaging resources for <(_target_name) APK',
685       'inputs': [
686         '<(DEPTH)/build/android/ant/apk-package-resources.xml',
687         '<(DEPTH)/build/android/gyp/util/build_utils.py',
688         '<(DEPTH)/build/android/gyp/ant.py',
689         '<(android_manifest_path)',
690         '<(codegen_stamp)',
692         '>@(library_manifest_paths)',
693         '>@(additional_input_paths)',
694       ],
695       'conditions': [
696         ['is_test_apk == 1', {
697           'variables': {
698             'additional_res_dirs=': [],
699             'additional_res_packages=': [],
700           }
701         }],
702       ],
703       'outputs': [
704         '<(package_resources_stamp)',
705       ],
706       'action': [
707         'python', '<(DEPTH)/build/android/gyp/ant.py',
708         '-quiet',
709         '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)',
710         '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)',
711         '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)',
712         '-DANDROID_SDK_JAR=<(android_sdk_jar)',
713         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
714         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
715         '-DAPK_NAME=<(apk_name)',
716         '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)',
717         '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)',
718         '-DASSET_DIR=<(asset_location)',
719         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
720         '-DOUT_DIR=<(intermediate_dir)',
721         '-DRESOURCE_DIR=<(resource_dir)',
723         '-DSTAMP=<(package_resources_stamp)',
725         '-Dbasedir=.',
726         '-buildfile',
727         '<(DEPTH)/build/android/ant/apk-package-resources.xml',
729         # Add list of inputs to the command line, so if inputs change
730         # (e.g. if a Java file is removed), the command will be re-run.
731         # TODO(newt): remove this once crbug.com/177552 is fixed in ninja.
732         '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)',
733       ]
734     },
735     {
736       'action_name': 'ant_package_<(_target_name)',
737       'message': 'Packaging <(_target_name)',
738       'inputs': [
739         '<(DEPTH)/build/android/ant/apk-package.xml',
740         '<(DEPTH)/build/android/gyp/util/build_utils.py',
741         '<(DEPTH)/build/android/gyp/ant.py',
742         '<(dex_path)',
743         '<(codegen_stamp)',
744         '<(obfuscate_stamp)',
745         '<(package_resources_stamp)',
746         '>@(package_input_paths)',
747       ],
748       'outputs': [
749         '<(unsigned_apk_path)',
750       ],
751       'action': [
752         'python', '<(DEPTH)/build/android/gyp/ant.py',
753         '-quiet',
754         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
755         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
756         '-DAPK_NAME=<(apk_name)',
757         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
758         '-DNATIVE_LIBS_DIR=<(apk_package_native_libs_dir)',
759         '-DOUT_DIR=<(intermediate_dir)',
760         '-DSOURCE_DIR=<(source_dir)',
761         '-DUNSIGNED_APK_PATH=<(unsigned_apk_path)',
762         '-DEMMA_INSTRUMENT=<(emma_instrument)',
763         '-DEMMA_DEVICE_JAR=<(emma_device_jar)',
765         '-Dbasedir=.',
766         '-buildfile',
767         '<(DEPTH)/build/android/ant/apk-package.xml',
769         # Add list of inputs to the command line, so if inputs change
770         # (e.g. if a Java file is removed), the command will be re-run.
771         # TODO(newt): remove this once crbug.com/177552 is fixed in ninja.
772         '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)',
773       ]
774     },
775   ],