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