net: Remove code for session cookie deletion experiment.
[chromium-blink-merge.git] / build / java_apk.gypi
blob507e0d5786bcd083dbd67cfbdb0abe8607bd0395
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     'conditions': [
227       ['chromium_code == 0', {
228         'enable_errorprone': 0,
229       }],
230     ],
231     'enable_errorprone%': 0,
232     'errorprone_exe_path': '<(PRODUCT_DIR)/bin.java/chromium_errorprone',
233   },
234   # Pass the jar path to the apk's "fake" jar target.  This would be better as
235   # direct_dependent_settings, but a variable set by a direct_dependent_settings
236   # cannot be lifted in a dependent to all_dependent_settings.
237   'all_dependent_settings': {
238     'conditions': [
239       ['proguard_enabled == "true"', {
240         'variables': {
241           'proguard_enabled': 'true',
242         }
243       }],
244     ],
245     'variables': {
246       'apk_output_jar_path': '<(jar_path)',
247       'tested_apk_obfuscated_jar_path': '<(obfuscated_jar_path)',
248       'tested_apk_dex_path': '<(dex_path)',
249       'tested_apk_is_multidex': '<(enable_multidex)',
250     },
251   },
252   'conditions': [
253     ['resource_dir!=""', {
254       'variables': {
255         'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ]
256       },
257     }],
258     ['R_package != ""', {
259       'variables': {
260         # We generate R.java in package R_package (in addition to the package
261         # listed in the AndroidManifest.xml, which is unavoidable).
262         'additional_res_packages': ['<(R_package)'],
263         'additional_R_text_files': ['<(intermediate_dir)/R.txt'],
264       },
265     }],
266     ['native_lib_target != "" and android_must_copy_system_libraries == 1', {
267       'dependencies': [
268         '<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
269       ],
270     }],
271     ['use_chromium_linker == 1', {
272       'dependencies': [
273         '<(DEPTH)/base/base.gyp:chromium_android_linker',
274       ],
275     }],
276     ['enable_errorprone == 1', {
277       'dependencies': [
278         '<(DEPTH)/third_party/errorprone/errorprone.gyp:require_errorprone',
279       ],
280     }],
281     ['native_lib_target != ""', {
282       'variables': {
283         'conditions': [
284           ['use_chromium_linker == 1', {
285             'variables': {
286               'chromium_linker_path': [
287                 '<(SHARED_LIB_DIR)/<(libchromium_android_linker)',
288               ],
289             }
290           }, {
291             'variables': {
292               'chromium_linker_path': [],
293             },
294           }],
295         ],
296         'generated_src_dirs': [ '<(native_libraries_java_dir)' ],
297         'native_libs_paths': [
298           '<(SHARED_LIB_DIR)/<(native_lib_target).>(android_product_extension)',
299           '<@(chromium_linker_path)'
300         ],
301         'package_input_paths': [
302           '<(apk_package_native_libs_dir)/<(android_app_abi)/gdbserver',
303         ],
304       },
305       'copies': [
306         {
307           # gdbserver is always copied into the APK's native libs dir. The ant
308           # build scripts (apkbuilder task) will only include it in a debug
309           # build.
310           'destination': '<(apk_package_native_libs_dir)/<(android_app_abi)',
311           'files': [
312             '<(android_gdbserver)',
313           ],
314         },
315       ],
316       'actions': [
317         {
318           'variables': {
319             'input_libraries': [
320               '<@(native_libs_paths)',
321               '<@(extra_native_libs)',
322             ],
323           },
324           'includes': ['../build/android/write_ordered_libraries.gypi'],
325         },
326         {
327           'action_name': 'native_libraries_<(_target_name)',
328           'variables': {
329             'conditions': [
330               ['use_chromium_linker == 1', {
331                 'variables': {
332                   'linker_gcc_preprocess_defines': [
333                     '--defines', 'ENABLE_CHROMIUM_LINKER',
334                   ],
335                 }
336               }, {
337                 'variables': {
338                   'linker_gcc_preprocess_defines': [],
339                 },
340               }],
341               ['load_library_from_zip == 1', {
342                 'variables': {
343                   'linker_load_from_zip_file_preprocess_defines': [
344                     '--defines', 'ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE',
345                   ],
346                 }
347               }, {
348                 'variables': {
349                   'linker_load_from_zip_file_preprocess_defines': [],
350                 },
351               }],
352               ['enable_chromium_linker_tests == 1', {
353                 'variables': {
354                   'linker_tests_gcc_preprocess_defines': [
355                     '--defines', 'ENABLE_CHROMIUM_LINKER_TESTS',
356                   ],
357                 }
358               }, {
359                 'variables': {
360                   'linker_tests_gcc_preprocess_defines': [],
361                 },
362               }],
363             ],
364             'gcc_preprocess_defines': [
365               '<@(linker_load_from_zip_file_preprocess_defines)',
366               '<@(linker_gcc_preprocess_defines)',
367               '<@(linker_tests_gcc_preprocess_defines)',
368             ],
369           },
370           'message': 'Creating NativeLibraries.java for <(_target_name)',
371           'inputs': [
372             '<(DEPTH)/build/android/gyp/util/build_utils.py',
373             '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
374             '<(ordered_libraries_file)',
375             '<(native_libraries_template)',
376           ],
377           'outputs': [
378             '<(native_libraries_java_stamp)',
379           ],
380           'action': [
381             'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
382             '--include-path=',
383             '--output=<(native_libraries_java_file)',
384             '--template=<(native_libraries_template)',
385             '--stamp=<(native_libraries_java_stamp)',
386             '--defines', 'NATIVE_LIBRARIES_LIST=@FileArg(<(ordered_libraries_file):java_libraries_list)',
387             '--defines', 'NATIVE_LIBRARIES_VERSION_NUMBER="<(native_lib_version_name)"',
388             '<@(gcc_preprocess_defines)',
389           ],
390         },
391         {
392           'action_name': 'strip_native_libraries',
393           'variables': {
394             'ordered_libraries_file%': '<(ordered_libraries_file)',
395             'stripped_libraries_dir%': '<(stripped_libraries_dir)',
396             'input_paths': [
397               '<@(native_libs_paths)',
398               '<@(extra_native_libs)',
399             ],
400             'stamp': '<(strip_stamp)'
401           },
402           'includes': ['../build/android/strip_native_libraries.gypi'],
403         },
404         {
405           'action_name': 'insert_chromium_version',
406           'variables': {
407             'ordered_libraries_file%': '<(ordered_libraries_file)',
408             'stripped_libraries_dir%': '<(stripped_libraries_dir)',
409             'version_string': '<(native_lib_version_name)',
410             'input_paths': [
411               '<(strip_stamp)',
412             ],
413             'stamp': '<(version_stamp)'
414           },
415           'includes': ['../build/android/insert_chromium_version.gypi'],
416         },
417         {
418           'action_name': 'pack_relocations',
419           'variables': {
420             'conditions': [
421               ['use_chromium_linker == 1 and use_relocation_packer == 1 and profiling != 1', {
422                 'enable_packing': 1,
423               }, {
424                 'enable_packing': 0,
425               }],
426             ],
427             'exclude_packing_list': [
428               '<(libchromium_android_linker)',
429             ],
430             'ordered_libraries_file%': '<(ordered_libraries_file)',
431             'stripped_libraries_dir%': '<(stripped_libraries_dir)',
432             'packed_libraries_dir': '<(libraries_source_dir)',
433             'input_paths': [
434               '<(version_stamp)'
435             ],
436             'stamp': '<(pack_relocations_stamp)',
437           },
438           'includes': ['../build/android/pack_relocations.gypi'],
439         },
440         {
441           'variables': {
442             'input_libraries': [
443               '<@(additional_bundled_libs)',
444             ],
445             'ordered_libraries_file': '<(additional_ordered_libraries_file)',
446             'subtarget': '_additional_libraries',
447           },
448           'includes': ['../build/android/write_ordered_libraries.gypi'],
449         },
450         {
451           'action_name': 'strip_additional_libraries',
452           'variables': {
453             'ordered_libraries_file': '<(additional_ordered_libraries_file)',
454             'stripped_libraries_dir': '<(libraries_source_dir)',
455             'input_paths': [
456               '<@(additional_bundled_libs)',
457               '<(strip_stamp)',
458             ],
459             'stamp': '<(strip_additional_stamp)'
460           },
461           'includes': ['../build/android/strip_native_libraries.gypi'],
462         },
463         {
464           'action_name': 'Create native lib placeholder files for previous releases',
465           'variables': {
466             'placeholders': ['<@(native_lib_placeholders)'],
467             'conditions': [
468               ['gyp_managed_install == 1', {
469                 # This "library" just needs to be put in the .apk. It is not loaded
470                 # at runtime.
471                 'placeholders': ['libfix.crbug.384638.so'],
472               }]
473             ],
474           },
475           'inputs': [
476             '<(DEPTH)/build/android/gyp/create_placeholder_files.py',
477           ],
478           'outputs': [
479             '<(native_lib_placeholder_stamp)',
480           ],
481           'action': [
482             'python', '<(DEPTH)/build/android/gyp/create_placeholder_files.py',
483             '--dest-lib-dir=<(apk_package_native_libs_dir)/<(android_app_abi)/',
484             '--stamp=<(native_lib_placeholder_stamp)',
485             '<@(placeholders)',
486           ],
487         },
488       ],
489       'conditions': [
490         ['gyp_managed_install == 1', {
491           'variables': {
492             'libraries_top_dir': '<(intermediate_dir)/lib.stripped',
493             'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)',
494             'device_library_dir': '<(device_intermediate_dir)/lib.stripped',
495             'configuration_name': '<(CONFIGURATION_NAME)',
496           },
497           'dependencies': [
498             '<(DEPTH)/build/android/setup.gyp:get_build_device_configurations',
499             '<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
500           ],
501           'actions': [
502             {
503               'includes': ['../build/android/push_libraries.gypi'],
504             },
505             {
506               'action_name': 'create device library symlinks',
507               'message': 'Creating links on device for <(_target_name)',
508               'inputs': [
509                 '<(DEPTH)/build/android/gyp/util/build_utils.py',
510                 '<(DEPTH)/build/android/gyp/create_device_library_links.py',
511                 '<(apk_install_record)',
512                 '<(build_device_config_path)',
513                 '<(ordered_libraries_file)',
514               ],
515               'outputs': [
516                 '<(link_stamp)'
517               ],
518               'action': [
519                 'python', '<(DEPTH)/build/android/gyp/create_device_library_links.py',
520                 '--build-device-configuration=<(build_device_config_path)',
521                 '--libraries=@FileArg(<(ordered_libraries_file):libraries)',
522                 '--script-host-path=<(symlink_script_host_path)',
523                 '--script-device-path=<(symlink_script_device_path)',
524                 '--target-dir=<(device_library_dir)',
525                 '--apk=<(incomplete_apk_path)',
526                 '--stamp=<(link_stamp)',
527                 '--configuration-name=<(CONFIGURATION_NAME)',
528               ],
529             },
530           ],
531           'conditions': [
532             ['create_standalone_apk == 1', {
533               'actions': [
534                 {
535                   'action_name': 'create standalone APK',
536                   'variables': {
537                     'inputs': [
538                       '<(ordered_libraries_file)',
539                       '<(strip_additional_stamp)',
540                       '<(pack_relocations_stamp)',
541                     ],
542                     'output_apk_path': '<(unsigned_standalone_apk_path)',
543                     'libraries_top_dir%': '<(libraries_top_dir)',
544                     'input_apk_path': '<(managed_input_apk_path)',
545                   },
546                   'includes': [ 'android/create_standalone_apk_action.gypi' ],
547                 },
548               ],
549             }],
550           ],
551         }, {
552           # gyp_managed_install != 1
553           'variables': {
554             'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_app_abi)',
555             'package_input_paths': [
556               '<(strip_additional_stamp)',
557               '<(pack_relocations_stamp)',
558             ],
559           },
560         }],
561       ],
562     }], # native_lib_target != ''
563     ['gyp_managed_install == 0 or create_standalone_apk == 1 or create_abi_split == 1', {
564       'dependencies': [
565         '<(DEPTH)/build/android/rezip.gyp:rezip_apk_jar',
566       ],
567     }],
568     ['create_abi_split == 1 or gyp_managed_install == 0 or create_standalone_apk == 1', {
569       'actions': [
570         {
571           'action_name': 'finalize_base',
572           'variables': {
573             'output_apk_path': '<(final_apk_path)',
574             'conditions': [
575               ['create_abi_split == 0', {
576                 'input_apk_path': '<(unsigned_standalone_apk_path)',
577               }, {
578                 'input_apk_path': '<(unsigned_apk_path)',
579                 'load_library_from_zip': 0,
580               }]
581             ],
582           },
583           'includes': [ 'android/finalize_apk_action.gypi']
584         },
585       ],
586     }],
587     ['create_abi_split == 1', {
588       'actions': [
589         {
590           'action_name': 'generate_split_manifest_<(_target_name)',
591           'inputs': [
592             '<(DEPTH)/build/android/gyp/util/build_utils.py',
593             '<(DEPTH)/build/android/gyp/generate_split_manifest.py',
594             '<(android_manifest_path)',
595           ],
596           'outputs': [
597             '<(split_android_manifest_path)',
598           ],
599           'action': [
600             'python', '<(DEPTH)/build/android/gyp/generate_split_manifest.py',
601             '--main-manifest', '<(android_manifest_path)',
602             '--out-manifest', '<(split_android_manifest_path)',
603             '--split', 'abi_<(android_app_abi)',
604           ],
605         },
606         {
607           'variables': {
608             'apk_name': '<(main_apk_name)-abi-<(android_app_abi)',
609             'asset_location': '',
610             'android_manifest_path': '<(split_android_manifest_path)',
611             'create_density_splits': 0,
612             'language_splits=': [],
613           },
614           'includes': [ 'android/package_resources_action.gypi' ],
615         },
616         {
617           'variables': {
618             'apk_name': '<(main_apk_name)-abi-<(android_app_abi)',
619             'apk_path': '<(unsigned_abi_split_apk_path)',
620             'has_code': 0,
621             'native_libs_dir': '<(apk_package_native_libs_dir)',
622             'extra_inputs': ['<(native_lib_placeholder_stamp)'],
623           },
624           'includes': ['android/apkbuilder_action.gypi'],
625         },
626       ],
627     }],
628     ['create_abi_split == 1 and (gyp_managed_install == 0 or create_standalone_apk == 1)', {
629       'actions': [
630         {
631           'action_name': 'finalize_split',
632           'variables': {
633             'output_apk_path': '<(final_abi_split_apk_path)',
634             'conditions': [
635               ['gyp_managed_install == 1', {
636                 'input_apk_path': '<(unsigned_standalone_apk_path)',
637               }, {
638                 'input_apk_path': '<(unsigned_abi_split_apk_path)',
639               }],
640             ],
641           },
642           'includes': [ 'android/finalize_apk_action.gypi']
643         },
644       ],
645     }],
646     ['gyp_managed_install == 1', {
647       'actions': [
648         {
649           'action_name': 'finalize incomplete apk',
650           'variables': {
651             'load_library_from_zip': 0,
652             'input_apk_path': '<(managed_input_apk_path)',
653             'output_apk_path': '<(incomplete_apk_path)',
654           },
655           'includes': [ 'android/finalize_apk_action.gypi']
656         },
657         {
658           'action_name': 'apk_install_<(_target_name)',
659           'message': 'Installing <(apk_name).apk',
660           'inputs': [
661             '<(DEPTH)/build/android/gyp/util/build_utils.py',
662             '<(DEPTH)/build/android/gyp/apk_install.py',
663             '<(build_device_config_path)',
664             '<(incomplete_apk_path)',
665           ],
666           'outputs': [
667             '<(apk_install_record)',
668           ],
669           'action': [
670             'python', '<(DEPTH)/build/android/gyp/apk_install.py',
671             '--build-device-configuration=<(build_device_config_path)',
672             '--install-record=<(apk_install_record)',
673             '--configuration-name=<(CONFIGURATION_NAME)',
674             '--android-sdk-tools', '<(android_sdk_tools)',
675           ],
676           'conditions': [
677             ['create_abi_split == 1', {
678               'inputs': [
679                 '<(final_apk_path)',
680               ],
681               'action': [
682                 '--apk-path=<(final_apk_path)',
683                 '--split-apk-path=<(incomplete_apk_path)',
684               ],
685             }, {
686               'action': [
687                 '--apk-path=<(incomplete_apk_path)',
688               ],
689             }],
690             ['create_density_splits == 1', {
691               'inputs': [
692                 '<(final_apk_path_no_extension)-density-hdpi.apk',
693                 '<(final_apk_path_no_extension)-density-xhdpi.apk',
694                 '<(final_apk_path_no_extension)-density-xxhdpi.apk',
695                 '<(final_apk_path_no_extension)-density-xxxhdpi.apk',
696                 '<(final_apk_path_no_extension)-density-tvdpi.apk',
697               ],
698               'action': [
699                 '--split-apk-path=<(final_apk_path_no_extension)-density-hdpi.apk',
700                 '--split-apk-path=<(final_apk_path_no_extension)-density-xhdpi.apk',
701                 '--split-apk-path=<(final_apk_path_no_extension)-density-xxhdpi.apk',
702                 '--split-apk-path=<(final_apk_path_no_extension)-density-xxxhdpi.apk',
703                 '--split-apk-path=<(final_apk_path_no_extension)-density-tvdpi.apk',
704               ],
705             }],
706             ['language_splits != []', {
707               'inputs': [
708                 "<!@(python <(DEPTH)/build/apply_locales.py '<(final_apk_path_no_extension)-lang-ZZLOCALE.apk' <(language_splits))",
709               ],
710               'action': [
711                 "<!@(python <(DEPTH)/build/apply_locales.py -- '--split-apk-path=<(final_apk_path_no_extension)-lang-ZZLOCALE.apk' <(language_splits))",
712               ],
713             }],
714           ],
715         },
716       ],
717     }],
718     ['create_density_splits == 1', {
719       'actions': [
720         {
721           'action_name': 'finalize_density_splits',
722           'variables': {
723             'density_splits': 1,
724           },
725           'includes': [ 'android/finalize_splits_action.gypi']
726         },
727       ],
728     }],
729     ['is_test_apk == 1', {
730       'dependencies': [
731         '<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
732         '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
733       ]
734     }],
735     ['run_findbugs == 1', {
736       'actions': [
737         {
738           'action_name': 'findbugs_<(_target_name)',
739           'message': 'Running findbugs on <(_target_name)',
740           'variables': {
741             'additional_findbugs_args': [],
742             'findbugs_verbose%': 0,
743           },
744           'conditions': [
745             ['findbugs_verbose == 1', {
746               'variables': {
747                 'additional_findbugs_args+': ['-vv'],
748               },
749             }],
750           ],
751           'inputs': [
752             '<(DEPTH)/build/android/findbugs_diff.py',
753             '<(DEPTH)/build/android/findbugs_filter/findbugs_exclude.xml',
754             '<(DEPTH)/build/android/pylib/utils/findbugs.py',
755             '>@(input_jars_paths)',
756             '<(jar_path)',
757             '<(compile_stamp)',
758           ],
759           'outputs': [
760             '<(findbugs_stamp)',
761           ],
762           'action': [
763             'python', '<(DEPTH)/build/android/findbugs_diff.py',
764             '--auxclasspath-gyp', '>(input_jars_paths)',
765             '--stamp', '<(findbugs_stamp)',
766             '<@(additional_findbugs_args)',
767             '<(jar_path)',
768           ],
769         },
770       ],
771     }],
772   ],
773   'dependencies': [
774     '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum',
775   ],
776   'actions': [
777     {
778       'action_name': 'process_resources',
779       'message': 'processing resources for <(_target_name)',
780       'variables': {
781         # Write the inputs list to a file, so that its mtime is updated when
782         # the list of inputs changes.
783         'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))',
784         'process_resources_options': [],
785         'conditions': [
786           ['is_test_apk == 1', {
787             'dependencies_res_zip_paths=': [],
788             'additional_res_packages=': [],
789           }],
790           ['res_v14_skip == 1', {
791             'process_resources_options+': ['--v14-skip']
792           }],
793           ['shared_resources == 1', {
794             'process_resources_options+': ['--shared-resources']
795           }],
796           ['R_package != ""', {
797             'process_resources_options+': ['--custom-package', '<(R_package)']
798           }],
799           ['include_all_resources == 1', {
800             'process_resources_options+': ['--include-all-resources']
801           }]
802         ],
803       },
804       'inputs': [
805         '<(DEPTH)/build/android/gyp/util/build_utils.py',
806         '<(DEPTH)/build/android/gyp/process_resources.py',
807         '<(android_manifest_path)',
808         '>@(additional_input_paths)',
809         '>@(resource_input_paths)',
810         '>@(dependencies_res_zip_paths)',
811         '>(inputs_list_file)',
812       ],
813       'outputs': [
814         '<(resource_zip_path)',
815         '<(generated_proguard_file)',
816         '<(codegen_stamp)',
817       ],
818       'action': [
819         'python', '<(DEPTH)/build/android/gyp/process_resources.py',
820         '--android-sdk', '<(android_sdk)',
821         '--aapt-path', '<(android_aapt_path)',
823         '--android-manifest', '<(android_manifest_path)',
824         '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
826         '--extra-res-packages', '>(additional_res_packages)',
827         '--extra-r-text-files', '>(additional_R_text_files)',
829         '--proguard-file', '<(generated_proguard_file)',
831         '--resource-dirs', '<(resource_dir)',
832         '--resource-zip-out', '<(resource_zip_path)',
834         '--R-dir', '<(intermediate_dir)/gen',
836         '--stamp', '<(codegen_stamp)',
838         '<@(process_resources_options)',
839       ],
840     },
841     {
842       'action_name': 'javac_<(_target_name)',
843       'message': 'Compiling java for <(_target_name)',
844       'variables': {
845         'extra_args': [],
846         'extra_inputs': [],
847         'gen_src_dirs': [
848           '<(intermediate_dir)/gen',
849           '>@(generated_src_dirs)',
850         ],
851         # If there is a separate find for additional_src_dirs, it will find the
852         # wrong .java files when additional_src_dirs is empty.
853         # TODO(thakis): Gyp caches >! evaluation by command. Both java.gypi and
854         # java_apk.gypi evaluate the same command, and at the moment two targets
855         # set java_in_dir to "java". Add a dummy comment here to make sure
856         # that the two targets (one uses java.gypi, the other java_apk.gypi)
857         # get distinct source lists. Medium-term, make targets list all their
858         # Java files instead of using find. (As is, this will be broken if two
859         # targets use the same java_in_dir and both use java_apk.gypi or
860         # both use java.gypi.)
861         'java_sources': ['>!@(find >(java_in_dir)>(java_in_dir_suffix) >(additional_src_dirs) -name "*.java"  # apk)'],
862         'conditions': [
863           ['enable_errorprone == 1', {
864             'extra_inputs': [
865               '<(errorprone_exe_path)',
866             ],
867             'extra_args': [ '--use-errorprone-path=<(errorprone_exe_path)' ],
868           }],
869         ],
870       },
871       'inputs': [
872         '<(DEPTH)/build/android/gyp/util/build_utils.py',
873         '<(DEPTH)/build/android/gyp/javac.py',
874         '>@(java_sources)',
875         '>@(input_jars_paths)',
876         '<(codegen_stamp)',
877         '<@(extra_inputs)',
878       ],
879       'conditions': [
880         ['native_lib_target != ""', {
881           'inputs': [ '<(native_libraries_java_stamp)' ],
882         }],
883       ],
884       'outputs': [
885         '<(compile_stamp)',
886         '<(javac_jar_path)',
887       ],
888       'action': [
889         'python', '<(DEPTH)/build/android/gyp/javac.py',
890         '--bootclasspath=<(android_sdk_jar)',
891         '--classpath=>(input_jars_paths) <(android_sdk_jar)',
892         '--src-gendirs=>(gen_src_dirs)',
893         '--javac-includes=<(javac_includes)',
894         '--chromium-code=<(chromium_code)',
895         '--jar-path=<(javac_jar_path)',
896         '--jar-excluded-classes=<(jar_excluded_classes)',
897         '--stamp=<(compile_stamp)',
898         '<@(extra_args)',
899         '>@(java_sources)',
900       ],
901     },
902     {
903       'action_name': 'main_dex_list_for_<(_target_name)',
904       'variables': {
905         'jar_path': '<(javac_jar_path)',
906         'output_path': '<(main_dex_list_path)',
907       },
908       'includes': [ 'android/main_dex_action.gypi' ],
909     },
910     {
911       'action_name': 'instr_jar_<(_target_name)',
912       'message': 'Instrumenting <(_target_name) jar',
913       'variables': {
914         'input_path': '<(javac_jar_path)',
915         'output_path': '<(jar_path)',
916         'stamp_path': '<(instr_stamp)',
917         'instr_type': 'jar',
918       },
919       'outputs': [
920         '<(instr_stamp)',
921         '<(jar_path)',
922       ],
923       'inputs': [
924         '<(javac_jar_path)',
925       ],
926       'includes': [ 'android/instr_action.gypi' ],
927     },
928     {
929       'variables': {
930         'src_dirs': [
931           '<(java_in_dir)<(java_in_dir_suffix)',
932           '>@(additional_src_dirs)',
933         ],
934         'lint_jar_path': '<(jar_path)',
935         'stamp_path': '<(lint_stamp)',
936         'result_path': '<(lint_result)',
937         'config_path': '<(lint_config)',
938       },
939       'outputs': [
940         '<(lint_stamp)',
941       ],
942       'includes': [ 'android/lint_action.gypi' ],
943     },
944     {
945       'action_name': 'obfuscate_<(_target_name)',
946       'message': 'Obfuscating <(_target_name)',
947       'variables': {
948         'additional_obfuscate_options': [],
949         'additional_obfuscate_input_paths': [],
950         'proguard_out_dir': '<(intermediate_dir)/proguard',
951         'proguard_input_jar_paths': [
952           '>@(input_jars_paths)',
953           '<(jar_path)',
954         ],
955         'target_conditions': [
956           ['is_test_apk == 1', {
957             'additional_obfuscate_options': [
958               '--testapp',
959             ],
960           }],
961           ['is_test_apk == 1 and tested_apk_obfuscated_jar_path != "/"', {
962             'additional_obfuscate_options': [
963               '--tested-apk-obfuscated-jar-path', '>(tested_apk_obfuscated_jar_path)',
964             ],
965             'additional_obfuscate_input_paths': [
966               '>(tested_apk_obfuscated_jar_path).info',
967             ],
968           }],
969           ['proguard_enabled == "true"', {
970             'additional_obfuscate_options': [
971               '--proguard-enabled',
972             ],
973           }],
974         ],
975         'obfuscate_input_jars_paths': [
976           '>@(input_jars_paths)',
977           '<(jar_path)',
978         ],
979       },
980       'conditions': [
981         ['is_test_apk == 1', {
982           'outputs': [
983             '<(test_jar_path)',
984           ],
985         }],
986       ],
987       'inputs': [
988         '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
989         '<(DEPTH)/build/android/gyp/util/build_utils.py',
990         '>@(proguard_flags_paths)',
991         '>@(obfuscate_input_jars_paths)',
992         '>@(additional_obfuscate_input_paths)',
993         '<(instr_stamp)',
994       ],
995       'outputs': [
996         '<(obfuscate_stamp)',
998         # In non-Release builds, these paths will all be empty files.
999         '<(obfuscated_jar_path)',
1000         '<(obfuscated_jar_path).info',
1001         '<(obfuscated_jar_path).dump',
1002         '<(obfuscated_jar_path).seeds',
1003         '<(obfuscated_jar_path).mapping',
1004         '<(obfuscated_jar_path).usage',
1005       ],
1006       'action': [
1007         'python', '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
1009         '--configuration-name', '<(CONFIGURATION_NAME)',
1011         '--android-sdk', '<(android_sdk)',
1012         '--android-sdk-tools', '<(android_sdk_tools)',
1013         '--android-sdk-jar', '<(android_sdk_jar)',
1015         '--input-jars-paths=>(proguard_input_jar_paths)',
1016         '--proguard-configs=>(proguard_flags_paths)',
1018         '--test-jar-path', '<(test_jar_path)',
1019         '--obfuscated-jar-path', '<(obfuscated_jar_path)',
1021         '--proguard-jar-path', '<(DEPTH)/third_party/proguard/lib/proguard.jar',
1023         '--stamp', '<(obfuscate_stamp)',
1025         '>@(additional_obfuscate_options)',
1026       ],
1027     },
1028     {
1029       'action_name': 'dex_<(_target_name)',
1030       'variables': {
1031         'dex_additional_options': [],
1032         'dex_input_paths': [
1033           '<(jar_path)',
1034         ],
1035         'output_path': '<(dex_path)',
1036         'proguard_enabled_input_path': '<(obfuscated_jar_path)',
1037       },
1038       'conditions': [
1039         ['enable_multidex == 1', {
1040           'variables': {
1041             'dex_additional_options': [
1042               '--multi-dex',
1043               '--main-dex-list-paths', '>@(main_dex_list_paths)',
1044             ],
1045           },
1046           'inputs': [
1047             '>@(main_dex_list_paths)',
1048           ],
1049         }]
1050       ],
1051       'target_conditions': [
1052         ['enable_multidex == 1 or tested_apk_is_multidex == 1', {
1053           'variables': {
1054             'dex_input_paths': [
1055               '>@(input_jars_paths)',
1056             ],
1057           },
1058         }, {
1059           'variables': {
1060             'dex_input_paths': [
1061               '>@(library_dexed_jars_paths)',
1062             ],
1063           },
1064         }],
1065         ['emma_instrument != 0', {
1066           'variables': {
1067             'dex_no_locals': 1,
1068             'dex_input_paths': [
1069               '<(emma_device_jar)'
1070             ],
1071           },
1072         }],
1073         ['is_test_apk == 1 and tested_apk_dex_path != "/"', {
1074           'variables': {
1075             'dex_additional_options': [
1076               '--excluded-paths', '@FileArg(>(tested_apk_dex_path).inputs)'
1077             ],
1078           },
1079           'inputs': [
1080             '>(tested_apk_dex_path).inputs',
1081           ],
1082         }],
1083         ['proguard_enabled == "true"', {
1084           'inputs': [ '<(obfuscate_stamp)' ]
1085         }, {
1086           'inputs': [ '<(instr_stamp)' ]
1087         }],
1088       ],
1089       'includes': [ 'android/dex_action.gypi' ],
1090     },
1091     {
1092       'variables': {
1093         'extra_inputs': ['<(codegen_stamp)'],
1094         'resource_zips': [
1095           '<(resource_zip_path)',
1096         ],
1097         'conditions': [
1098           ['is_test_apk == 0', {
1099             'resource_zips': [
1100               '>@(dependencies_res_zip_paths)',
1101             ],
1102           }],
1103         ],
1104       },
1105       'includes': [ 'android/package_resources_action.gypi' ],
1106     },
1107     {
1108       'variables': {
1109         'apk_path': '<(unsigned_apk_path)',
1110         'conditions': [
1111           ['native_lib_target != ""', {
1112             'extra_inputs': ['<(native_lib_placeholder_stamp)'],
1113           }],
1114           ['create_abi_split == 0', {
1115             'native_libs_dir': '<(apk_package_native_libs_dir)',
1116           }, {
1117             'native_libs_dir': '<(DEPTH)/build/android/ant/empty/res',
1118           }],
1119         ],
1120       },
1121       'includes': ['android/apkbuilder_action.gypi'],
1122     },
1123   ],