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