cc: Threaded GPU - fix thread binding.
[chromium-blink-merge.git] / build / java_apk.gypi
blob8d55307924488948af7a705b448743699ee7b857
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 #  generated_src_dirs - Same as additional_src_dirs except used for .java files
35 #    that are generated at build time. This should be set automatically by a
36 #    target's dependencies. The .java files in these directories are not
37 #    included in the 'inputs' list (unlike additional_src_dirs).
38 #  input_jars_paths - The path to jars to be included in the classpath. This
39 #    should be filled automatically by depending on the appropriate targets.
40 #  is_test_apk - Set to 1 if building a test apk.  This prevents resources from
41 #    dependencies from being re-included.
42 #  native_lib_target - The target_name of the target which generates the final
43 #    shared library to be included in this apk. A stripped copy of the
44 #    library will be included in the apk.
45 #  resource_dir - The directory for resources.
46 #  shared_resources - Make a resource package that can be loaded by a different
47 #    application at runtime to access the package's resources.
48 #  R_package - A custom Java package to generate the resource file R.java in.
49 #    By default, the package given in AndroidManifest.xml will be used.
50 #  use_chromium_linker - Enable the content dynamic linker that allows sharing the
51 #    RELRO section of the native libraries between the different processes.
52 #  load_library_from_zip_file - When using the dynamic linker, load the library
53 #    directly out of the zip file.
54 #  use_relocation_packer - Enable relocation packing. Relies on the chromium
55 #    linker, so use_chromium_linker must also be enabled.
56 #  enable_chromium_linker_tests - Enable the content dynamic linker test support
57 #    code. This allows a test APK to inject a Linker.TestRunner instance at
58 #    runtime. Should only be used by the chromium_linker_test_apk target!!
59 #  never_lint - Set to 1 to not run lint on this target.
60 #  java_in_dir_suffix - To override the /src suffix on java_in_dir.
61 #  app_manifest_version_name - set the apps 'human readable' version number.
62 #  app_manifest_version_code - set the apps version number.
64   'variables': {
65     'tested_apk_obfuscated_jar_path%': '/',
66     'tested_apk_dex_path%': '/',
67     'additional_input_paths': [],
68     'input_jars_paths': [],
69     'library_dexed_jars_paths': [],
70     'additional_src_dirs': [],
71     'generated_src_dirs': [],
72     'app_manifest_version_name%': '<(android_app_version_name)',
73     'app_manifest_version_code%': '<(android_app_version_code)',
74     # aapt generates this proguard.txt.
75     'generated_proguard_file': '<(intermediate_dir)/proguard.txt',
76     'proguard_enabled%': 'false',
77     'proguard_flags_paths': ['<(generated_proguard_file)'],
78     'jar_name': 'chromium_apk_<(_target_name).jar',
79     'resource_dir%':'<(DEPTH)/build/android/ant/empty/res',
80     'R_package%':'',
81     'additional_R_text_files': [],
82     'dependencies_res_zip_paths': [],
83     'additional_res_packages': [],
84     'additional_bundled_libs%': [],
85     'is_test_apk%': 0,
86     'extensions_to_not_compress%': '',
87     'resource_input_paths': [],
88     'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)',
89     'asset_location%': '<(intermediate_dir)/assets',
90     'codegen_stamp': '<(intermediate_dir)/codegen.stamp',
91     'package_input_paths': [],
92     'ordered_libraries_file': '<(intermediate_dir)/native_libraries.json',
93     'additional_ordered_libraries_file': '<(intermediate_dir)/additional_native_libraries.json',
94     'native_libraries_template': '<(DEPTH)/base/android/java/templates/NativeLibraries.template',
95     'native_libraries_java_dir': '<(intermediate_dir)/native_libraries_java/',
96     'native_libraries_java_file': '<(native_libraries_java_dir)/NativeLibraries.java',
97     'native_libraries_java_stamp': '<(intermediate_dir)/native_libraries_java.stamp',
98     'native_libraries_template_data_dir': '<(intermediate_dir)/native_libraries/',
99     'native_libraries_template_data_file': '<(native_libraries_template_data_dir)/native_libraries_array.h',
100     'native_libraries_template_version_file': '<(native_libraries_template_data_dir)/native_libraries_version.h',
101     'compile_stamp': '<(intermediate_dir)/compile.stamp',
102     'lint_stamp': '<(intermediate_dir)/lint.stamp',
103     'lint_result': '<(intermediate_dir)/lint_result.xml',
104     'lint_config': '<(intermediate_dir)/lint_config.xml',
105     'never_lint%': 0,
106     'java_in_dir_suffix%': '/src',
107     'instr_stamp': '<(intermediate_dir)/instr.stamp',
108     'jar_stamp': '<(intermediate_dir)/jar.stamp',
109     'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp',
110     'pack_arm_relocations_stamp': '<(intermediate_dir)/pack_arm_relocations.stamp',
111     'strip_stamp': '<(intermediate_dir)/strip.stamp',
112     'stripped_libraries_dir': '<(intermediate_dir)/stripped_libraries',
113     'strip_additional_stamp': '<(intermediate_dir)/strip_additional.stamp',
114     'version_stamp': '<(intermediate_dir)/version.stamp',
115     'javac_includes': [],
116     'jar_excluded_classes': [],
117     'javac_jar_path': '<(intermediate_dir)/<(_target_name).javac.jar',
118     'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
119     'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar',
120     'test_jar_path': '<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar',
121     'dex_path': '<(intermediate_dir)/classes.dex',
122     'emma_device_jar': '<(android_sdk_root)/tools/lib/emma_device.jar',
123     'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml',
124     'push_stamp': '<(intermediate_dir)/push.stamp',
125     'link_stamp': '<(intermediate_dir)/link.stamp',
126     'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp',
127     'resource_zip_path': '<(intermediate_dir)/<(_target_name).resources.zip',
128     'resource_packaged_apk_name': '<(apk_name)-resources.ap_',
129     'resource_packaged_apk_path': '<(intermediate_dir)/<(resource_packaged_apk_name)',
130     'shared_resources%': 0,
131     'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk',
132     'final_apk_path%': '<(PRODUCT_DIR)/apks/<(apk_name).apk',
133     'incomplete_apk_path': '<(intermediate_dir)/<(apk_name)-incomplete.apk',
134     'apk_install_record': '<(intermediate_dir)/apk_install.record.stamp',
135     'device_intermediate_dir': '/data/data/org.chromium.gyp_managed_install/<(_target_name)/<(CONFIGURATION_NAME)',
136     'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh',
137     'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh',
138     'create_standalone_apk%': 1,
139     'res_v14_verify_only%': 0,
140     'variables': {
141       'variables': {
142         'native_lib_target%': '',
143         'native_lib_version_name%': '',
144         'use_chromium_linker%' : 0,
145         'load_library_from_zip_file%' : 0,
146         'use_relocation_packer%' : 0,
147         'enable_chromium_linker_tests%': 0,
148         'is_test_apk%': 0,
149       },
150       'conditions': [
151         ['gyp_managed_install == 1 and native_lib_target != ""', {
152           'unsigned_standalone_apk_path': '<(intermediate_dir)/<(apk_name)-standalone-unsigned.apk',
153         }, {
154           'unsigned_standalone_apk_path': '<(unsigned_apk_path)',
155         }],
156         ['gyp_managed_install == 1', {
157           'apk_package_native_libs_dir': '<(intermediate_dir)/libs.managed',
158         }, {
159           'apk_package_native_libs_dir': '<(intermediate_dir)/libs',
160         }],
161         ['is_test_apk == 0 and emma_coverage != 0', {
162           'emma_instrument%': 1,
163         },{
164           'emma_instrument%': 0,
165         }],
166       ],
167     },
168     'native_lib_target%': '',
169     'native_lib_version_name%': '',
170     'use_chromium_linker%' : 0,
171     'load_library_from_zip_file%' : 0,
172     'use_relocation_packer%' : 0,
173     'enable_chromium_linker_tests%': 0,
174     'emma_instrument%': '<(emma_instrument)',
175     'apk_package_native_libs_dir': '<(apk_package_native_libs_dir)',
176     'unsigned_standalone_apk_path': '<(unsigned_standalone_apk_path)',
177     'libchromium_android_linker': 'libchromium_android_linker.>(android_product_extension)',
178     'extra_native_libs': [],
179     'native_lib_placeholder_stamp': '<(apk_package_native_libs_dir)/<(android_app_abi)/native_lib_placeholder.stamp',
180     'native_lib_placeholders': [],
181   },
182   # Pass the jar path to the apk's "fake" jar target.  This would be better as
183   # direct_dependent_settings, but a variable set by a direct_dependent_settings
184   # cannot be lifted in a dependent to all_dependent_settings.
185   'all_dependent_settings': {
186     'conditions': [
187       ['proguard_enabled == "true"', {
188         'variables': {
189           'proguard_enabled': 'true',
190         }
191       }],
192     ],
193     'variables': {
194       'apk_output_jar_path': '<(jar_path)',
195       'tested_apk_obfuscated_jar_path': '<(obfuscated_jar_path)',
196       'tested_apk_dex_path': '<(dex_path)',
197     },
198   },
199   'conditions': [
200     ['resource_dir!=""', {
201       'variables': {
202         'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ]
203       },
204     }],
205     ['R_package != ""', {
206       'variables': {
207         # We generate R.java in package R_package (in addition to the package
208         # listed in the AndroidManifest.xml, which is unavoidable).
209         'additional_res_packages': ['<(R_package)'],
210         'additional_R_text_files': ['<(intermediate_dir)/R.txt'],
211       },
212     }],
213     ['native_lib_target != "" and component == "shared_library"', {
214       'dependencies': [
215         '<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
216       ],
217     }],
218     ['use_chromium_linker == 1', {
219       'dependencies': [
220         '<(DEPTH)/base/base.gyp:chromium_android_linker',
221       ],
222     }],
223     ['native_lib_target != ""', {
224       'variables': {
225         'conditions': [
226           ['use_chromium_linker == 1', {
227             'variables': {
228               'chromium_linker_path': [
229                 '<(SHARED_LIB_DIR)/<(libchromium_android_linker)',
230               ],
231             }
232           }, {
233             'variables': {
234               'chromium_linker_path': [],
235             },
236           }],
237         ],
238         'generated_src_dirs': [ '<(native_libraries_java_dir)' ],
239         'native_libs_paths': [
240           '<(SHARED_LIB_DIR)/<(native_lib_target).>(android_product_extension)',
241           '<@(chromium_linker_path)'
242         ],
243         'package_input_paths': [
244           '<(apk_package_native_libs_dir)/<(android_app_abi)/gdbserver',
245         ],
246       },
247       'copies': [
248         {
249           # gdbserver is always copied into the APK's native libs dir. The ant
250           # build scripts (apkbuilder task) will only include it in a debug
251           # build.
252           'destination': '<(apk_package_native_libs_dir)/<(android_app_abi)',
253           'files': [
254             '<(android_gdbserver)',
255           ],
256         },
257       ],
258       'actions': [
259         {
260           'variables': {
261             'input_libraries': [
262               '<@(native_libs_paths)',
263               '<@(extra_native_libs)',
264             ],
265           },
266           'includes': ['../build/android/write_ordered_libraries.gypi'],
267         },
268         {
269           'action_name': 'native_libraries_<(_target_name)',
270           'variables': {
271             'conditions': [
272               ['use_chromium_linker == 1', {
273                 'variables': {
274                   'linker_gcc_preprocess_defines': [
275                     '--defines', 'ENABLE_CHROMIUM_LINKER',
276                   ],
277                 }
278               }, {
279                 'variables': {
280                   'linker_gcc_preprocess_defines': [],
281                 },
282               }],
283               ['load_library_from_zip_file == 1', {
284                 'variables': {
285                   'linker_load_from_zip_file_preprocess_defines': [
286                     '--defines', 'ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE',
287                   ],
288                 }
289               }, {
290                 'variables': {
291                   'linker_load_from_zip_file_preprocess_defines': [],
292                 },
293               }],
294               ['enable_chromium_linker_tests == 1', {
295                 'variables': {
296                   'linker_tests_gcc_preprocess_defines': [
297                     '--defines', 'ENABLE_CHROMIUM_LINKER_TESTS',
298                   ],
299                 }
300               }, {
301                 'variables': {
302                   'linker_tests_gcc_preprocess_defines': [],
303                 },
304               }],
305             ],
306             'gcc_preprocess_defines': [
307               '<@(linker_load_from_zip_file_preprocess_defines)',
308               '<@(linker_gcc_preprocess_defines)',
309               '<@(linker_tests_gcc_preprocess_defines)',
310             ],
311           },
312           'message': 'Creating NativeLibraries.java for <(_target_name)',
313           'inputs': [
314             '<(DEPTH)/build/android/gyp/util/build_utils.py',
315             '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
316             '<(ordered_libraries_file)',
317             '<(native_libraries_template)',
318           ],
319           'outputs': [
320             '<(native_libraries_java_stamp)',
321           ],
322           'action': [
323             'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
324             '--include-path=',
325             '--output=<(native_libraries_java_file)',
326             '--template=<(native_libraries_template)',
327             '--stamp=<(native_libraries_java_stamp)',
328             '--defines', 'NATIVE_LIBRARIES_LIST=@FileArg(<(ordered_libraries_file):java_libraries_list)',
329             '--defines', 'NATIVE_LIBRARIES_VERSION_NUMBER="<(native_lib_version_name)"',
330             '<@(gcc_preprocess_defines)',
331           ],
332         },
333         {
334           'action_name': 'strip_native_libraries',
335           'variables': {
336             'ordered_libraries_file%': '<(ordered_libraries_file)',
337             'stripped_libraries_dir%': '<(stripped_libraries_dir)',
338             'input_paths': [
339               '<@(native_libs_paths)',
340               '<@(extra_native_libs)',
341             ],
342             'stamp': '<(strip_stamp)'
343           },
344           'includes': ['../build/android/strip_native_libraries.gypi'],
345         },
346         {
347           'action_name': 'insert_chromium_version',
348           'variables': {
349             'ordered_libraries_file%': '<(ordered_libraries_file)',
350             'stripped_libraries_dir%': '<(stripped_libraries_dir)',
351             'version_string': '<(native_lib_version_name)',
352             'input_paths': [
353               '<(strip_stamp)',
354             ],
355             'stamp': '<(version_stamp)'
356           },
357           'includes': ['../build/android/insert_chromium_version.gypi'],
358         },
359         {
360           'action_name': 'pack_arm_relocations',
361           'variables': {
362             'conditions': [
363               ['use_chromium_linker == 1 and use_relocation_packer == 1 and profiling != 1', {
364                 'enable_packing': 1,
365               }, {
366                 'enable_packing': 0,
367               }],
368             ],
369             'exclude_packing_list': [
370               '<(libchromium_android_linker)',
371             ],
372             'ordered_libraries_file%': '<(ordered_libraries_file)',
373             'stripped_libraries_dir%': '<(stripped_libraries_dir)',
374             'packed_libraries_dir': '<(libraries_source_dir)',
375             'input_paths': [
376               '<(version_stamp)'
377             ],
378             'stamp': '<(pack_arm_relocations_stamp)',
379           },
380           'includes': ['../build/android/pack_arm_relocations.gypi'],
381         },
382         {
383           'variables': {
384             'input_libraries': [
385               '<@(additional_bundled_libs)',
386             ],
387             'ordered_libraries_file': '<(additional_ordered_libraries_file)',
388             'subtarget': '_additional_libraries',
389           },
390           'includes': ['../build/android/write_ordered_libraries.gypi'],
391         },
392         {
393           'action_name': 'strip_additional_libraries',
394           'variables': {
395             'ordered_libraries_file': '<(additional_ordered_libraries_file)',
396             'stripped_libraries_dir': '<(libraries_source_dir)',
397             'input_paths': [
398               '<@(additional_bundled_libs)',
399               '<(strip_stamp)',
400             ],
401             'stamp': '<(strip_additional_stamp)'
402           },
403           'includes': ['../build/android/strip_native_libraries.gypi'],
404         },
405         {
406           'action_name': 'Create native lib placeholder files for previous releases',
407           'variables': {
408             'placeholders': ['<@(native_lib_placeholders)'],
409             'conditions': [
410               ['gyp_managed_install == 1', {
411                 # This "library" just needs to be put in the .apk. It is not loaded
412                 # at runtime.
413                 'placeholders': ['libfix.crbug.384638.so'],
414               }]
415             ],
416           },
417           'inputs': [
418             '<(DEPTH)/build/android/gyp/create_placeholder_files.py',
419           ],
420           'outputs': [
421             '<(native_lib_placeholder_stamp)',
422           ],
423           'action': [
424             'python', '<(DEPTH)/build/android/gyp/create_placeholder_files.py',
425             '--dest-lib-dir=<(apk_package_native_libs_dir)/<(android_app_abi)/',
426             '--stamp=<(native_lib_placeholder_stamp)',
427             '<@(placeholders)',
428           ],
429         },
430       ],
431       'conditions': [
432         ['gyp_managed_install == 1', {
433           'variables': {
434             'libraries_top_dir': '<(intermediate_dir)/lib.stripped',
435             'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)',
436             'device_library_dir': '<(device_intermediate_dir)/lib.stripped',
437             'configuration_name': '<(CONFIGURATION_NAME)',
438           },
439           'dependencies': [
440             '<(DEPTH)/build/android/setup.gyp:get_build_device_configurations',
441             '<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
442           ],
443           'actions': [
444             {
445               'includes': ['../build/android/push_libraries.gypi'],
446             },
447             {
448               'action_name': 'create device library symlinks',
449               'message': 'Creating links on device for <(_target_name)',
450               'inputs': [
451                 '<(DEPTH)/build/android/gyp/util/build_utils.py',
452                 '<(DEPTH)/build/android/gyp/create_device_library_links.py',
453                 '<(apk_install_record)',
454                 '<(build_device_config_path)',
455                 '<(ordered_libraries_file)',
456               ],
457               'outputs': [
458                 '<(link_stamp)'
459               ],
460               'action': [
461                 'python', '<(DEPTH)/build/android/gyp/create_device_library_links.py',
462                 '--build-device-configuration=<(build_device_config_path)',
463                 '--libraries=@FileArg(<(ordered_libraries_file):libraries)',
464                 '--script-host-path=<(symlink_script_host_path)',
465                 '--script-device-path=<(symlink_script_device_path)',
466                 '--target-dir=<(device_library_dir)',
467                 '--apk=<(incomplete_apk_path)',
468                 '--stamp=<(link_stamp)',
469                 '--configuration-name=<(CONFIGURATION_NAME)',
470               ],
471             },
472           ],
473           'conditions': [
474             ['create_standalone_apk == 1', {
475               'actions': [
476                 {
477                   'action_name': 'create standalone APK',
478                   'variables': {
479                     'inputs': [
480                       '<(ordered_libraries_file)',
481                       '<(strip_additional_stamp)',
482                       '<(pack_arm_relocations_stamp)',
483                     ],
484                     'input_apk_path': '<(unsigned_apk_path)',
485                     'output_apk_path': '<(unsigned_standalone_apk_path)',
486                     'libraries_top_dir%': '<(libraries_top_dir)',
487                   },
488                   'includes': [ 'android/create_standalone_apk_action.gypi' ],
489                 },
490               ],
491             }],
492           ],
493         }, {
494           # gyp_managed_install != 1
495           'variables': {
496             'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_app_abi)',
497             'package_input_paths': [
498               '<(strip_additional_stamp)',
499               '<(pack_arm_relocations_stamp)',
500             ],
501           },
502         }],
503       ],
504     }], # native_lib_target != ''
505     ['gyp_managed_install == 0 or create_standalone_apk == 1', {
506       'actions': [
507         {
508           'action_name': 'finalize standalone apk',
509           'variables': {
510             'input_apk_path': '<(unsigned_standalone_apk_path)',
511             'output_apk_path': '<(final_apk_path)',
512           },
513           'includes': [ 'android/finalize_apk_action.gypi']
514         },
515       ],
516       'dependencies': [
517         '<(DEPTH)/build/android/rezip.gyp:rezip_apk_jar',
518       ],
519     }],
520     ['gyp_managed_install == 1', {
521       'actions': [
522         {
523           'action_name': 'finalize incomplete apk',
524           'variables': {
525             'input_apk_path': '<(unsigned_apk_path)',
526             'output_apk_path': '<(incomplete_apk_path)',
527           },
528           'includes': [ 'android/finalize_apk_action.gypi']
529         },
530         {
531           'action_name': 'apk_install_<(_target_name)',
532           'message': 'Installing <(apk_name).apk',
533           'inputs': [
534             '<(DEPTH)/build/android/gyp/util/build_utils.py',
535             '<(DEPTH)/build/android/gyp/apk_install.py',
536             '<(build_device_config_path)',
537             '<(incomplete_apk_path)',
538           ],
539           'outputs': [
540             '<(apk_install_record)',
541           ],
542           'action': [
543             'python', '<(DEPTH)/build/android/gyp/apk_install.py',
544             '--apk-path=<(incomplete_apk_path)',
545             '--build-device-configuration=<(build_device_config_path)',
546             '--install-record=<(apk_install_record)',
547             '--configuration-name=<(CONFIGURATION_NAME)',
548           ],
549         },
550       ],
551       'dependencies': [
552         '<(DEPTH)/build/android/rezip.gyp:rezip_apk_jar',
553       ],
554     }],
555     ['is_test_apk == 1', {
556       'dependencies': [
557         '<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
558         '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
559       ]
560     }],
561   ],
562   'dependencies': [
563     '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum',
564   ],
565   'actions': [
566     {
567       'action_name': 'process_resources',
568       'message': 'processing resources for <(_target_name)',
569       'variables': {
570         # Write the inputs list to a file, so that its mtime is updated when
571         # the list of inputs changes.
572         'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))',
573         'process_resources_options': [],
574         'conditions': [
575           ['is_test_apk == 1', {
576             'dependencies_res_zip_paths=': [],
577             'additional_res_packages=': [],
578           }],
579           ['res_v14_verify_only == 1', {
580             'process_resources_options+': ['--v14-verify-only']
581           }],
582           ['shared_resources == 1', {
583             'process_resources_options+': ['--shared-resources']
584           }],
585         ],
586       },
587       'inputs': [
588         '<(DEPTH)/build/android/gyp/util/build_utils.py',
589         '<(DEPTH)/build/android/gyp/process_resources.py',
590         '<(android_manifest_path)',
591         '>@(additional_input_paths)',
592         '>@(resource_input_paths)',
593         '>@(dependencies_res_zip_paths)',
594         '>(inputs_list_file)',
595       ],
596       'outputs': [
597         '<(resource_zip_path)',
598         '<(generated_proguard_file)',
599         '<(codegen_stamp)',
600       ],
601       'action': [
602         'python', '<(DEPTH)/build/android/gyp/process_resources.py',
603         '--android-sdk', '<(android_sdk)',
604         '--android-sdk-tools', '<(android_sdk_tools)',
606         '--android-manifest', '<(android_manifest_path)',
607         '--dependencies-res-zips', '>(dependencies_res_zip_paths)',
609         '--extra-res-packages', '>(additional_res_packages)',
610         '--extra-r-text-files', '>(additional_R_text_files)',
612         '--proguard-file', '<(generated_proguard_file)',
614         '--resource-dirs', '<(resource_dir)',
615         '--resource-zip-out', '<(resource_zip_path)',
617         '--R-dir', '<(intermediate_dir)/gen',
619         '--stamp', '<(codegen_stamp)',
621         '<@(process_resources_options)',
622       ],
623     },
624     {
625       'action_name': 'javac_<(_target_name)',
626       'message': 'Compiling java for <(_target_name)',
627       'variables': {
628         'gen_src_dirs': [
629           '<(intermediate_dir)/gen',
630           '>@(generated_src_dirs)',
631         ],
632         # If there is a separate find for additional_src_dirs, it will find the
633         # wrong .java files when additional_src_dirs is empty.
634         # TODO(thakis): Gyp caches >! evaluation by command. Both java.gypi and
635         # java_apk.gypi evaluate the same command, and at the moment two targets
636         # set java_in_dir to "java". Add a dummy comment here to make sure
637         # that the two targets (one uses java.gypi, the other java_apk.gypi)
638         # get distinct source lists. Medium-term, make targets list all their
639         # Java files instead of using find. (As is, this will be broken if two
640         # targets use the same java_in_dir and both use java_apk.gypi or
641         # both use java.gypi.)
642         'java_sources': ['>!@(find >(java_in_dir)>(java_in_dir_suffix) >(additional_src_dirs) -name "*.java"  # apk)'],
644       },
645       'inputs': [
646         '<(DEPTH)/build/android/gyp/util/build_utils.py',
647         '<(DEPTH)/build/android/gyp/javac.py',
648         '>@(java_sources)',
649         '>@(input_jars_paths)',
650         '<(codegen_stamp)',
651       ],
652       'conditions': [
653         ['native_lib_target != ""', {
654           'inputs': [ '<(native_libraries_java_stamp)' ],
655         }],
656       ],
657       'outputs': [
658         '<(compile_stamp)',
659         '<(javac_jar_path)',
660       ],
661       'action': [
662         'python', '<(DEPTH)/build/android/gyp/javac.py',
663         '--classpath=>(input_jars_paths) <(android_sdk_jar)',
664         '--src-gendirs=>(gen_src_dirs)',
665         '--javac-includes=<(javac_includes)',
666         '--chromium-code=<(chromium_code)',
667         '--jar-path=<(javac_jar_path)',
668         '--jar-excluded-classes=<(jar_excluded_classes)',
669         '--stamp=<(compile_stamp)',
670         '>@(java_sources)',
671       ],
672     },
673     {
674       'action_name': 'instr_jar_<(_target_name)',
675       'message': 'Instrumenting <(_target_name) jar',
676       'variables': {
677         'input_path': '<(javac_jar_path)',
678         'output_path': '<(jar_path)',
679         'stamp_path': '<(instr_stamp)',
680         'instr_type': 'jar',
681       },
682       'outputs': [
683         '<(instr_stamp)',
684         '<(jar_path)',
685       ],
686       'inputs': [
687         '<(javac_jar_path)',
688       ],
689       'includes': [ 'android/instr_action.gypi' ],
690     },
691     {
692       'variables': {
693         'src_dirs': [
694           '<(java_in_dir)<(java_in_dir_suffix)',
695           '>@(additional_src_dirs)',
696         ],
697         'lint_jar_path': '<(jar_path)',
698         'stamp_path': '<(lint_stamp)',
699         'result_path': '<(lint_result)',
700         'config_path': '<(lint_config)',
701       },
702       'outputs': [
703         '<(lint_stamp)',
704       ],
705       'includes': [ 'android/lint_action.gypi' ],
706     },
707     {
708       'action_name': 'obfuscate_<(_target_name)',
709       'message': 'Obfuscating <(_target_name)',
710       'variables': {
711         'additional_obfuscate_options': [],
712         'additional_obfuscate_input_paths': [],
713         'proguard_out_dir': '<(intermediate_dir)/proguard',
714         'proguard_input_jar_paths': [
715           '>@(input_jars_paths)',
716           '<(jar_path)',
717         ],
718         'target_conditions': [
719           ['is_test_apk == 1', {
720             'additional_obfuscate_options': [
721               '--testapp',
722             ],
723           }],
724           ['is_test_apk == 1 and tested_apk_obfuscated_jar_path != "/"', {
725             'additional_obfuscate_options': [
726               '--tested-apk-obfuscated-jar-path', '>(tested_apk_obfuscated_jar_path)',
727             ],
728             'additional_obfuscate_input_paths': [
729               '>(tested_apk_obfuscated_jar_path).info',
730             ],
731           }],
732           ['proguard_enabled == "true"', {
733             'additional_obfuscate_options': [
734               '--proguard-enabled',
735             ],
736           }],
737         ],
738         'obfuscate_input_jars_paths': [
739           '>@(input_jars_paths)',
740           '<(jar_path)',
741         ],
742       },
743       'conditions': [
744         ['is_test_apk == 1', {
745           'outputs': [
746             '<(test_jar_path)',
747           ],
748         }],
749       ],
750       'inputs': [
751         '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
752         '<(DEPTH)/build/android/gyp/util/build_utils.py',
753         '>@(proguard_flags_paths)',
754         '>@(obfuscate_input_jars_paths)',
755         '>@(additional_obfuscate_input_paths)',
756         '<(instr_stamp)',
757       ],
758       'outputs': [
759         '<(obfuscate_stamp)',
761         # In non-Release builds, these paths will all be empty files.
762         '<(obfuscated_jar_path)',
763         '<(obfuscated_jar_path).info',
764         '<(obfuscated_jar_path).dump',
765         '<(obfuscated_jar_path).seeds',
766         '<(obfuscated_jar_path).mapping',
767         '<(obfuscated_jar_path).usage',
768       ],
769       'action': [
770         'python', '<(DEPTH)/build/android/gyp/apk_obfuscate.py',
772         '--configuration-name', '<(CONFIGURATION_NAME)',
774         '--android-sdk', '<(android_sdk)',
775         '--android-sdk-tools', '<(android_sdk_tools)',
776         '--android-sdk-jar', '<(android_sdk_jar)',
778         '--input-jars-paths=>(proguard_input_jar_paths)',
779         '--proguard-configs=>(proguard_flags_paths)',
782         '--test-jar-path', '<(test_jar_path)',
783         '--obfuscated-jar-path', '<(obfuscated_jar_path)',
785         '--proguard-jar-path', '<(android_sdk_root)/tools/proguard/lib/proguard.jar',
787         '--stamp', '<(obfuscate_stamp)',
789         '>@(additional_obfuscate_options)',
790       ],
791     },
792     {
793       'action_name': 'dex_<(_target_name)',
794       'variables': {
795         'dex_input_paths': [
796           '>@(library_dexed_jars_paths)',
797           '<(jar_path)',
798         ],
799         'output_path': '<(dex_path)',
800         'proguard_enabled_input_path': '<(obfuscated_jar_path)',
801       },
802       'target_conditions': [
803         ['emma_instrument != 0', {
804           'variables': {
805             'dex_no_locals': 1,
806             'dex_input_paths': [
807               '<(emma_device_jar)'
808             ],
809           },
810         }],
811         ['is_test_apk == 1 and tested_apk_dex_path != "/"', {
812           'variables': {
813             'dex_additional_options': [
814               '--excluded-paths-file', '>(tested_apk_dex_path).inputs'
815             ],
816           },
817           'inputs': [
818             '>(tested_apk_dex_path).inputs',
819           ],
820         }],
821         ['proguard_enabled == "true"', {
822           'inputs': [ '<(obfuscate_stamp)' ]
823         }, {
824           'inputs': [ '<(instr_stamp)' ]
825         }],
826       ],
827       'includes': [ 'android/dex_action.gypi' ],
828     },
829     {
830       'action_name': 'package_resources',
831       'message': 'packaging resources for <(_target_name)',
832       'variables': {
833         'package_resources_options': [],
834         'package_resource_zip_input_paths': [
835           '<(resource_zip_path)',
836           '>@(dependencies_res_zip_paths)',
837         ],
838         'conditions': [
839           ['shared_resources == 1', {
840             'package_resources_options+': ['--shared-resources']
841           }],
842         ],
843       },
844       'conditions': [
845         ['is_test_apk == 1', {
846           'variables': {
847             'dependencies_res_zip_paths=': [],
848             'additional_res_packages=': [],
849           }
850         }],
851       ],
852       'inputs': [
853         # TODO: This isn't always rerun correctly, http://crbug.com/351928
854         '<(DEPTH)/build/android/gyp/util/build_utils.py',
855         '<(DEPTH)/build/android/gyp/package_resources.py',
856         '<(android_manifest_path)',
858         '>@(package_resource_zip_input_paths)',
860         '<(codegen_stamp)',
861       ],
862       'outputs': [
863         '<(resource_packaged_apk_path)',
864       ],
865       'action': [
866         'python', '<(DEPTH)/build/android/gyp/package_resources.py',
867         '--android-sdk', '<(android_sdk)',
868         '--android-sdk-tools', '<(android_sdk_tools)',
870         '--configuration-name', '<(CONFIGURATION_NAME)',
872         '--android-manifest', '<(android_manifest_path)',
873         '--version-code', '<(app_manifest_version_code)',
874         '--version-name', '<(app_manifest_version_name)',
876         '--asset-dir', '<(asset_location)',
877         '--resource-zips', '>(package_resource_zip_input_paths)',
879         '--no-compress', '<(extensions_to_not_compress)',
881         '--apk-path', '<(resource_packaged_apk_path)',
883         '<@(package_resources_options)',
884       ],
885     },
886     {
887       'action_name': 'ant_package_<(_target_name)',
888       'message': 'Packaging <(_target_name)',
889       'variables': {
890         # Write the inputs list to a file, so that its mtime is updated when
891         # the list of inputs changes.
892         'inputs_list_file': '>|(apk_package.<(_target_name).gypcmd >@(package_input_paths))'
893       },
894       'inputs': [
895         '<(DEPTH)/build/android/ant/apk-package.xml',
896         '<(DEPTH)/build/android/gyp/util/build_utils.py',
897         '<(DEPTH)/build/android/gyp/ant.py',
898         '<(dex_path)',
899         '<(codegen_stamp)',
900         '<(obfuscate_stamp)',
901         '<(resource_packaged_apk_path)',
902         '>@(package_input_paths)',
903         '>(inputs_list_file)',
904       ],
905       'outputs': [
906         '<(unsigned_apk_path)',
907       ],
908       'conditions': [
909         ['native_lib_target != ""', {
910           'inputs': ['<(native_lib_placeholder_stamp)'],
911         }],
912       ],
913       'action': [
914         'python', '<(DEPTH)/build/android/gyp/ant.py',
915         '--',
916         '-quiet',
917         '-DDEX_FILE_PATH=<(intermediate_dir)/classes.dex',
918         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
919         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
920         '-DRESOURCE_PACKAGED_APK_NAME=<(resource_packaged_apk_name)',
921         '-DAPK_NAME=<(apk_name)',
922         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
923         '-DNATIVE_LIBS_DIR=<(apk_package_native_libs_dir)',
924         '-DOUT_DIR=<(intermediate_dir)',
925         '-DUNSIGNED_APK_PATH=<(unsigned_apk_path)',
926         '-DEMMA_INSTRUMENT=<(emma_instrument)',
927         '-DEMMA_DEVICE_JAR=<(emma_device_jar)',
929         '-Dbasedir=.',
930         '-buildfile',
931         '<(DEPTH)/build/android/ant/apk-package.xml',
932       ]
933     },
934   ],