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