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