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