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. 4 5# This file is meant to be included into a target to provide a rule 6# to build Android APKs in a consistent manner. 7# 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# } 19# 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# java_strings_grd - The name of the grd file from which to generate localized 48# strings.xml files, if any. 49# library_manifest_paths'- Paths to additional AndroidManifest.xml files from 50# libraries. 51# use_content_linker - Enable the content dynamic linker that allows sharing the 52# RELRO section of the native libraries between the different processes. 53# enable_content_linker_tests - Enable the content dynamic linker test support 54# code. This allows a test APK to inject a Linker.TestRunner instance at 55# runtime. Should only be used by the content_linker_test_apk target!! 56# never_lint - Set to 1 to not run lint on this target. 57{ 58 'variables': { 59 'additional_input_paths': [], 60 'input_jars_paths': [], 61 'library_dexed_jars_paths': [], 62 'additional_src_dirs': [], 63 'generated_src_dirs': [], 64 'app_manifest_version_name%': '<(android_app_version_name)', 65 'app_manifest_version_code%': '<(android_app_version_code)', 66 'proguard_enabled%': 'false', 67 'proguard_flags_paths%': ['<(DEPTH)/build/android/empty_proguard.flags'], 68 'jar_name': 'chromium_apk_<(_target_name).jar', 69 'resource_dir%':'<(DEPTH)/build/android/ant/empty/res', 70 'R_package%':'', 71 'additional_R_text_files': [], 72 'additional_res_dirs': [], 73 'additional_res_packages': [], 74 'is_test_apk%': 0, 75 'java_strings_grd%': '', 76 'library_manifest_paths' : [], 77 'resource_input_paths': [], 78 'intermediate_dir': '<(PRODUCT_DIR)/<(_target_name)', 79 'asset_location%': '<(intermediate_dir)/assets', 80 'codegen_stamp': '<(intermediate_dir)/codegen.stamp', 81 'compile_input_paths': [], 82 'package_input_paths': [], 83 'ordered_libraries_file': '<(intermediate_dir)/native_libraries.json', 84 # TODO(cjhopman): build/ shouldn't refer to content/. The libraryloader and 85 # nativelibraries template should be moved out of content/ (to base/?). 86 # http://crbug.com/225101 87 'native_libraries_template': '<(DEPTH)/content/public/android/java/templates/NativeLibraries.template', 88 'native_libraries_java_dir': '<(intermediate_dir)/native_libraries_java/', 89 'native_libraries_java_file': '<(native_libraries_java_dir)/NativeLibraries.java', 90 'native_libraries_java_stamp': '<(intermediate_dir)/native_libraries_java.stamp', 91 'native_libraries_template_data_dir': '<(intermediate_dir)/native_libraries/', 92 'native_libraries_template_data_file': '<(native_libraries_template_data_dir)/native_libraries_array.h', 93 'native_libraries_template_version_file': '<(native_libraries_template_data_dir)/native_libraries_version.h', 94 'compile_stamp': '<(intermediate_dir)/compile.stamp', 95 'lint_stamp': '<(intermediate_dir)/lint.stamp', 96 'lint_result': '<(intermediate_dir)/lint_result.xml', 97 'lint_config': '<(intermediate_dir)/lint_config.xml', 98 'never_lint%': 0, 99 'instr_stamp': '<(intermediate_dir)/instr.stamp', 100 'jar_stamp': '<(intermediate_dir)/jar.stamp', 101 'obfuscate_stamp': '<(intermediate_dir)/obfuscate.stamp', 102 'strip_stamp': '<(intermediate_dir)/strip.stamp', 103 'classes_dir': '<(intermediate_dir)/classes', 104 'classes_final_dir': '<(intermediate_dir)/classes_instr', 105 'javac_includes': [], 106 'jar_excluded_classes': [], 107 'jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', 108 'obfuscated_jar_path': '<(intermediate_dir)/obfuscated.jar', 109 'dex_path': '<(intermediate_dir)/classes.dex', 110 'emma_device_jar': '<(android_sdk_root)/tools/lib/emma_device.jar', 111 'android_manifest_path%': '<(java_in_dir)/AndroidManifest.xml', 112 'push_stamp': '<(intermediate_dir)/push.stamp', 113 'link_stamp': '<(intermediate_dir)/link.stamp', 114 'package_resources_stamp': '<(intermediate_dir)/package_resources.stamp', 115 'codegen_input_paths': [], 116 'unsigned_apk_path': '<(intermediate_dir)/<(apk_name)-unsigned.apk', 117 'final_apk_path%': '<(PRODUCT_DIR)/apks/<(apk_name).apk', 118 'incomplete_apk_path': '<(intermediate_dir)/<(apk_name)-incomplete.apk', 119 'source_dir': '<(java_in_dir)/src', 120 'apk_install_record': '<(intermediate_dir)/apk_install.record.stamp', 121 'device_intermediate_dir': '/data/local/tmp/chromium/<(_target_name)/<(CONFIGURATION_NAME)', 122 'symlink_script_host_path': '<(intermediate_dir)/create_symlinks.sh', 123 'symlink_script_device_path': '<(device_intermediate_dir)/create_symlinks.sh', 124 'create_standalone_apk%': 1, 125 'variables': { 126 'variables': { 127 'native_lib_target%': '', 128 'native_lib_version_name%': '', 129 'use_content_linker%': 0, 130 'enable_content_linker_tests%': 0, 131 'is_test_apk%': 0, 132 }, 133 'conditions': [ 134 ['gyp_managed_install == 1 and native_lib_target != ""', { 135 'unsigned_standalone_apk_path': '<(intermediate_dir)/<(apk_name)-standalone-unsigned.apk', 136 }, { 137 'unsigned_standalone_apk_path': '<(unsigned_apk_path)', 138 }], 139 ['gyp_managed_install == 1', { 140 'apk_package_native_libs_dir': '<(intermediate_dir)/libs.managed', 141 }, { 142 'apk_package_native_libs_dir': '<(intermediate_dir)/libs', 143 }], 144 ['is_test_apk == 0 and emma_coverage != 0', { 145 'emma_instrument': 1, 146 },{ 147 'emma_instrument': 0, 148 }], 149 ], 150 }, 151 'native_lib_target%': '', 152 'native_lib_version_name%': '', 153 'use_content_linker%': 0, 154 'enable_content_linker_tests%': 0, 155 'emma_instrument': '<(emma_instrument)', 156 'apk_package_native_libs_dir': '<(apk_package_native_libs_dir)', 157 'unsigned_standalone_apk_path': '<(unsigned_standalone_apk_path)', 158 'extra_native_libs': [], 159 }, 160 # Pass the jar path to the apk's "fake" jar target. This would be better as 161 # direct_dependent_settings, but a variable set by a direct_dependent_settings 162 # cannot be lifted in a dependent to all_dependent_settings. 163 'all_dependent_settings': { 164 'variables': { 165 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', 166 }, 167 }, 168 'conditions': [ 169 ['resource_dir!=""', { 170 'variables': { 171 'resource_input_paths': [ '<!@(find <(resource_dir) -name "*")' ] 172 }, 173 }], 174 ['R_package != ""', { 175 'variables': { 176 # We generate R.java in package R_package (in addition to the package 177 # listed in the AndroidManifest.xml, which is unavoidable). 178 'additional_res_dirs': ['<(DEPTH)/build/android/ant/empty/res'], 179 'additional_res_packages': ['<(R_package)'], 180 'additional_R_text_files': ['<(PRODUCT_DIR)/<(package_name)/R.txt'], 181 }, 182 }], 183 ['native_lib_target != "" and component == "shared_library"', { 184 'dependencies': [ 185 '<(DEPTH)/build/android/setup.gyp:copy_system_libraries', 186 ], 187 }], 188 ['use_content_linker == 1', { 189 'dependencies': [ 190 '<(DEPTH)/content/content.gyp:content_android_linker', 191 ], 192 }], 193 ['native_lib_target != ""', { 194 'variables': { 195 'compile_input_paths': [ '<(native_libraries_java_stamp)' ], 196 'generated_src_dirs': [ '<(native_libraries_java_dir)' ], 197 'native_libs_paths': [ 198 '<(SHARED_LIB_DIR)/<(native_lib_target).>(android_product_extension)' 199 ], 200 'package_input_paths': [ 201 '<(apk_package_native_libs_dir)/<(android_app_abi)/gdbserver', 202 ], 203 }, 204 'copies': [ 205 { 206 # gdbserver is always copied into the APK's native libs dir. The ant 207 # build scripts (apkbuilder task) will only include it in a debug 208 # build. 209 'destination': '<(apk_package_native_libs_dir)/<(android_app_abi)', 210 'files': [ 211 '<(android_gdbserver)', 212 '<@(extra_native_libs)', 213 ], 214 }, 215 ], 216 'actions': [ 217 { 218 'variables': { 219 'conditions': [ 220 ['use_content_linker == 1', { 221 'variables': { 222 'linker_input_libraries': [ 223 '<(SHARED_LIB_DIR)/libcontent_android_linker.>(android_product_extension)', 224 ], 225 } 226 }, { 227 'variables': { 228 'linker_input_libraries': [], 229 }, 230 }], 231 ], 232 'input_libraries': [ 233 '<@(native_libs_paths)', 234 '<@(extra_native_libs)', 235 '<@(linker_input_libraries)', 236 ], 237 }, 238 'includes': ['../build/android/write_ordered_libraries.gypi'], 239 }, 240 { 241 'action_name': 'native_libraries_template_data_<(_target_name)', 242 'message': 'Creating native_libraries_list.h for <(_target_name)', 243 'inputs': [ 244 '<(DEPTH)/build/android/gyp/util/build_utils.py', 245 '<(DEPTH)/build/android/gyp/create_native_libraries_header.py', 246 '<(ordered_libraries_file)', 247 ], 248 'outputs': [ 249 '<(native_libraries_template_data_file)', 250 '<(native_libraries_template_version_file)', 251 ], 252 'action': [ 253 'python', '<(DEPTH)/build/android/gyp/create_native_libraries_header.py', 254 '--ordered-libraries=<(ordered_libraries_file)', 255 '--version-name=<(native_lib_version_name)', 256 '--native-library-list=<(native_libraries_template_data_file)', 257 '--version-output=<(native_libraries_template_version_file)', 258 ], 259 }, 260 { 261 'action_name': 'native_libraries_<(_target_name)', 262 'variables': { 263 'conditions': [ 264 ['use_content_linker == 1', { 265 'variables': { 266 'linker_gcc_preprocess_defines': [ 267 '--defines', 'ENABLE_CONTENT_LINKER', 268 ], 269 } 270 }, { 271 'variables': { 272 'linker_gcc_preprocess_defines': [], 273 }, 274 }], 275 ['enable_content_linker_tests == 1', { 276 'variables': { 277 'linker_tests_gcc_preprocess_defines': [ 278 '--defines', 'ENABLE_CONTENT_LINKER_TESTS', 279 ], 280 } 281 }, { 282 'variables': { 283 'linker_tests_gcc_preprocess_defines': [], 284 }, 285 }], 286 ], 287 'gcc_preprocess_defines': [ 288 '<@(linker_gcc_preprocess_defines)', 289 '<@(linker_tests_gcc_preprocess_defines)', 290 ], 291 }, 292 'message': 'Creating NativeLibraries.java for <(_target_name).', 293 'inputs': [ 294 '<(DEPTH)/build/android/gyp/util/build_utils.py', 295 '<(DEPTH)/build/android/gyp/gcc_preprocess.py', 296 '<(native_libraries_template_data_file)', 297 '<(native_libraries_template_version_file)', 298 '<(native_libraries_template)', 299 ], 300 'outputs': [ 301 '<(native_libraries_java_stamp)', 302 ], 303 'action': [ 304 'python', '<(DEPTH)/build/android/gyp/gcc_preprocess.py', 305 '--include-path=<(native_libraries_template_data_dir)', 306 '--output=<(native_libraries_java_file)', 307 '--template=<(native_libraries_template)', 308 '--stamp=<(native_libraries_java_stamp)', 309 '<@(gcc_preprocess_defines)', 310 ], 311 }, 312 { 313 'action_name': 'strip_native_libraries', 314 'variables': { 315 'ordered_libraries_file%': '<(ordered_libraries_file)', 316 'stripped_libraries_dir': '<(libraries_source_dir)', 317 'input_paths': [ 318 '<@(native_libs_paths)', 319 '<@(extra_native_libs)', 320 ], 321 'stamp': '<(strip_stamp)' 322 }, 323 'includes': ['../build/android/strip_native_libraries.gypi'], 324 }, 325 ], 326 'conditions': [ 327 ['gyp_managed_install == 1', { 328 'variables': { 329 'libraries_top_dir': '<(intermediate_dir)/lib.stripped', 330 'libraries_source_dir': '<(libraries_top_dir)/lib/<(android_app_abi)', 331 'device_library_dir': '<(device_intermediate_dir)/lib.stripped', 332 'configuration_name': '<(CONFIGURATION_NAME)', 333 }, 334 'dependencies': [ 335 '<(DEPTH)/build/android/setup.gyp:get_build_device_configurations', 336 ], 337 'actions': [ 338 { 339 'includes': ['../build/android/push_libraries.gypi'], 340 }, 341 { 342 'action_name': 'create device library symlinks', 343 'message': 'Creating links on device for <(_target_name).', 344 'inputs': [ 345 '<(DEPTH)/build/android/gyp/util/build_utils.py', 346 '<(DEPTH)/build/android/gyp/create_device_library_links.py', 347 '<(apk_install_record)', 348 '<(build_device_config_path)', 349 '<(ordered_libraries_file)', 350 ], 351 'outputs': [ 352 '<(link_stamp)' 353 ], 354 'action': [ 355 'python', '<(DEPTH)/build/android/gyp/create_device_library_links.py', 356 '--build-device-configuration=<(build_device_config_path)', 357 '--libraries-json=<(ordered_libraries_file)', 358 '--script-host-path=<(symlink_script_host_path)', 359 '--script-device-path=<(symlink_script_device_path)', 360 '--target-dir=<(device_library_dir)', 361 '--apk=<(incomplete_apk_path)', 362 '--stamp=<(link_stamp)', 363 '--configuration-name=<(CONFIGURATION_NAME)', 364 ], 365 }, 366 ], 367 'conditions': [ 368 ['create_standalone_apk == 1', { 369 'actions': [ 370 { 371 'action_name': 'create standalone APK', 372 'variables': { 373 'inputs': [ 374 '<(ordered_libraries_file)', 375 '<(strip_stamp)', 376 ], 377 'input_apk_path': '<(unsigned_apk_path)', 378 'output_apk_path': '<(unsigned_standalone_apk_path)', 379 'libraries_top_dir%': '<(libraries_top_dir)', 380 }, 381 'includes': [ 'android/create_standalone_apk_action.gypi' ], 382 }, 383 ], 384 }], 385 ], 386 }, { 387 # gyp_managed_install != 1 388 'variables': { 389 'libraries_source_dir': '<(apk_package_native_libs_dir)/<(android_app_abi)', 390 'package_input_paths': [ '<(strip_stamp)' ], 391 }, 392 }], 393 ], 394 }], # native_lib_target != '' 395 ['gyp_managed_install == 0 or create_standalone_apk == 1', { 396 'actions': [ 397 { 398 'action_name': 'finalize standalone apk', 399 'variables': { 400 'input_apk_path': '<(unsigned_standalone_apk_path)', 401 'output_apk_path': '<(final_apk_path)', 402 }, 403 'includes': [ 'android/finalize_apk_action.gypi'] 404 }, 405 ], 406 }], 407 ['java_strings_grd != ""', { 408 'variables': { 409 'res_grit_dir': '<(SHARED_INTERMEDIATE_DIR)/<(package_name)_apk/res_grit', 410 'additional_res_dirs': ['<(res_grit_dir)'], 411 # grit_grd_file is used by grit_action.gypi, included below. 412 'grit_grd_file': '<(java_in_dir)/strings/<(java_strings_grd)', 413 'resource_input_paths': [ 414 '<!@pymod_do_main(grit_info <@(grit_defines) --outputs "<(res_grit_dir)" <(grit_grd_file))' 415 ], 416 }, 417 'actions': [ 418 { 419 'action_name': 'generate_localized_strings_xml', 420 'variables': { 421 'grit_additional_defines': ['-E', 'ANDROID_JAVA_TAGGED_ONLY=false'], 422 'grit_out_dir': '<(res_grit_dir)', 423 # resource_ids is unneeded since we don't generate .h headers. 424 'grit_resource_ids': '', 425 }, 426 'includes': ['../build/grit_action.gypi'], 427 }, 428 ], 429 }], 430 ['gyp_managed_install == 1', { 431 'actions': [ 432 { 433 'action_name': 'finalize incomplete apk', 434 'variables': { 435 'input_apk_path': '<(unsigned_apk_path)', 436 'output_apk_path': '<(incomplete_apk_path)', 437 }, 438 'includes': [ 'android/finalize_apk_action.gypi'] 439 }, 440 { 441 'action_name': 'apk_install_<(_target_name)', 442 'message': 'Installing <(apk_name).apk', 443 'inputs': [ 444 '<(DEPTH)/build/android/gyp/util/build_utils.py', 445 '<(DEPTH)/build/android/gyp/apk_install.py', 446 '<(build_device_config_path)', 447 '<(incomplete_apk_path)', 448 ], 449 'outputs': [ 450 '<(apk_install_record)', 451 ], 452 'action': [ 453 'python', '<(DEPTH)/build/android/gyp/apk_install.py', 454 '--apk-path=<(incomplete_apk_path)', 455 '--build-device-configuration=<(build_device_config_path)', 456 '--install-record=<(apk_install_record)', 457 '--configuration-name=<(CONFIGURATION_NAME)', 458 ], 459 }, 460 ], 461 }], 462 ['is_test_apk == 1', { 463 'dependencies': [ 464 '<(DEPTH)/tools/android/android_tools.gyp:android_tools', 465 ] 466 }], 467 ], 468 'dependencies': [ 469 '<(DEPTH)/tools/android/md5sum/md5sum.gyp:md5sum', 470 ], 471 'actions': [ 472 { 473 'action_name': 'ant_codegen_<(_target_name)', 474 'message': 'Generating R.java for <(_target_name)', 475 'conditions': [ 476 ['is_test_apk == 1', { 477 'variables': { 478 'additional_res_dirs=': [], 479 'additional_res_packages=': [], 480 } 481 }], 482 ], 483 'inputs': [ 484 '<(DEPTH)/build/android/ant/apk-codegen.xml', 485 '<(DEPTH)/build/android/gyp/util/build_utils.py', 486 '<(DEPTH)/build/android/gyp/ant.py', 487 '<(android_manifest_path)', 488 '>@(additional_input_paths)', 489 '>@(codegen_input_paths)', 490 '>@(library_manifest_paths)', 491 '>@(resource_input_paths)', 492 ], 493 'outputs': [ 494 '<(codegen_stamp)', 495 ], 496 'action': [ 497 'python', '<(DEPTH)/build/android/gyp/ant.py', 498 '-quiet', 499 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', 500 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', 501 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)', 502 '-DANDROID_MANIFEST=<(android_manifest_path)', 503 '-DANDROID_SDK_JAR=<(android_sdk_jar)', 504 '-DANDROID_SDK_ROOT=<(android_sdk_root)', 505 '-DANDROID_SDK_VERSION=<(android_sdk_version)', 506 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', 507 '-DLIBRARY_MANIFEST_PATHS=>(library_manifest_paths)', 508 '-DOUT_DIR=<(intermediate_dir)', 509 '-DRESOURCE_DIR=<(resource_dir)', 510 511 '-DSTAMP=<(codegen_stamp)', 512 '-Dbasedir=.', 513 '-buildfile', 514 '<(DEPTH)/build/android/ant/apk-codegen.xml', 515 516 # Add list of inputs to the command line, so if inputs change 517 # (e.g. if a Java file is removed), the command will be re-run. 518 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. 519 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', 520 ], 521 }, 522 { 523 'action_name': 'javac_<(_target_name)', 524 'message': 'Compiling java for <(_target_name)', 525 'variables': { 526 'all_src_dirs': [ 527 '<(java_in_dir)/src', 528 '<(intermediate_dir)/gen', 529 '>@(additional_src_dirs)', 530 '>@(generated_src_dirs)', 531 ], 532 }, 533 'inputs': [ 534 '<(DEPTH)/build/android/gyp/util/build_utils.py', 535 '<(DEPTH)/build/android/gyp/javac.py', 536 # If there is a separate find for additional_src_dirs, it will find the 537 # wrong .java files when additional_src_dirs is empty. 538 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', 539 '>@(input_jars_paths)', 540 '<(codegen_stamp)', 541 '>@(compile_input_paths)', 542 ], 543 'outputs': [ 544 '<(compile_stamp)', 545 ], 546 'action': [ 547 'python', '<(DEPTH)/build/android/gyp/javac.py', 548 '--output-dir=<(classes_dir)', 549 '--classpath=>(input_jars_paths) <(android_sdk_jar)', 550 '--src-dirs=>(all_src_dirs)', 551 '--javac-includes=<(javac_includes)', 552 '--chromium-code=<(chromium_code)', 553 '--stamp=<(compile_stamp)', 554 555 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. 556 '--ignore=>!(echo \'>(_inputs)\' | md5sum)', 557 ], 558 }, 559 { 560 'variables': { 561 'src_dirs': [ 562 '<(java_in_dir)/src', 563 '>@(additional_src_dirs)', 564 ], 565 'stamp_path': '<(lint_stamp)', 566 'result_path': '<(lint_result)', 567 'config_path': '<(lint_config)', 568 }, 569 'inputs': [ 570 '<(compile_stamp)', 571 ], 572 'outputs': [ 573 '<(lint_stamp)', 574 ], 575 'includes': [ 'android/lint_action.gypi' ], 576 }, 577 { 578 'action_name': 'instr_classes_<(_target_name)', 579 'message': 'Instrumenting <(_target_name) classes', 580 'variables': { 581 'input_path': '<(classes_dir)', 582 'output_path': '<(classes_final_dir)', 583 'stamp_path': '<(instr_stamp)', 584 'instr_type': 'classes', 585 }, 586 'inputs': [ 587 '<(compile_stamp)', 588 ], 589 'outputs': [ 590 '<(instr_stamp)', 591 ], 592 'includes': [ 'android/instr_action.gypi' ], 593 }, 594 { 595 'action_name': 'jar_<(_target_name)', 596 'message': 'Creating <(_target_name) jar', 597 'inputs': [ 598 '<(instr_stamp)', 599 '<(DEPTH)/build/android/gyp/util/build_utils.py', 600 '<(DEPTH)/build/android/gyp/util/md5_check.py', 601 '<(DEPTH)/build/android/gyp/jar.py', 602 ], 603 'outputs': [ 604 '<(jar_stamp)', 605 ], 606 'action': [ 607 'python', '<(DEPTH)/build/android/gyp/jar.py', 608 '--classes-dir=<(classes_final_dir)', 609 '--jar-path=<(jar_path)', 610 '--excluded-classes=<(jar_excluded_classes)', 611 '--stamp=<(jar_stamp)', 612 613 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. 614 '--ignore=>!(echo \'>(_inputs)\' | md5sum)', 615 ] 616 }, 617 { 618 'action_name': 'ant_obfuscate_<(_target_name)', 619 'message': 'Obfuscating <(_target_name)', 620 'inputs': [ 621 '<(DEPTH)/build/android/ant/apk-obfuscate.xml', 622 '<(DEPTH)/build/android/ant/create-test-jar.js', 623 '<(DEPTH)/build/android/gyp/util/build_utils.py', 624 '<(DEPTH)/build/android/gyp/ant.py', 625 '<(instr_stamp)', 626 '>@(proguard_flags_paths)', 627 ], 628 'outputs': [ 629 '<(obfuscate_stamp)', 630 ], 631 'action': [ 632 'python', '<(DEPTH)/build/android/gyp/ant.py', 633 '-quiet', 634 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', 635 '-DANDROID_SDK_JAR=<(android_sdk_jar)', 636 '-DANDROID_SDK_ROOT=<(android_sdk_root)', 637 '-DANDROID_SDK_VERSION=<(android_sdk_version)', 638 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', 639 '-DAPK_NAME=<(apk_name)', 640 '-DCREATE_TEST_JAR_PATH=<(DEPTH)/build/android/ant/create-test-jar.js', 641 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', 642 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', 643 '-DINPUT_JARS_PATHS=>(input_jars_paths)', 644 '-DIS_TEST_APK=<(is_test_apk)', 645 '-DJAR_PATH=<(PRODUCT_DIR)/lib.java/<(jar_name)', 646 '-DOBFUSCATED_JAR_PATH=<(obfuscated_jar_path)', 647 '-DOUT_DIR=<(intermediate_dir)', 648 '-DPROGUARD_ENABLED=<(proguard_enabled)', 649 '-DPROGUARD_FLAGS=<(proguard_flags_paths)', 650 '-DTEST_JAR_PATH=<(PRODUCT_DIR)/test.lib.java/<(apk_name).jar', 651 652 '-DSTAMP=<(obfuscate_stamp)', 653 '-Dbasedir=.', 654 '-buildfile', 655 '<(DEPTH)/build/android/ant/apk-obfuscate.xml', 656 657 # Add list of inputs to the command line, so if inputs change 658 # (e.g. if a Java file is removed), the command will be re-run. 659 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. 660 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', 661 ], 662 }, 663 { 664 'action_name': 'dex_<(_target_name)', 665 'variables': { 666 'conditions': [ 667 ['proguard_enabled == "true"', { 668 'input_paths': [ '<(obfuscate_stamp)' ], 669 'proguard_enabled_input_path': '<(obfuscated_jar_path)', 670 }], 671 ['emma_instrument != 0', { 672 'dex_no_locals': 1, 673 }], 674 ['emma_instrument != 0 and is_test_apk == 0', { 675 'dex_input_paths': [ '<(emma_device_jar)' ], 676 }], 677 ], 678 'input_paths': [ '<(instr_stamp)' ], 679 'dex_input_paths': [ '>@(library_dexed_jars_paths)' ], 680 'dex_generated_input_dirs': [ '<(classes_final_dir)' ], 681 'output_path': '<(dex_path)', 682 }, 683 'includes': [ 'android/dex_action.gypi' ], 684 }, 685 { 686 'action_name': 'ant package resources', 687 'message': 'Packaging resources for <(_target_name) APK.', 688 'inputs': [ 689 '<(DEPTH)/build/android/ant/apk-package-resources.xml', 690 '<(DEPTH)/build/android/gyp/util/build_utils.py', 691 '<(DEPTH)/build/android/gyp/ant.py', 692 '<(android_manifest_path)', 693 '<(codegen_stamp)', 694 695 '>@(library_manifest_paths)', 696 '>@(additional_input_paths)', 697 ], 698 'conditions': [ 699 ['is_test_apk == 1', { 700 'variables': { 701 'additional_res_dirs=': [], 702 'additional_res_packages=': [], 703 } 704 }], 705 ], 706 'outputs': [ 707 '<(package_resources_stamp)', 708 ], 709 'action': [ 710 'python', '<(DEPTH)/build/android/gyp/ant.py', 711 '-quiet', 712 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', 713 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', 714 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)', 715 '-DANDROID_SDK_JAR=<(android_sdk_jar)', 716 '-DANDROID_SDK_ROOT=<(android_sdk_root)', 717 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', 718 '-DAPK_NAME=<(apk_name)', 719 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', 720 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', 721 '-DASSET_DIR=<(asset_location)', 722 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', 723 '-DOUT_DIR=<(intermediate_dir)', 724 '-DRESOURCE_DIR=<(resource_dir)', 725 726 '-DSTAMP=<(package_resources_stamp)', 727 728 '-Dbasedir=.', 729 '-buildfile', 730 '<(DEPTH)/build/android/ant/apk-package-resources.xml', 731 732 # Add list of inputs to the command line, so if inputs change 733 # (e.g. if a Java file is removed), the command will be re-run. 734 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. 735 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', 736 ] 737 }, 738 { 739 'action_name': 'ant_package_<(_target_name)', 740 'message': 'Packaging <(_target_name).', 741 'inputs': [ 742 '<(DEPTH)/build/android/ant/apk-package.xml', 743 '<(DEPTH)/build/android/gyp/util/build_utils.py', 744 '<(DEPTH)/build/android/gyp/ant.py', 745 '<(dex_path)', 746 '<(codegen_stamp)', 747 '<(obfuscate_stamp)', 748 '<(package_resources_stamp)', 749 '>@(package_input_paths)', 750 ], 751 'outputs': [ 752 '<(unsigned_apk_path)', 753 ], 754 'action': [ 755 'python', '<(DEPTH)/build/android/gyp/ant.py', 756 '-quiet', 757 '-DANDROID_SDK_ROOT=<(android_sdk_root)', 758 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', 759 '-DAPK_NAME=<(apk_name)', 760 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', 761 '-DNATIVE_LIBS_DIR=<(apk_package_native_libs_dir)', 762 '-DOUT_DIR=<(intermediate_dir)', 763 '-DSOURCE_DIR=<(source_dir)', 764 '-DUNSIGNED_APK_PATH=<(unsigned_apk_path)', 765 '-DEMMA_INSTRUMENT=<(emma_instrument)', 766 '-DEMMA_DEVICE_JAR=<(emma_device_jar)', 767 768 '-Dbasedir=.', 769 '-buildfile', 770 '<(DEPTH)/build/android/ant/apk-package.xml', 771 772 # Add list of inputs to the command line, so if inputs change 773 # (e.g. if a Java file is removed), the command will be re-run. 774 # TODO(newt): remove this once crbug.com/177552 is fixed in ninja. 775 '-DTHIS_IS_IGNORED=>!(echo \'>(_inputs)\' | md5sum)', 776 ] 777 }, 778 ], 779} 780