disable two ClientCertStoreChromeOSTest.* unit_tests on Valgrind bots
[chromium-blink-merge.git] / build / java_apk.gypi
blob6dbb85876aae863af245d77d46bae8a3f9e1ab50
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 android_must_copy_system_libraries == 1', {
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           'variables': {
725             'additional_findbugs_args': [],
726             'findbugs_verbose%': 0,
727           },
728           'conditions': [
729             ['findbugs_verbose == 1', {
730               'variables': {
731                 'additional_findbugs_args+': ['-vv'],
732               },
733             }],
734           ],
735           'inputs': [
736             '<(DEPTH)/build/android/findbugs_diff.py',
737             '<(DEPTH)/build/android/findbugs_filter/findbugs_exclude.xml',
738             '<(DEPTH)/build/android/pylib/utils/findbugs.py',
739             '>@(input_jars_paths)',
740             '<(jar_path)',
741             '<(compile_stamp)',
742           ],
743           'outputs': [
744             '<(findbugs_stamp)',
745           ],
746           'action': [
747             'python', '<(DEPTH)/build/android/findbugs_diff.py',
748             '--auxclasspath-gyp', '>(input_jars_paths)',
749             '--stamp', '<(findbugs_stamp)',
750             '<@(additional_findbugs_args)',
751             '<(jar_path)',
752           ],
753         },
754       ],
755     },
756     ]
757   ],
758   'dependencies': [
759     '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum',
760   ],
761   'actions': [
762     {
763       'action_name': 'process_resources',
764       'message': 'processing resources for <(_target_name)',
765       'variables': {
766         # Write the inputs list to a file, so that its mtime is updated when
767         # the list of inputs changes.
768         'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))',
769         'process_resources_options': [],
770         'conditions': [
771           ['is_test_apk == 1', {
772             'dependencies_res_zip_paths=': [],
773             'additional_res_packages=': [],
774           }],
775           ['res_v14_skip == 1', {
776             'process_resources_options+': ['--v14-skip']
777           }],
778           ['shared_resources == 1', {
779             'process_resources_options+': ['--shared-resources']
780           }],
781           ['R_package != ""', {
782             'process_resources_options+': ['--custom-package', '<(R_package)']
783           }],
784           ['include_all_resources == 1', {
785             'process_resources_options+': ['--include-all-resources']
786           }]
787         ],
788       },
789       'inputs': [
790         '<(DEPTH)/build/android/gyp/util/build_utils.py',
791         '<(DEPTH)/build/android/gyp/process_resources.py',
792         '<(android_manifest_path)',
793         '>@(additional_input_paths)',
794         '>@(resource_input_paths)',
795         '>@(dependencies_res_zip_paths)',
796         '>(inputs_list_file)',
797       ],
798       'outputs': [
799         '<(resource_zip_path)',
800         '<(generated_proguard_file)',
801         '<(codegen_stamp)',
802       ],
803       'action': [
804         'python', '<(DEPTH)/build/android/gyp/process_resources.py',
805         '--android-sdk', '<(android_sdk)',
806         '--aapt-path', '<(android_aapt_path)',
808         '--android-manifest', '<(android_manifest_path)',
809         '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
811         '--extra-res-packages', '>(additional_res_packages)',
812         '--extra-r-text-files', '>(additional_R_text_files)',
814         '--proguard-file', '<(generated_proguard_file)',
816         '--resource-dirs', '<(resource_dir)',
817         '--resource-zip-out', '<(resource_zip_path)',
819         '--R-dir', '<(intermediate_dir)/gen',
821         '--stamp', '<(codegen_stamp)',
823         '<@(process_resources_options)',
824       ],
825     },
826     {
827       'action_name': 'javac_<(_target_name)',
828       'message': 'Compiling java for <(_target_name)',
829       'variables': {
830         'extra_args': [],
831         'extra_inputs': [],
832         'gen_src_dirs': [
833           '<(intermediate_dir)/gen',
834           '>@(generated_src_dirs)',
835         ],
836         # If there is a separate find for additional_src_dirs, it will find the
837         # wrong .java files when additional_src_dirs is empty.
838         # TODO(thakis): Gyp caches >! evaluation by command. Both java.gypi and
839         # java_apk.gypi evaluate the same command, and at the moment two targets
840         # set java_in_dir to "java". Add a dummy comment here to make sure
841         # that the two targets (one uses java.gypi, the other java_apk.gypi)
842         # get distinct source lists. Medium-term, make targets list all their
843         # Java files instead of using find. (As is, this will be broken if two
844         # targets use the same java_in_dir and both use java_apk.gypi or
845         # both use java.gypi.)
846         'java_sources': ['>!@(find >(java_in_dir)>(java_in_dir_suffix) >(additional_src_dirs) -name "*.java"  # apk)'],
847         'conditions': [
848           ['enable_errorprone == 1', {
849             'extra_inputs': [
850               '<(errorprone_exe_path)',
851             ],
852             'extra_args': [ '--use-errorprone-path=<(errorprone_exe_path)' ],
853           }],
854         ],
855       },
856       'inputs': [
857         '<(DEPTH)/build/android/gyp/util/build_utils.py',
858         '<(DEPTH)/build/android/gyp/javac.py',
859         '>@(java_sources)',
860         '>@(input_jars_paths)',
861         '<(codegen_stamp)',
862         '<@(extra_inputs)',
863       ],
864       'conditions': [
865         ['native_lib_target != ""', {
866           'inputs': [ '<(native_libraries_java_stamp)' ],
867         }],
868       ],
869       'outputs': [
870         '<(compile_stamp)',
871         '<(javac_jar_path)',
872       ],
873       'action': [
874         'python', '<(DEPTH)/build/android/gyp/javac.py',
875         '--bootclasspath=<(android_sdk_jar)',
876         '--classpath=>(input_jars_paths) <(android_sdk_jar)',
877         '--src-gendirs=>(gen_src_dirs)',
878         '--javac-includes=<(javac_includes)',
879         '--chromium-code=<(chromium_code)',
880         '--jar-path=<(javac_jar_path)',
881         '--jar-excluded-classes=<(jar_excluded_classes)',
882         '--stamp=<(compile_stamp)',
883         '<@(extra_args)',
884         '>@(java_sources)',
885       ],
886     },
887     {
888       'action_name': 'instr_jar_<(_target_name)',
889       'message': 'Instrumenting <(_target_name) jar',
890       'variables': {
891         'input_path': '<(javac_jar_path)',
892         'output_path': '<(jar_path)',
893         'stamp_path': '<(instr_stamp)',
894         'instr_type': 'jar',
895       },
896       'outputs': [
897         '<(instr_stamp)',
898         '<(jar_path)',
899       ],
900       'inputs': [
901         '<(javac_jar_path)',
902       ],
903       'includes': [ 'android/instr_action.gypi' ],
904     },
905     {
906       'variables': {
907         'src_dirs': [
908           '<(java_in_dir)<(java_in_dir_suffix)',
909           '>@(additional_src_dirs)',
910         ],
911         'lint_jar_path': '<(jar_path)',
912         'stamp_path': '<(lint_stamp)',
913         'result_path': '<(lint_result)',
914         'config_path': '<(lint_config)',
915       },
916       'outputs': [
917         '<(lint_stamp)',
918       ],
919       'includes': [ 'android/lint_action.gypi' ],
920     },
921     {
922       'action_name': 'obfuscate_<(_target_name)',
923       'message': 'Obfuscating <(_target_name)',
924       'variables': {
925         'additional_obfuscate_options': [],
926         'additional_obfuscate_input_paths': [],
927         'proguard_out_dir': '<(intermediate_dir)/proguard',
928         'proguard_input_jar_paths': [
929           '>@(input_jars_paths)',
930           '<(jar_path)',
931         ],
932         'target_conditions': [
933           ['is_test_apk == 1', {
934             'additional_obfuscate_options': [
935               '--testapp',
936             ],
937           }],
938           ['is_test_apk == 1 and tested_apk_obfuscated_jar_path != "/"', {
939             'additional_obfuscate_options': [
940               '--tested-apk-obfuscated-jar-path', '>(tested_apk_obfuscated_jar_path)',
941             ],
942             'additional_obfuscate_input_paths': [
943               '>(tested_apk_obfuscated_jar_path).info',
944             ],
945           }],
946           ['proguard_enabled == "true"', {
947             'additional_obfuscate_options': [
948               '--proguard-enabled',
949             ],
950           }],
951         ],
952         'obfuscate_input_jars_paths': [
953           '>@(input_jars_paths)',
954           '<(jar_path)',
955         ],
956       },
957       'conditions': [
958         ['is_test_apk == 1', {
959           'outputs': [
960             '<(test_jar_path)',
961           ],
962         }],
963       ],
964       'inputs': [
965         '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
966         '<(DEPTH)/build/android/gyp/util/build_utils.py',
967         '>@(proguard_flags_paths)',
968         '>@(obfuscate_input_jars_paths)',
969         '>@(additional_obfuscate_input_paths)',
970         '<(instr_stamp)',
971       ],
972       'outputs': [
973         '<(obfuscate_stamp)',
975         # In non-Release builds, these paths will all be empty files.
976         '<(obfuscated_jar_path)',
977         '<(obfuscated_jar_path).info',
978         '<(obfuscated_jar_path).dump',
979         '<(obfuscated_jar_path).seeds',
980         '<(obfuscated_jar_path).mapping',
981         '<(obfuscated_jar_path).usage',
982       ],
983       'action': [
984         'python', '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
986         '--configuration-name', '<(CONFIGURATION_NAME)',
988         '--android-sdk', '<(android_sdk)',
989         '--android-sdk-tools', '<(android_sdk_tools)',
990         '--android-sdk-jar', '<(android_sdk_jar)',
992         '--input-jars-paths=>(proguard_input_jar_paths)',
993         '--proguard-configs=>(proguard_flags_paths)',
995         '--test-jar-path', '<(test_jar_path)',
996         '--obfuscated-jar-path', '<(obfuscated_jar_path)',
998         '--proguard-jar-path', '<(android_sdk_root)/tools/proguard/lib/proguard.jar',
1000         '--stamp', '<(obfuscate_stamp)',
1002         '>@(additional_obfuscate_options)',
1003       ],
1004     },
1005     {
1006       'action_name': 'dex_<(_target_name)',
1007       'variables': {
1008         'dex_input_paths': [
1009           '>@(library_dexed_jars_paths)',
1010           '<(jar_path)',
1011         ],
1012         'output_path': '<(dex_path)',
1013         'proguard_enabled_input_path': '<(obfuscated_jar_path)',
1014       },
1015       'target_conditions': [
1016         ['emma_instrument != 0', {
1017           'variables': {
1018             'dex_no_locals': 1,
1019             'dex_input_paths': [
1020               '<(emma_device_jar)'
1021             ],
1022           },
1023         }],
1024         ['is_test_apk == 1 and tested_apk_dex_path != "/"', {
1025           'variables': {
1026             'dex_additional_options': [
1027               '--excluded-paths', '@FileArg(>(tested_apk_dex_path).inputs)'
1028             ],
1029           },
1030           'inputs': [
1031             '>(tested_apk_dex_path).inputs',
1032           ],
1033         }],
1034         ['proguard_enabled == "true"', {
1035           'inputs': [ '<(obfuscate_stamp)' ]
1036         }, {
1037           'inputs': [ '<(instr_stamp)' ]
1038         }],
1039       ],
1040       'includes': [ 'android/dex_action.gypi' ],
1041     },
1042     {
1043       'variables': {
1044         'extra_inputs': ['<(codegen_stamp)'],
1045         'resource_zips': [
1046           '<(resource_zip_path)',
1047         ],
1048         'conditions': [
1049           ['is_test_apk == 0', {
1050             'resource_zips': [
1051               '>@(dependencies_res_zip_paths)',
1052             ],
1053           }],
1054         ],
1055       },
1056       'includes': [ 'android/package_resources_action.gypi' ],
1057     },
1058     {
1059       'variables': {
1060         'apk_path': '<(unsigned_apk_path)',
1061         'conditions': [
1062           ['native_lib_target != ""', {
1063             'extra_inputs': ['<(native_lib_placeholder_stamp)'],
1064           }],
1065           ['create_abi_split == 0', {
1066             'native_libs_dir': '<(apk_package_native_libs_dir)',
1067           }, {
1068             'native_libs_dir': '<(DEPTH)/build/android/ant/empty/res',
1069           }],
1070         ],
1071       },
1072       'includes': ['android/apkbuilder_action.gypi'],
1073     },
1074   ],