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