OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # This file is meant to be included into a target to provide a rule | 5 # This file is meant to be included into a target to provide a rule |
6 # to build Android APKs in a consistent manner. | 6 # to build Android APKs in a consistent manner. |
7 # | 7 # |
8 # To use this, create a gyp target with the following form: | 8 # To use this, create a gyp target with the following form: |
9 # { | 9 # { |
10 # 'target_name': 'my_package_apk', | 10 # 'target_name': 'my_package_apk', |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 'javac_includes': [], | 95 'javac_includes': [], |
96 'jar_excluded_classes': [], | 96 'jar_excluded_classes': [], |
97 'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', | 97 'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
98 'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar', | 98 'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar', |
99 'dex_path': '<(intermediate_dir)/classes.dex', | 99 'dex_path': '<(intermediate_dir)/classes.dex', |
100 'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml', | 100 'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml', |
101 'push_stamp': '<(intermediate_dir)/push.stamp', | 101 'push_stamp': '<(intermediate_dir)/push.stamp', |
102 'link_stamp': '<(intermediate_dir)/link.stamp', | 102 'link_stamp': '<(intermediate_dir)/link.stamp', |
103 'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp', | 103 'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp', |
104 'codegen_input_paths': [], | 104 'codegen_input_paths': [], |
105 'keystore_path': '<(DEPTH)/build/android/ant/chromium-debug.keystore', | |
106 'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk', | 105 'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk', |
107 'final_apk_path%': '<(PRODUCT_DIR)/apks/<(apk_name).apk', | 106 'final_apk_path%': '<(PRODUCT_DIR)/apks/<(apk_name).apk', |
| 107 'incomplete_apk_path': '<(intermediate_dir)/<(apk_name)-incomplete.apk', |
108 'source_dir': '<(java_in_dir)/src', | 108 'source_dir': '<(java_in_dir)/src', |
109 'apk_install_record': '<(intermediate_dir)/apk_install.record.stamp', | 109 'apk_install_record': '<(intermediate_dir)/apk_install.record.stamp', |
110 'device_intermediate_dir': '/data/local/tmp/chromium/<(_target_name)/<(CONFI
GURATION_NAME)', | 110 'device_intermediate_dir': '/data/local/tmp/chromium/<(_target_name)/<(CONFI
GURATION_NAME)', |
111 'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh', | 111 'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh', |
112 'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh
', | 112 'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh
', |
| 113 'create_standalone_apk%': 1, |
113 'variables': { | 114 'variables': { |
114 'conditions': [ | 115 'conditions': [ |
115 ['gyp_managed_install == 1', { | 116 ['gyp_managed_install == 1', { |
116 'apk_package_native_libs_dir': '<(intermediate_dir)/libs.managed', | 117 'apk_package_native_libs_dir': '<(intermediate_dir)/libs.managed', |
| 118 'unsigned_standalone_apk_path': '<(intermediate_dir)/<(apk_name)-stand
alone-unsigned.apk', |
117 }, { | 119 }, { |
118 'apk_package_native_libs_dir': '<(intermediate_dir)/libs', | 120 'apk_package_native_libs_dir': '<(intermediate_dir)/libs', |
| 121 'unsigned_standalone_apk_path': '<(unsigned_apk_path)', |
119 }], | 122 }], |
120 ], | 123 ], |
121 }, | 124 }, |
122 'apk_package_native_libs_dir': '<(apk_package_native_libs_dir)', | 125 'apk_package_native_libs_dir': '<(apk_package_native_libs_dir)', |
| 126 'unsigned_standalone_apk_path': '<(unsigned_standalone_apk_path)', |
123 }, | 127 }, |
124 # Pass the jar path to the apk's "fake" jar target. This would be better as | 128 # Pass the jar path to the apk's "fake" jar target. This would be better as |
125 # direct_dependent_settings, but a variable set by a direct_dependent_settings | 129 # direct_dependent_settings, but a variable set by a direct_dependent_settings |
126 # cannot be lifted in a dependent to all_dependent_settings. | 130 # cannot be lifted in a dependent to all_dependent_settings. |
127 'all_dependent_settings': { | 131 'all_dependent_settings': { |
128 'variables': { | 132 'variables': { |
129 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', | 133 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
130 }, | 134 }, |
131 }, | 135 }, |
132 'conditions': [ | 136 'conditions': [ |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 'variables': { | 224 'variables': { |
221 'stripped_libraries_dir': '<(libraries_source_dir)', | 225 'stripped_libraries_dir': '<(libraries_source_dir)', |
222 'input_paths': ['<@(native_libs_paths)'], | 226 'input_paths': ['<@(native_libs_paths)'], |
223 }, | 227 }, |
224 'includes': ['../build/android/strip_native_libraries.gypi'], | 228 'includes': ['../build/android/strip_native_libraries.gypi'], |
225 }, | 229 }, |
226 ], | 230 ], |
227 'conditions': [ | 231 'conditions': [ |
228 ['gyp_managed_install == 1', { | 232 ['gyp_managed_install == 1', { |
229 'variables': { | 233 'variables': { |
230 'libraries_source_dir': '<(intermediate_dir)/lib.stripped/<(android_
app_abi)', | 234 'libraries_top_dir': '<(intermediate_dir)/lib.stripped', |
| 235 'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)
', |
231 'device_library_dir': '<(device_intermediate_dir)/lib.stripped', | 236 'device_library_dir': '<(device_intermediate_dir)/lib.stripped', |
232 }, | 237 }, |
233 'dependencies': [ | 238 'dependencies': [ |
234 '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum', | 239 '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum', |
235 ], | 240 ], |
236 'actions': [ | 241 'actions': [ |
237 { | 242 { |
238 'includes': ['../build/android/push_libraries.gypi'], | 243 'includes': ['../build/android/push_libraries.gypi'], |
239 }, | 244 }, |
240 { | 245 { |
241 'action_name': 'create device library symlinks', | 246 'action_name': 'create device library symlinks', |
242 'message': 'Creating links on device for <(_target_name).', | 247 'message': 'Creating links on device for <(_target_name).', |
243 'inputs': [ | 248 'inputs': [ |
244 '<(DEPTH)/build/android/gyp/util/build_utils.py', | 249 '<(DEPTH)/build/android/gyp/util/build_utils.py', |
245 '<(DEPTH)/build/android/gyp/create_device_library_links.py', | 250 '<(DEPTH)/build/android/gyp/create_device_library_links.py', |
246 '<(apk_install_record)', | 251 '<(apk_install_record)', |
247 '<(ordered_libraries_file)', | 252 '<(ordered_libraries_file)', |
248 ], | 253 ], |
249 'outputs': [ | 254 'outputs': [ |
250 '<(link_stamp)' | 255 '<(link_stamp)' |
251 ], | 256 ], |
252 'action': [ | 257 'action': [ |
253 'python', '<(DEPTH)/build/android/gyp/create_device_library_link
s.py', | 258 'python', '<(DEPTH)/build/android/gyp/create_device_library_link
s.py', |
254 '--libraries-json=<(ordered_libraries_file)', | 259 '--libraries-json=<(ordered_libraries_file)', |
255 '--script-host-path=<(symlink_script_host_path)', | 260 '--script-host-path=<(symlink_script_host_path)', |
256 '--script-device-path=<(symlink_script_device_path)', | 261 '--script-device-path=<(symlink_script_device_path)', |
257 '--target-dir=<(device_library_dir)', | 262 '--target-dir=<(device_library_dir)', |
258 '--apk=<(final_apk_path)', | 263 '--apk=<(incomplete_apk_path)', |
259 '--stamp=<(link_stamp)', | 264 '--stamp=<(link_stamp)', |
260 ], | 265 ], |
261 }, | 266 }, |
262 ], | 267 ], |
| 268 'conditions': [ |
| 269 ['create_standalone_apk == 1', { |
| 270 'actions': [ |
| 271 { |
| 272 'action_name': 'create standalone APK', |
| 273 'variables': { |
| 274 'inputs': [ |
| 275 '<(ordered_libraries_file)', |
| 276 '<(strip_stamp)', |
| 277 ], |
| 278 'input_apk_path': '<(unsigned_apk_path)', |
| 279 'output_apk_path': '<(unsigned_standalone_apk_path)', |
| 280 'libraries_top_dir%': '<(libraries_top_dir)', |
| 281 }, |
| 282 'includes': [ 'android/create_standalone_apk_action.gypi' ], |
| 283 }, |
| 284 ], |
| 285 }], |
| 286 ], |
263 }, { | 287 }, { |
264 # gyp_managed_install != 1 | 288 # gyp_managed_install != 1 |
265 'variables': { | 289 'variables': { |
266 'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_ap
p_abi)', | 290 'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_ap
p_abi)', |
267 'package_input_paths': [ '<(strip_stamp)' ], | 291 'package_input_paths': [ '<(strip_stamp)' ], |
268 }, | 292 }, |
269 }], | 293 }], |
| 294 ['gyp_managed_install == 0 or create_standalone_apk == 1', { |
| 295 'actions': [ |
| 296 { |
| 297 'action_name': 'finalize standalone apk', |
| 298 'variables': { |
| 299 'input_apk_path': '<(unsigned_standalone_apk_path)', |
| 300 'output_apk_path': '<(final_apk_path)', |
| 301 }, |
| 302 'includes': [ 'android/finalize_apk_action.gypi'] |
| 303 }, |
| 304 ], |
| 305 }], |
270 ], | 306 ], |
271 }], # native_lib_target != '' | 307 }], # native_lib_target != '' |
272 ['java_strings_grd != ""', { | 308 ['java_strings_grd != ""', { |
273 'variables': { | 309 'variables': { |
274 'res_grit_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res_grit
', | 310 'res_grit_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res_grit
', |
275 'additional_res_dirs': ['<(res_grit_dir)'], | 311 'additional_res_dirs': ['<(res_grit_dir)'], |
276 # grit_grd_file is used by grit_action.gypi, included below. | 312 # grit_grd_file is used by grit_action.gypi, included below. |
277 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', | 313 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', |
278 'resource_input_paths': [ | 314 'resource_input_paths': [ |
279 '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(res_grit_dir
)" <(grit_grd_file))' | 315 '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(res_grit_dir
)" <(grit_grd_file))' |
280 ], | 316 ], |
281 }, | 317 }, |
282 'actions': [ | 318 'actions': [ |
283 { | 319 { |
284 'action_name': 'generate_localized_strings_xml', | 320 'action_name': 'generate_localized_strings_xml', |
285 'variables': { | 321 'variables': { |
286 'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=false'], | 322 'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=false'], |
287 'grit_out_dir': '<(res_grit_dir)', | 323 'grit_out_dir': '<(res_grit_dir)', |
288 # resource_ids is unneeded since we don't generate .h headers. | 324 # resource_ids is unneeded since we don't generate .h headers. |
289 'grit_resource_ids': '', | 325 'grit_resource_ids': '', |
290 }, | 326 }, |
291 'includes': ['../build/grit_action.gypi'], | 327 'includes': ['../build/grit_action.gypi'], |
292 }, | 328 }, |
293 ], | 329 ], |
294 }], | 330 }], |
295 ['gyp_managed_install == 1', { | 331 ['gyp_managed_install == 1', { |
296 'actions': [ | 332 'actions': [ |
297 { | 333 { |
| 334 'action_name': 'finalize incomplete apk', |
| 335 'variables': { |
| 336 'input_apk_path': '<(unsigned_apk_path)', |
| 337 'output_apk_path': '<(incomplete_apk_path)', |
| 338 }, |
| 339 'includes': [ 'android/finalize_apk_action.gypi'] |
| 340 }, |
| 341 { |
298 'action_name': 'apk_install_<(_target_name)', | 342 'action_name': 'apk_install_<(_target_name)', |
299 'message': 'Installing <(apk_name).apk', | 343 'message': 'Installing <(apk_name).apk', |
300 'inputs': [ | 344 'inputs': [ |
301 '<(DEPTH)/build/android/gyp/util/build_utils.py', | 345 '<(DEPTH)/build/android/gyp/util/build_utils.py', |
302 '<(DEPTH)/build/android/gyp/apk_install.py', | 346 '<(DEPTH)/build/android/gyp/apk_install.py', |
303 '<(final_apk_path)', | 347 '<(incomplete_apk_path)', |
304 ], | 348 ], |
305 'outputs': [ | 349 'outputs': [ |
306 '<(apk_install_record)', | 350 '<(apk_install_record)', |
307 # If a user switches the connected device, the APK may need to be | 351 # If a user switches the connected device, the APK may need to be |
308 # installed even if there have been no changes. To ensure that the | 352 # installed even if there have been no changes. To ensure that the |
309 # APK on the device is always up-to-date, this step should always | 353 # APK on the device is always up-to-date, this step should always |
310 # be triggered. | 354 # be triggered. |
311 '<(apk_install_record).fake', | 355 '<(apk_install_record).fake', |
312 ], | 356 ], |
313 'action': [ | 357 'action': [ |
314 'python', '<(DEPTH)/build/android/gyp/apk_install.py', | 358 'python', '<(DEPTH)/build/android/gyp/apk_install.py', |
315 '--android-sdk-tools=<(android_sdk_tools)', | 359 '--android-sdk-tools=<(android_sdk_tools)', |
316 '--apk-path=<(final_apk_path)', | 360 '--apk-path=<(incomplete_apk_path)', |
317 '--install-record=<(apk_install_record)' | 361 '--install-record=<(apk_install_record)' |
318 ], | 362 ], |
319 }, | 363 }, |
320 ], | 364 ], |
321 }], | 365 }], |
322 ], | 366 ], |
323 'actions': [ | 367 'actions': [ |
324 { | 368 { |
325 'action_name': 'ant_codegen_<(_target_name)', | 369 'action_name': 'ant_codegen_<(_target_name)', |
326 'message': 'Generating R.java for <(_target_name)', | 370 'message': 'Generating R.java for <(_target_name)', |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 '-Dbasedir=.', | 641 '-Dbasedir=.', |
598 '-buildfile', | 642 '-buildfile', |
599 '<(DEPTH)/build/android/ant/apk-package.xml', | 643 '<(DEPTH)/build/android/ant/apk-package.xml', |
600 | 644 |
601 # Add list of inputs to the command line, so if inputs change | 645 # Add list of inputs to the command line, so if inputs change |
602 # (e.g. if a Java file is removed), the command will be re-run. | 646 # (e.g. if a Java file is removed), the command will be re-run. |
603 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | 647 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. |
604 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', | 648 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', |
605 ] | 649 ] |
606 }, | 650 }, |
607 { | |
608 'action_name': 'finalize_apk', | |
609 'message': 'Signing/aligning <(_target_name) APK.', | |
610 'inputs': [ | |
611 '<(DEPTH)/build/android/gyp/util/build_utils.py', | |
612 '<(DEPTH)/build/android/gyp/finalize_apk.py', | |
613 '<(unsigned_apk_path)', | |
614 ], | |
615 'outputs': [ | |
616 '<(final_apk_path)', | |
617 ], | |
618 'action': [ | |
619 'python', '<(DEPTH)/build/android/gyp/finalize_apk.py', | |
620 '--android-sdk-root=<(android_sdk_root)', | |
621 '--unsigned-apk-path=<(unsigned_apk_path)', | |
622 '--final-apk-path=<(final_apk_path)', | |
623 '--keystore-path=<(keystore_path)', | |
624 | |
625 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. | |
626 '--ignore=>!(echo \'>(_inputs)\' | md5sum)', | |
627 ], | |
628 }, | |
629 ], | 651 ], |
630 } | 652 } |
OLD | NEW |