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