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