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