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