WebViewGuest: Add missing break statement.
[chromium-blink-merge.git] / build / java_apk.gypi
blobc94959a980bc1c5141ffbfdb727ccd1399ee6347
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 #  asset_location - The directory where assets are located.
33 #  generated_src_dirs - Same as additional_src_dirs except used for .java files
34 #    that are generated at build time. This should be set automatically by a
35 #    target's dependencies. The .java files in these directories are not
36 #    included in the 'inputs' list (unlike additional_src_dirs).
37 #  input_jars_paths - The path to jars to be included in the classpath. This
38 #    should be filled automatically by depending on the appropriate targets.
39 #  is_test_apk - Set to 1 if building a test apk.  This prevents resources from
40 #    dependencies from being re-included.
41 #  native_lib_target - The target_name of the target which generates the final
42 #    shared library to be included in this apk. A stripped copy of the
43 #    library will be included in the apk.
44 #  resource_dir - The directory for resources.
45 #  R_package - A custom Java package to generate the resource file R.java in.
46 #    By default, the package given in AndroidManifest.xml will be used.
47 #  use_chromium_linker - Enable the content dynamic linker that allows sharing the
48 #    RELRO section of the native libraries between the different processes.
49 #  enable_chromium_linker_tests - Enable the content dynamic linker test support
50 #    code. This allows a test APK to inject a Linker.TestRunner instance at
51 #    runtime. Should only be used by the chromium_linker_test_apk target!!
52 #  never_lint - Set to 1 to not run lint on this target.
54   'variables': {
55     'additional_input_paths': [],
56     'input_jars_paths': [],
57     'library_dexed_jars_paths': [],
58     'additional_src_dirs': [],
59     'generated_src_dirs': [],
60     'app_manifest_version_name%': '<(android_app_version_name)',
61     'app_manifest_version_code%': '<(android_app_version_code)',
62     # aapt generates this proguard.txt.
63     'generated_proguard_file': '<(intermediate_dir)/proguard.txt',
64     'proguard_enabled%': 'false',
65     'proguard_flags_paths': ['<(generated_proguard_file)'],
66     'jar_name': 'chromium_apk_<(_target_name).jar',
67     'resource_dir%':'<(DEPTH)/build/android/ant/empty/res',
68     'R_package%':'',
69     'additional_R_text_files': [],
70     'additional_res_dirs': [],
71     'additional_res_packages': [],
72     'is_test_apk%': 0,
73     'resource_input_paths': [],
74     'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)',
75     'asset_location%': '<(intermediate_dir)/assets',
76     'codegen_stamp': '<(intermediate_dir)/codegen.stamp',
77     'package_input_paths': [],
78     'ordered_libraries_file': '<(intermediate_dir)/native_libraries.json',
79     'native_libraries_template': '<(DEPTH)/base/android/java/templates/NativeLibraries.template',
80     'native_libraries_java_dir': '<(intermediate_dir)/native_libraries_java/',
81     'native_libraries_java_file': '<(native_libraries_java_dir)/NativeLibraries.java',
82     'native_libraries_java_stamp': '<(intermediate_dir)/native_libraries_java.stamp',
83     'native_libraries_template_data_dir': '<(intermediate_dir)/native_libraries/',
84     'native_libraries_template_data_file': '<(native_libraries_template_data_dir)/native_libraries_array.h',
85     'native_libraries_template_version_file': '<(native_libraries_template_data_dir)/native_libraries_version.h',
86     'compile_stamp': '<(intermediate_dir)/compile.stamp',
87     'lint_stamp': '<(intermediate_dir)/lint.stamp',
88     'lint_result': '<(intermediate_dir)/lint_result.xml',
89     'lint_config': '<(intermediate_dir)/lint_config.xml',
90     'never_lint%': 0,
91     'instr_stamp': '<(intermediate_dir)/instr.stamp',
92     'jar_stamp': '<(intermediate_dir)/jar.stamp',
93     'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp',
94     'strip_stamp': '<(intermediate_dir)/strip.stamp',
95     'classes_dir': '<(intermediate_dir)/classes',
96     'classes_final_dir': '<(intermediate_dir)/classes_instr',
97     'javac_includes': [],
98     'jar_excluded_classes': [],
99     'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)',
100     'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar',
101     'dex_path': '<(intermediate_dir)/classes.dex',
102     'emma_device_jar': '<(android_sdk_root)/tools/lib/emma_device.jar',
103     'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml',
104     'push_stamp': '<(intermediate_dir)/push.stamp',
105     'link_stamp': '<(intermediate_dir)/link.stamp',
106     'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp',
107     'crunch_output_dir': '<(intermediate_dir)/res',
108     'resource_packaged_apk_name': '<(apk_name)-resources.ap_',
109     'resource_packaged_apk_path': '<(intermediate_dir)/<(resource_packaged_apk_name)',
110     'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk',
111     'final_apk_path%': '<(PRODUCT_DIR)/apks/<(apk_name).apk',
112     'incomplete_apk_path': '<(intermediate_dir)/<(apk_name)-incomplete.apk',
113     'apk_install_record': '<(intermediate_dir)/apk_install.record.stamp',
114     'device_intermediate_dir': '/data/data/org.chromium.gyp_managed_install/<(_target_name)/<(CONFIGURATION_NAME)',
115     'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh',
116     'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh',
117     'create_standalone_apk%': 1,
118     'variables': {
119       'variables': {
120         'native_lib_target%': '',
121         'native_lib_version_name%': '',
122         'use_chromium_linker%' : 0,
123         'enable_chromium_linker_tests%': 0,
124         'is_test_apk%': 0,
125       },
126       'conditions': [
127         ['gyp_managed_install == 1 and native_lib_target != ""', {
128           'unsigned_standalone_apk_path': '<(intermediate_dir)/<(apk_name)-standalone-unsigned.apk',
129         }, {
130           'unsigned_standalone_apk_path': '<(unsigned_apk_path)',
131         }],
132         ['gyp_managed_install == 1', {
133           'apk_package_native_libs_dir': '<(intermediate_dir)/libs.managed',
134         }, {
135           'apk_package_native_libs_dir': '<(intermediate_dir)/libs',
136         }],
137         ['is_test_apk == 0 and emma_coverage != 0', {
138           'emma_instrument%': 1,
139         },{
140           'emma_instrument%': 0,
141         }],
142       ],
143     },
144     'native_lib_target%': '',
145     'native_lib_version_name%': '',
146     'use_chromium_linker%' : 0,
147     'enable_chromium_linker_tests%': 0,
148     'emma_instrument%': '<(emma_instrument)',
149     'apk_package_native_libs_dir': '<(apk_package_native_libs_dir)',
150     'unsigned_standalone_apk_path': '<(unsigned_standalone_apk_path)',
151     'extra_native_libs': [],
152   },
153   # Pass the jar path to the apk's "fake" jar target.  This would be better as
154   # direct_dependent_settings, but a variable set by a direct_dependent_settings
155   # cannot be lifted in a dependent to all_dependent_settings.
156   'all_dependent_settings': {
157     'variables': {
158       'apk_output_jar_path': '<(jar_path)',
159     },
160   },
161   'conditions': [
162     ['resource_dir!=""', {
163       'variables': {
164         'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ]
165       },
166     }],
167     ['R_package != ""', {
168       'variables': {
169         # We generate R.java in package R_package (in addition to the package
170         # listed in the AndroidManifest.xml, which is unavoidable).
171         'additional_res_dirs': ['<(DEPTH)/build/android/ant/empty/res'],
172         'additional_res_packages': ['<(R_package)'],
173         'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'],
174       },
175     }],
176     ['native_lib_target != "" and component == "shared_library"', {
177       'dependencies': [
178         '<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
179       ],
180     }],
181     ['use_chromium_linker == 1', {
182       'dependencies': [
183         '<(DEPTH)/base/base.gyp:chromium_android_linker',
184       ],
185     }],
186     ['native_lib_target != ""', {
187       'variables': {
188         'generated_src_dirs': [ '<(native_libraries_java_dir)' ],
189         'native_libs_paths': [
190           '<(SHARED_LIB_DIR)/<(native_lib_target).>(android_product_extension)'
191         ],
192         'package_input_paths': [
193           '<(apk_package_native_libs_dir)/<(android_app_abi)/gdbserver',
194         ],
195       },
196       'copies': [
197         {
198           # gdbserver is always copied into the APK's native libs dir. The ant
199           # build scripts (apkbuilder task) will only include it in a debug
200           # build.
201           'destination': '<(apk_package_native_libs_dir)/<(android_app_abi)',
202           'files': [
203             '<(android_gdbserver)',
204           ],
205         },
206       ],
207       'actions': [
208         {
209           'variables': {
210             'conditions': [
211               ['use_chromium_linker == 1', {
212                 'variables': {
213                   'linker_input_libraries': [
214                     '<(SHARED_LIB_DIR)/libchromium_android_linker.>(android_product_extension)',
215                   ],
216                 }
217               }, {
218                 'variables': {
219                   'linker_input_libraries': [],
220                 },
221               }],
222             ],
223             'input_libraries': [
224               '<@(native_libs_paths)',
225               '<@(extra_native_libs)',
226               '<@(linker_input_libraries)',
227             ],
228           },
229           'includes': ['../build/android/write_ordered_libraries.gypi'],
230         },
231         {
232           'action_name': 'native_libraries_template_data_<(_target_name)',
233           'message': 'Creating native_libraries_list.h for <(_target_name)',
234           'inputs': [
235             '<(DEPTH)/build/android/gyp/util/build_utils.py',
236             '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
237             '<(ordered_libraries_file)',
238           ],
239           'outputs': [
240             '<(native_libraries_template_data_file)',
241             '<(native_libraries_template_version_file)',
242           ],
243           'action': [
244             'python', '<(DEPTH)/build/android/gyp/create_native_libraries_header.py',
245             '--ordered-libraries=<(ordered_libraries_file)',
246             '--version-name=<(native_lib_version_name)',
247             '--native-library-list=<(native_libraries_template_data_file)',
248             '--version-output=<(native_libraries_template_version_file)',
249           ],
250         },
251         {
252           'action_name': 'native_libraries_<(_target_name)',
253           'variables': {
254             'conditions': [
255               ['use_chromium_linker == 1', {
256                 'variables': {
257                   'linker_gcc_preprocess_defines': [
258                     '--defines', 'ENABLE_CHROMIUM_LINKER',
259                   ],
260                 }
261               }, {
262                 'variables': {
263                   'linker_gcc_preprocess_defines': [],
264                 },
265               }],
266               ['enable_chromium_linker_tests == 1', {
267                 'variables': {
268                   'linker_tests_gcc_preprocess_defines': [
269                     '--defines', 'ENABLE_CHROMIUM_LINKER_TESTS',
270                   ],
271                 }
272               }, {
273                 'variables': {
274                   'linker_tests_gcc_preprocess_defines': [],
275                 },
276               }],
277             ],
278             'gcc_preprocess_defines': [
279               '<@(linker_gcc_preprocess_defines)',
280               '<@(linker_tests_gcc_preprocess_defines)',
281             ],
282           },
283           'message': 'Creating NativeLibraries.java for <(_target_name)',
284           'inputs': [
285             '<(DEPTH)/build/android/gyp/util/build_utils.py',
286             '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
287             '<(native_libraries_template_data_file)',
288             '<(native_libraries_template_version_file)',
289             '<(native_libraries_template)',
290           ],
291           'outputs': [
292             '<(native_libraries_java_stamp)',
293           ],
294           'action': [
295             'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py',
296             '--include-path=<(native_libraries_template_data_dir)',
297             '--output=<(native_libraries_java_file)',
298             '--template=<(native_libraries_template)',
299             '--stamp=<(native_libraries_java_stamp)',
300             '<@(gcc_preprocess_defines)',
301           ],
302         },
303         {
304           'action_name': 'strip_native_libraries',
305           'variables': {
306             'ordered_libraries_file%': '<(ordered_libraries_file)',
307             'stripped_libraries_dir': '<(libraries_source_dir)',
308             'input_paths': [
309               '<@(native_libs_paths)',
310               '<@(extra_native_libs)',
311             ],
312             'stamp': '<(strip_stamp)'
313           },
314           'includes': ['../build/android/strip_native_libraries.gypi'],
315         },
316       ],
317       'conditions': [
318         ['gyp_managed_install == 1', {
319           'variables': {
320             'libraries_top_dir': '<(intermediate_dir)/lib.stripped',
321             'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)',
322             'device_library_dir': '<(device_intermediate_dir)/lib.stripped',
323             'configuration_name': '<(CONFIGURATION_NAME)',
324           },
325           'dependencies': [
326             '<(DEPTH)/build/android/setup.gyp:get_build_device_configurations',
327           ],
328           'actions': [
329             {
330               'includes': ['../build/android/push_libraries.gypi'],
331             },
332             {
333               'action_name': 'create device library symlinks',
334               'message': 'Creating links on device for <(_target_name)',
335               'inputs': [
336                 '<(DEPTH)/build/android/gyp/util/build_utils.py',
337                 '<(DEPTH)/build/android/gyp/create_device_library_links.py',
338                 '<(apk_install_record)',
339                 '<(build_device_config_path)',
340                 '<(ordered_libraries_file)',
341               ],
342               'outputs': [
343                 '<(link_stamp)'
344               ],
345               'action': [
346                 'python', '<(DEPTH)/build/android/gyp/create_device_library_links.py',
347                 '--build-device-configuration=<(build_device_config_path)',
348                 '--libraries-json=<(ordered_libraries_file)',
349                 '--script-host-path=<(symlink_script_host_path)',
350                 '--script-device-path=<(symlink_script_device_path)',
351                 '--target-dir=<(device_library_dir)',
352                 '--apk=<(incomplete_apk_path)',
353                 '--stamp=<(link_stamp)',
354                 '--configuration-name=<(CONFIGURATION_NAME)',
355               ],
356             },
357           ],
358           'conditions': [
359             ['create_standalone_apk == 1', {
360               'actions': [
361                 {
362                   'action_name': 'create standalone APK',
363                   'variables': {
364                     'inputs': [
365                       '<(ordered_libraries_file)',
366                       '<(strip_stamp)',
367                     ],
368                     'input_apk_path': '<(unsigned_apk_path)',
369                     'output_apk_path': '<(unsigned_standalone_apk_path)',
370                     'libraries_top_dir%': '<(libraries_top_dir)',
371                   },
372                   'includes': [ 'android/create_standalone_apk_action.gypi' ],
373                 },
374               ],
375             }],
376           ],
377         }, {
378           # gyp_managed_install != 1
379           'variables': {
380             'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_app_abi)',
381             'package_input_paths': [ '<(strip_stamp)' ],
382           },
383         }],
384       ],
385     }], # native_lib_target != ''
386     ['gyp_managed_install == 0 or create_standalone_apk == 1', {
387       'actions': [
388         {
389           'action_name': 'finalize standalone apk',
390           'variables': {
391             'input_apk_path': '<(unsigned_standalone_apk_path)',
392             'output_apk_path': '<(final_apk_path)',
393           },
394           'includes': [ 'android/finalize_apk_action.gypi']
395         },
396       ],
397     }],
398     ['gyp_managed_install == 1', {
399       'actions': [
400         {
401           'action_name': 'finalize incomplete apk',
402           'variables': {
403             'input_apk_path': '<(unsigned_apk_path)',
404             'output_apk_path': '<(incomplete_apk_path)',
405           },
406           'includes': [ 'android/finalize_apk_action.gypi']
407         },
408         {
409           'action_name': 'apk_install_<(_target_name)',
410           'message': 'Installing <(apk_name).apk',
411           'inputs': [
412             '<(DEPTH)/build/android/gyp/util/build_utils.py',
413             '<(DEPTH)/build/android/gyp/apk_install.py',
414             '<(build_device_config_path)',
415             '<(incomplete_apk_path)',
416           ],
417           'outputs': [
418             '<(apk_install_record)',
419           ],
420           'action': [
421             'python', '<(DEPTH)/build/android/gyp/apk_install.py',
422             '--apk-path=<(incomplete_apk_path)',
423             '--build-device-configuration=<(build_device_config_path)',
424             '--install-record=<(apk_install_record)',
425             '--configuration-name=<(CONFIGURATION_NAME)',
426           ],
427         },
428       ],
429     }],
430     ['is_test_apk == 1', {
431       'dependencies': [
432         '<(DEPTH)/tools/android/android_tools.gyp:android_tools',
433       ]
434     }],
435   ],
436   'dependencies': [
437     '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum',
438   ],
439   'actions': [
440     {
441       'action_name': 'process_resources',
442       'message': 'processing resources for <(_target_name)',
443       'variables': {
444         # Write the inputs list to a file, so that its mtime is updated when
445         # the list of inputs changes.
446         'inputs_list_file': '>|(apk_codegen.<(_target_name).gypcmd >@(additional_input_paths) >@(resource_input_paths))',
447       },
448       'conditions': [
449         ['is_test_apk == 1', {
450           'variables': {
451             'additional_res_dirs=': [],
452             'additional_res_packages=': [],
453           }
454         }],
455       ],
456       'inputs': [
457         '<(DEPTH)/build/android/gyp/util/build_utils.py',
458         '<(DEPTH)/build/android/gyp/process_resources.py',
459         '<(android_manifest_path)',
460         '>@(additional_input_paths)',
461         '>@(resource_input_paths)',
462         '>(inputs_list_file)',
463       ],
464       'outputs': [
465         '<(generated_proguard_file)',
466         '<(codegen_stamp)',
467       ],
468       'action': [
469         'python', '<(DEPTH)/build/android/gyp/process_resources.py',
470         '--android-sdk', '<(android_sdk)',
471         '--android-sdk-tools', '<(android_sdk_tools)',
473         '--android-manifest', '<(android_manifest_path)',
474         '--dependencies-res-dirs', '>(additional_res_dirs)',
476         '--extra-res-packages', '>(additional_res_packages)',
477         '--extra-r-text-files', '>(additional_R_text_files)',
479         '--proguard-file', '<(generated_proguard_file)',
481         '--resource-dir', '<(resource_dir)',
482         '--crunch-output-dir', '<(crunch_output_dir)',
484         '--R-dir', '<(intermediate_dir)/gen',
486         '--stamp', '<(codegen_stamp)',
487       ],
488     },
489     {
490       'action_name': 'javac_<(_target_name)',
491       'message': 'Compiling java for <(_target_name)',
492       'variables': {
493         'gen_src_dirs': [
494           '<(intermediate_dir)/gen',
495           '>@(generated_src_dirs)',
496         ],
497         # If there is a separate find for additional_src_dirs, it will find the
498         # wrong .java files when additional_src_dirs is empty.
499         # TODO(thakis): Gyp caches >! evaluation by command. Both java.gypi and
500         # java_apk.gypi evaluate the same command, and at the moment two targets
501         # set java_in_dir to "java". Add a dummy comment here to make sure
502         # that the two targets (one uses java.gypi, the other java_apk.gypi)
503         # get distinct source lists. Medium-term, make targets list all their
504         # Java files instead of using find. (As is, this will be broken if two
505         # targets use the same java_in_dir and both use java_apk.gypi or
506         # both use java.gypi.)
507         'java_sources': ['>!@(find >(java_in_dir)/src >(additional_src_dirs) -name "*.java"  # apk)'],
509       },
510       'inputs': [
511         '<(DEPTH)/build/android/gyp/util/build_utils.py',
512         '<(DEPTH)/build/android/gyp/javac.py',
513         '>@(java_sources)',
514         '>@(input_jars_paths)',
515         '<(codegen_stamp)',
516       ],
517       'conditions': [
518         ['native_lib_target != ""', {
519           'inputs': [ '<(native_libraries_java_stamp)' ],
520         }],
521       ],
522       'outputs': [
523         '<(compile_stamp)',
524       ],
525       'action': [
526         'python', '<(DEPTH)/build/android/gyp/javac.py',
527         '--output-dir=<(classes_dir)',
528         '--classpath=>(input_jars_paths) <(android_sdk_jar)',
529         '--src-gendirs=>(gen_src_dirs)',
530         '--javac-includes=<(javac_includes)',
531         '--chromium-code=<(chromium_code)',
532         '--stamp=<(compile_stamp)',
533         '>@(java_sources)',
534       ],
535     },
536     {
537       'variables': {
538         'src_dirs': [
539           '<(java_in_dir)/src',
540           '>@(additional_src_dirs)',
541         ],
542         'stamp_path': '<(lint_stamp)',
543         'result_path': '<(lint_result)',
544         'config_path': '<(lint_config)',
545       },
546       'inputs': [
547         '<(compile_stamp)',
548       ],
549       'outputs': [
550         '<(lint_stamp)',
551       ],
552       'includes': [ 'android/lint_action.gypi' ],
553     },
554     {
555       'action_name': 'instr_classes_<(_target_name)',
556       'message': 'Instrumenting <(_target_name) classes',
557       'variables': {
558         'input_path': '<(classes_dir)',
559         'output_path': '<(classes_final_dir)',
560         'stamp_path': '<(instr_stamp)',
561         'instr_type': 'classes',
562       },
563       'inputs': [
564         '<(compile_stamp)',
565       ],
566       'outputs': [
567         '<(instr_stamp)',
568       ],
569       'includes': [ 'android/instr_action.gypi' ],
570     },
571     {
572       'action_name': 'jar_<(_target_name)',
573       'message': 'Creating <(_target_name) jar',
574       'inputs': [
575         '<(DEPTH)/build/android/gyp/util/build_utils.py',
576         '<(DEPTH)/build/android/gyp/util/md5_check.py',
577         '<(DEPTH)/build/android/gyp/jar.py',
578         '<(instr_stamp)',
579       ],
580       'outputs': [
581         '<(jar_stamp)',
582       ],
583       'action': [
584         'python', '<(DEPTH)/build/android/gyp/jar.py',
585         '--classes-dir=<(classes_final_dir)',
586         '--jar-path=<(jar_path)',
587         '--excluded-classes=<(jar_excluded_classes)',
588         '--stamp=<(jar_stamp)',
589       ]
590     },
591     {
592       'action_name': 'ant_obfuscate_<(_target_name)',
593       'message': 'Obfuscating <(_target_name)',
594       'inputs': [
595         '<(DEPTH)/build/android/ant/apk-obfuscate.xml',
596         '<(DEPTH)/build/android/gyp/util/build_utils.py',
597         '<(DEPTH)/build/android/gyp/ant.py',
598         '<(android_manifest_path)',
599         '>@(proguard_flags_paths)',
600         '<(instr_stamp)',
601       ],
602       'outputs': [
603         # This lists obfuscate_stamp instead of obfuscated_jar_path because
604         # ant only writes the latter if the md5 of the inputs changes.
605         '<(obfuscate_stamp)',
606       ],
607       'action': [
608         'python', '<(DEPTH)/build/android/gyp/ant.py',
609         '-quiet',
610         '-DANDROID_MANIFEST=<(android_manifest_path)',
611         '-DANDROID_SDK_JAR=<(android_sdk_jar)',
612         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
613         '-DANDROID_SDK_VERSION=<(android_sdk_version)',
614         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
615         '-DAPK_NAME=<(apk_name)',
616         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
617         '-DINPUT_JARS_PATHS=>(input_jars_paths)',
618         '-DIS_TEST_APK=<(is_test_apk)',
619         '-DOBFUSCATED_JAR_PATH=<(obfuscated_jar_path)',
620         '-DOUT_DIR=<(intermediate_dir)',
621         '-DPROGUARD_ENABLED=<(proguard_enabled)',
622         '-DPROGUARD_FLAGS=<(proguard_flags_paths)',
623         '-DTEST_JAR_PATH=<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar',
625         '-DSTAMP=<(obfuscate_stamp)',
626         '-Dbasedir=.',
627         '-buildfile',
628         '<(DEPTH)/build/android/ant/apk-obfuscate.xml',
629       ],
630     },
631     {
632       'action_name': 'dex_<(_target_name)',
633       'variables': {
634         'conditions': [
635           ['emma_instrument != 0', {
636             'dex_no_locals': 1,
637             'dex_input_paths': [ '<(emma_device_jar)' ],
638           }],
639         ],
640         'dex_input_paths': [ '>@(library_dexed_jars_paths)' ],
641         'dex_generated_input_dirs': [ '<(classes_final_dir)' ],
642         'output_path': '<(dex_path)',
643         'proguard_enabled_input_path': '<(obfuscated_jar_path)',
644       },
645       'conditions': [
646         ['proguard_enabled == "true"', { 'inputs': [ '<(obfuscate_stamp)' ] },
647                                        { 'inputs': [ '<(instr_stamp)' ] }],
648       ],
649       'includes': [ 'android/dex_action.gypi' ],
650     },
651     {
652       'action_name': 'package_resources',
653       'message': 'packaging resources for <(_target_name)',
654       'variables': {
655         'extra_package_input_paths': [
656             '>@(package_input_paths)',
657             '>@(additional_input_paths)',
658             '>@(resource_input_paths)'
659         ],
660         'package_resource_dirs': [
661             # <(crunch_output_dir) must come before <(resource_dir) so that
662             # the crunched files take precedence.
663             '<(crunch_output_dir)',
664             '<(resource_dir)',
665             '>@(additional_res_dirs)',
666         ],
667         # Write the inputs list to a file, so that its mtime is updated when
668         # the list of inputs changes.
669         'inputs_list_file': '>|(apk_package.<(_target_name).gypcmd >@(extra_package_input_paths))',
670       },
671       'conditions': [
672         ['is_test_apk == 1', {
673           'variables': {
674             'additional_res_dirs=': [],
675             'additional_res_packages=': [],
676           }
677         }],
678       ],
679       'inputs': [
680         # TODO: This isn't always rerun correctly, http://crbug.com/351928
681         '<(DEPTH)/build/android/gyp/util/build_utils.py',
682         '<(DEPTH)/build/android/gyp/package_resources.py',
683         '<(android_manifest_path)',
685         '<(codegen_stamp)',
687         '>@(extra_package_input_paths)',
688         '>(inputs_list_file)',
689       ],
690       'outputs': [
691         '<(resource_packaged_apk_path)',
692       ],
693       'action': [
694         'python', '<(DEPTH)/build/android/gyp/package_resources.py',
695         '--android-sdk', '<(android_sdk)',
696         '--android-sdk-tools', '<(android_sdk_tools)',
698         '--configuration-name', '<(CONFIGURATION_NAME)',
700         '--android-manifest', '<(android_manifest_path)',
701         '--version-code', '<(app_manifest_version_code)',
702         '--version-name', '<(app_manifest_version_name)',
704         '--asset-dir', '<(asset_location)',
705         '--resource-dirs', '>(package_resource_dirs)',
707         '--apk-path', '<(resource_packaged_apk_path)',
708       ],
709     },
710     {
711       'action_name': 'ant_package_<(_target_name)',
712       'message': 'Packaging <(_target_name)',
713       'variables': {
714         # Write the inputs list to a file, so that its mtime is updated when
715         # the list of inputs changes.
716         'inputs_list_file': '>|(apk_package.<(_target_name).gypcmd >@(package_input_paths))'
717       },
718       'inputs': [
719         '<(DEPTH)/build/android/ant/apk-package.xml',
720         '<(DEPTH)/build/android/gyp/util/build_utils.py',
721         '<(DEPTH)/build/android/gyp/ant.py',
722         '<(dex_path)',
723         '<(codegen_stamp)',
724         '<(obfuscate_stamp)',
725         '<(resource_packaged_apk_path)',
726         '>@(package_input_paths)',
727         '>(inputs_list_file)',
728       ],
729       'outputs': [
730         '<(unsigned_apk_path)',
731       ],
732       'action': [
733         'python', '<(DEPTH)/build/android/gyp/ant.py',
734         '-quiet',
735         '-DANDROID_SDK_ROOT=<(android_sdk_root)',
736         '-DANDROID_SDK_TOOLS=<(android_sdk_tools)',
737         '-DRESOURCE_PACKAGED_APK_NAME=<(resource_packaged_apk_name)',
738         '-DAPK_NAME=<(apk_name)',
739         '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)',
740         '-DNATIVE_LIBS_DIR=<(apk_package_native_libs_dir)',
741         '-DOUT_DIR=<(intermediate_dir)',
742         '-DUNSIGNED_APK_PATH=<(unsigned_apk_path)',
743         '-DEMMA_INSTRUMENT=<(emma_instrument)',
744         '-DEMMA_DEVICE_JAR=<(emma_device_jar)',
746         '-Dbasedir=.',
747         '-buildfile',
748         '<(DEPTH)/build/android/ant/apk-package.xml',
749       ]
750     },
751   ],