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