| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
| 6 import("//build/config/zip.gni") | 6 import("//build/config/zip.gni") |
| 7 import("//third_party/ijar/ijar.gni") | 7 import("//third_party/ijar/ijar.gni") |
| 8 | 8 |
| 9 assert(is_android) | 9 assert(is_android) |
| 10 | 10 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 template("write_build_config") { | 235 template("write_build_config") { |
| 236 set_sources_assignment_filter([]) | 236 set_sources_assignment_filter([]) |
| 237 | 237 |
| 238 assert(defined(invoker.type)) | 238 assert(defined(invoker.type)) |
| 239 assert(defined(invoker.build_config)) | 239 assert(defined(invoker.build_config)) |
| 240 | 240 |
| 241 type = invoker.type | 241 type = invoker.type |
| 242 build_config = invoker.build_config | 242 build_config = invoker.build_config |
| 243 | 243 |
| 244 assert(type == "android_apk" || type == "java_library" || | 244 assert(type == "android_apk" || type == "java_library" || |
| 245 type == "android_resources" || type == "deps_dex") | 245 type == "android_resources" || type == "deps_dex" || |
| 246 type == "android_assets") |
| 246 | 247 |
| 247 action(target_name) { | 248 action(target_name) { |
| 248 deps = [] | 249 deps = [] |
| 249 forward_variables_from(invoker, | 250 forward_variables_from(invoker, |
| 250 [ | 251 [ |
| 251 "deps", | 252 "deps", |
| 252 "testonly", | 253 "testonly", |
| 253 "visibility", | 254 "visibility", |
| 254 ]) | 255 ]) |
| 255 | 256 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 276 type, | 277 type, |
| 277 "--depfile", | 278 "--depfile", |
| 278 rebase_path(depfile, root_build_dir), | 279 rebase_path(depfile, root_build_dir), |
| 279 "--possible-deps-configs=$rebase_possible_deps_configs", | 280 "--possible-deps-configs=$rebase_possible_deps_configs", |
| 280 "--build-config", | 281 "--build-config", |
| 281 rebase_path(build_config, root_build_dir), | 282 rebase_path(build_config, root_build_dir), |
| 282 ] | 283 ] |
| 283 | 284 |
| 284 is_java_library = type == "java_library" | 285 is_java_library = type == "java_library" |
| 285 is_apk = type == "android_apk" | 286 is_apk = type == "android_apk" |
| 287 is_android_assets = type == "android_assets" |
| 286 is_android_resources = type == "android_resources" | 288 is_android_resources = type == "android_resources" |
| 287 is_deps_dex = type == "deps_dex" | 289 is_deps_dex = type == "deps_dex" |
| 288 | 290 |
| 289 supports_android = is_apk || is_android_resources || is_deps_dex || | 291 supports_android = |
| 290 (is_java_library && defined(invoker.supports_android) && | 292 is_apk || is_android_assets || is_android_resources || is_deps_dex || |
| 291 invoker.supports_android) | 293 (is_java_library && defined(invoker.supports_android) && |
| 292 requires_android = is_apk || is_android_resources || is_deps_dex || | 294 invoker.supports_android) |
| 293 (is_java_library && defined(invoker.requires_android) && | 295 requires_android = |
| 294 invoker.requires_android) | 296 is_apk || is_android_assets || is_android_resources || is_deps_dex || |
| 297 (is_java_library && defined(invoker.requires_android) && |
| 298 invoker.requires_android) |
| 295 | 299 |
| 296 assert(!requires_android || supports_android, | 300 assert(!requires_android || supports_android, |
| 297 "requires_android requires" + " supports_android") | 301 "requires_android requires" + " supports_android") |
| 298 | 302 |
| 299 # Mark these variables as used. | 303 # Mark these variables as used. |
| 300 assert(is_java_library || true) | 304 assert(is_java_library || true) |
| 301 assert(is_apk || true) | 305 assert(is_apk || true) |
| 302 assert(is_android_resources || true) | 306 assert(is_android_resources || true) |
| 303 assert(is_deps_dex || true) | 307 assert(is_deps_dex || true) |
| 304 | 308 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 332 get_label_info(invoker.apk_under_test, "target_gen_dir") | 336 get_label_info(invoker.apk_under_test, "target_gen_dir") |
| 333 apk_under_test_name = get_label_info(invoker.apk_under_test, "name") | 337 apk_under_test_name = get_label_info(invoker.apk_under_test, "name") |
| 334 apk_under_test_config = | 338 apk_under_test_config = |
| 335 "$apk_under_test_gen_dir/$apk_under_test_name.build_config" | 339 "$apk_under_test_gen_dir/$apk_under_test_name.build_config" |
| 336 args += [ | 340 args += [ |
| 337 "--tested-apk-config", | 341 "--tested-apk-config", |
| 338 rebase_path(apk_under_test_config, root_build_dir), | 342 rebase_path(apk_under_test_config, root_build_dir), |
| 339 ] | 343 ] |
| 340 } | 344 } |
| 341 | 345 |
| 346 if (is_android_assets) { |
| 347 inputs += invoker.assets |
| 348 _rebased_assets = rebase_path(invoker.assets, root_build_dir) |
| 349 args += [ "--assets=$_rebased_assets" ] |
| 350 if (defined(invoker.asset_outputs)) { |
| 351 # These are zip paths, so no need to rebase. |
| 352 args += [ "--asset-outputs=${invoker.asset_outputs}" ] |
| 353 } |
| 354 if (defined(invoker.disable_compression) && invoker.disable_compression) { |
| 355 args += [ "--disable-asset-compression" ] |
| 356 } |
| 357 } |
| 358 |
| 342 if (is_android_resources || is_apk) { | 359 if (is_android_resources || is_apk) { |
| 343 assert(defined(invoker.resources_zip)) | 360 assert(defined(invoker.resources_zip)) |
| 344 args += [ | 361 args += [ |
| 345 "--resources-zip", | 362 "--resources-zip", |
| 346 rebase_path(invoker.resources_zip, root_build_dir), | 363 rebase_path(invoker.resources_zip, root_build_dir), |
| 347 ] | 364 ] |
| 348 if (defined(invoker.android_manifest)) { | 365 if (defined(invoker.android_manifest)) { |
| 349 inputs += [ invoker.android_manifest ] | 366 inputs += [ invoker.android_manifest ] |
| 350 args += [ | 367 args += [ |
| 351 "--android-manifest", | 368 "--android-manifest", |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 public_deps = [ | 490 public_deps = [ |
| 474 ":${target_name}__ijar", | 491 ":${target_name}__ijar", |
| 475 ":$_output_jar_target", | 492 ":$_output_jar_target", |
| 476 ] | 493 ] |
| 477 } | 494 } |
| 478 } | 495 } |
| 479 | 496 |
| 480 # Creates an unsigned .apk. | 497 # Creates an unsigned .apk. |
| 481 # | 498 # |
| 482 # Variables | 499 # Variables |
| 500 # assets_build_config: Path to android_apk .build_config containing merged |
| 501 # asset information. |
| 483 # deps: Specifies the dependencies of this target. | 502 # deps: Specifies the dependencies of this target. |
| 484 # dex_path: Path to classes.dex file to include (optional). | 503 # dex_path: Path to classes.dex file to include (optional). |
| 485 # resource_packaged_apk_path: Path to .ap_ to use. | 504 # resource_packaged_apk_path: Path to .ap_ to use. |
| 486 # output_apk_path: Output path for the generated .apk. | 505 # output_apk_path: Output path for the generated .apk. |
| 487 # native_libs_dir: Directory containing native libraries. | 506 # native_libs_dir: Directory containing native libraries. |
| 488 # create_placeholder_lib: Whether to add a dummy lib to the apk. | 507 # create_placeholder_lib: Whether to add a dummy lib to the apk. |
| 489 template("package_apk") { | 508 template("package_apk") { |
| 490 action(target_name) { | 509 action(target_name) { |
| 491 forward_variables_from(invoker, | 510 forward_variables_from(invoker, |
| 492 [ | 511 [ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 518 _rebased_resource_packaged_apk_path = | 537 _rebased_resource_packaged_apk_path = |
| 519 rebase_path(invoker.resource_packaged_apk_path, root_build_dir) | 538 rebase_path(invoker.resource_packaged_apk_path, root_build_dir) |
| 520 _rebased_packaged_apk_path = | 539 _rebased_packaged_apk_path = |
| 521 rebase_path(invoker.output_apk_path, root_build_dir) | 540 rebase_path(invoker.output_apk_path, root_build_dir) |
| 522 args = [ | 541 args = [ |
| 523 "--depfile", | 542 "--depfile", |
| 524 rebase_path(depfile, root_build_dir), | 543 rebase_path(depfile, root_build_dir), |
| 525 "--resource-apk=$_rebased_resource_packaged_apk_path", | 544 "--resource-apk=$_rebased_resource_packaged_apk_path", |
| 526 "--output-apk=$_rebased_packaged_apk_path", | 545 "--output-apk=$_rebased_packaged_apk_path", |
| 527 ] | 546 ] |
| 547 if (defined(invoker.assets_build_config)) { |
| 548 inputs += [ invoker.assets_build_config ] |
| 549 _rebased_build_config = |
| 550 rebase_path(invoker.assets_build_config, root_build_dir) |
| 551 args += [ |
| 552 "--assets=@FileArg($_rebased_build_config:assets)", |
| 553 "--uncompressed-assets=@FileArg($_rebased_build_config:uncompressed_asse
ts)", |
| 554 ] |
| 555 } |
| 528 if (defined(invoker.dex_path)) { | 556 if (defined(invoker.dex_path)) { |
| 529 _rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir) | 557 _rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir) |
| 530 args += [ "--dex-file=$_rebased_dex_path" ] | 558 args += [ "--dex-file=$_rebased_dex_path" ] |
| 531 } | 559 } |
| 532 if (defined(invoker.native_libs_dir) || _create_placeholder_lib) { | 560 if (defined(invoker.native_libs_dir) || _create_placeholder_lib) { |
| 533 args += [ "--android-abi=$android_app_abi" ] | 561 args += [ "--android-abi=$android_app_abi" ] |
| 534 } | 562 } |
| 535 if (defined(invoker.native_libs_dir)) { | 563 if (defined(invoker.native_libs_dir)) { |
| 536 _rebased_native_libs_dir = | 564 _rebased_native_libs_dir = |
| 537 rebase_path(invoker.native_libs_dir, root_build_dir) | 565 rebase_path(invoker.native_libs_dir, root_build_dir) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 657 |
| 630 _deps = [] | 658 _deps = [] |
| 631 if (defined(invoker.deps)) { | 659 if (defined(invoker.deps)) { |
| 632 _deps = invoker.deps | 660 _deps = invoker.deps |
| 633 } | 661 } |
| 634 _incremental_deps = [] | 662 _incremental_deps = [] |
| 635 if (defined(invoker.incremental_deps)) { | 663 if (defined(invoker.incremental_deps)) { |
| 636 _incremental_deps = invoker.incremental_deps | 664 _incremental_deps = invoker.incremental_deps |
| 637 } | 665 } |
| 638 | 666 |
| 667 # TODO(agrieve): Remove support for asset_location in favor of using |
| 668 # android_asset() everywhere (http://crbug.com/547162). |
| 639 if (defined(invoker.asset_location)) { | 669 if (defined(invoker.asset_location)) { |
| 640 _asset_location = invoker.asset_location | 670 _asset_location = invoker.asset_location |
| 641 assert(_asset_location != "") # Mark as used. | 671 assert(_asset_location != "") # Mark as used. |
| 642 } | 672 } |
| 643 | 673 |
| 644 _version_code = invoker.version_code | 674 _version_code = invoker.version_code |
| 645 _version_name = invoker.version_name | 675 _version_name = invoker.version_name |
| 646 assert(_version_code != -1) # Mark as used. | 676 assert(_version_code != -1) # Mark as used. |
| 647 assert(_version_name != "") # Mark as used. | 677 assert(_version_name != "") # Mark as used. |
| 648 | 678 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 package_resources_helper(_incremental_package_resources_target_name) { | 825 package_resources_helper(_incremental_package_resources_target_name) { |
| 796 forward_variables_from(invoker, [ "extensions_to_not_compress" ]) | 826 forward_variables_from(invoker, [ "extensions_to_not_compress" ]) |
| 797 deps = | 827 deps = |
| 798 _incremental_deps + [ ":$_generate_incremental_manifest_target_name" ] | 828 _incremental_deps + [ ":$_generate_incremental_manifest_target_name" ] |
| 799 android_manifest = _incremental_android_manifest | 829 android_manifest = _incremental_android_manifest |
| 800 resource_packaged_apk_path = _incremental_resource_packaged_apk_path | 830 resource_packaged_apk_path = _incremental_resource_packaged_apk_path |
| 801 } | 831 } |
| 802 | 832 |
| 803 package_target = "${target_name}__package" | 833 package_target = "${target_name}__package" |
| 804 package_apk(package_target) { | 834 package_apk(package_target) { |
| 805 forward_variables_from(invoker, [ "native_libs_dir" ]) | 835 forward_variables_from(invoker, |
| 836 [ |
| 837 "assets_build_config", |
| 838 "native_libs_dir", |
| 839 ]) |
| 806 deps = _deps + [ ":${_package_resources_target_name}" ] | 840 deps = _deps + [ ":${_package_resources_target_name}" ] |
| 807 | 841 |
| 808 if (defined(_dex_path)) { | 842 if (defined(_dex_path)) { |
| 809 dex_path = _dex_path | 843 dex_path = _dex_path |
| 810 } | 844 } |
| 811 | 845 |
| 812 output_apk_path = _packaged_apk_path | 846 output_apk_path = _packaged_apk_path |
| 813 resource_packaged_apk_path = _resource_packaged_apk_path | 847 resource_packaged_apk_path = _resource_packaged_apk_path |
| 814 } | 848 } |
| 815 | 849 |
| 816 _incremental_package_target = "${target_name}_incremental__package" | 850 _incremental_package_target = "${target_name}_incremental__package" |
| 817 package_apk(_incremental_package_target) { | 851 package_apk(_incremental_package_target) { |
| 852 forward_variables_from(invoker, [ "assets_build_config" ]) |
| 818 _dex_target = "//build/android/incremental_install:bootstrap_java__dex" | 853 _dex_target = "//build/android/incremental_install:bootstrap_java__dex" |
| 819 deps = _incremental_deps + [ | 854 deps = _incremental_deps + [ |
| 820 ":${_incremental_package_resources_target_name}", | 855 ":${_incremental_package_resources_target_name}", |
| 821 _dex_target, | 856 _dex_target, |
| 822 ] | 857 ] |
| 823 | 858 |
| 824 if (defined(_dex_path)) { | 859 if (defined(_dex_path)) { |
| 825 dex_path = | 860 dex_path = |
| 826 get_label_info(_dex_target, "target_gen_dir") + "/bootstrap.dex" | 861 get_label_info(_dex_target, "target_gen_dir") + "/bootstrap.dex" |
| 827 } | 862 } |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 ] | 1725 ] |
| 1691 args = [ | 1726 args = [ |
| 1692 "--depfile", | 1727 "--depfile", |
| 1693 rebase_path(depfile, root_build_dir), | 1728 rebase_path(depfile, root_build_dir), |
| 1694 "--script-output-path", | 1729 "--script-output-path", |
| 1695 rebase_path(generated_script, root_build_dir), | 1730 rebase_path(generated_script, root_build_dir), |
| 1696 ] | 1731 ] |
| 1697 args += test_runner_args | 1732 args += test_runner_args |
| 1698 } | 1733 } |
| 1699 } | 1734 } |
| OLD | NEW |