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