| 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 if (defined(invoker.asset_sources)) { |
| 348 inputs += invoker.asset_sources |
| 349 _rebased_asset_sources = |
| 350 rebase_path(invoker.asset_sources, root_build_dir) |
| 351 args += [ "--asset-sources=$_rebased_asset_sources" ] |
| 352 } |
| 353 if (defined(invoker.asset_renaming_sources)) { |
| 354 inputs += invoker.asset_renaming_sources |
| 355 _rebased_asset_renaming_sources = |
| 356 rebase_path(invoker.asset_renaming_sources, root_build_dir) |
| 357 args += [ "--asset-renaming-sources=$_rebased_asset_renaming_sources" ] |
| 358 |
| 359 # These are zip paths, so no need to rebase. |
| 360 args += [ "--asset-renaming-destinations=${invoker.asset_renaming_destin
ations}" ] |
| 361 } |
| 362 if (defined(invoker.disable_compression) && invoker.disable_compression) { |
| 363 args += [ "--disable-asset-compression" ] |
| 364 } |
| 365 } |
| 366 |
| 342 if (is_android_resources || is_apk) { | 367 if (is_android_resources || is_apk) { |
| 343 assert(defined(invoker.resources_zip)) | 368 assert(defined(invoker.resources_zip)) |
| 344 args += [ | 369 args += [ |
| 345 "--resources-zip", | 370 "--resources-zip", |
| 346 rebase_path(invoker.resources_zip, root_build_dir), | 371 rebase_path(invoker.resources_zip, root_build_dir), |
| 347 ] | 372 ] |
| 348 if (defined(invoker.android_manifest)) { | 373 if (defined(invoker.android_manifest)) { |
| 349 inputs += [ invoker.android_manifest ] | 374 inputs += [ invoker.android_manifest ] |
| 350 args += [ | 375 args += [ |
| 351 "--android-manifest", | 376 "--android-manifest", |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 public_deps = [ | 498 public_deps = [ |
| 474 ":${target_name}__ijar", | 499 ":${target_name}__ijar", |
| 475 ":$_output_jar_target", | 500 ":$_output_jar_target", |
| 476 ] | 501 ] |
| 477 } | 502 } |
| 478 } | 503 } |
| 479 | 504 |
| 480 # Creates an unsigned .apk. | 505 # Creates an unsigned .apk. |
| 481 # | 506 # |
| 482 # Variables | 507 # Variables |
| 508 # assets_build_config: Path to android_apk .build_config containing merged |
| 509 # asset information. |
| 483 # deps: Specifies the dependencies of this target. | 510 # deps: Specifies the dependencies of this target. |
| 484 # dex_path: Path to classes.dex file to include (optional). | 511 # dex_path: Path to classes.dex file to include (optional). |
| 485 # resource_packaged_apk_path: Path to .ap_ to use. | 512 # resource_packaged_apk_path: Path to .ap_ to use. |
| 486 # output_apk_path: Output path for the generated .apk. | 513 # output_apk_path: Output path for the generated .apk. |
| 487 # native_libs_dir: Directory containing native libraries. | 514 # native_libs_dir: Directory containing native libraries. |
| 488 # create_placeholder_lib: Whether to add a dummy lib to the apk. | 515 # create_placeholder_lib: Whether to add a dummy lib to the apk. |
| 489 template("package_apk") { | 516 template("package_apk") { |
| 490 action(target_name) { | 517 action(target_name) { |
| 491 forward_variables_from(invoker, | 518 forward_variables_from(invoker, |
| 492 [ | 519 [ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 518 _rebased_resource_packaged_apk_path = | 545 _rebased_resource_packaged_apk_path = |
| 519 rebase_path(invoker.resource_packaged_apk_path, root_build_dir) | 546 rebase_path(invoker.resource_packaged_apk_path, root_build_dir) |
| 520 _rebased_packaged_apk_path = | 547 _rebased_packaged_apk_path = |
| 521 rebase_path(invoker.output_apk_path, root_build_dir) | 548 rebase_path(invoker.output_apk_path, root_build_dir) |
| 522 args = [ | 549 args = [ |
| 523 "--depfile", | 550 "--depfile", |
| 524 rebase_path(depfile, root_build_dir), | 551 rebase_path(depfile, root_build_dir), |
| 525 "--resource-apk=$_rebased_resource_packaged_apk_path", | 552 "--resource-apk=$_rebased_resource_packaged_apk_path", |
| 526 "--output-apk=$_rebased_packaged_apk_path", | 553 "--output-apk=$_rebased_packaged_apk_path", |
| 527 ] | 554 ] |
| 555 if (defined(invoker.assets_build_config)) { |
| 556 inputs += [ invoker.assets_build_config ] |
| 557 _rebased_build_config = |
| 558 rebase_path(invoker.assets_build_config, root_build_dir) |
| 559 args += [ |
| 560 "--assets=@FileArg($_rebased_build_config:assets)", |
| 561 "--uncompressed-assets=@FileArg($_rebased_build_config:uncompressed_asse
ts)", |
| 562 ] |
| 563 } |
| 528 if (defined(invoker.dex_path)) { | 564 if (defined(invoker.dex_path)) { |
| 529 _rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir) | 565 _rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir) |
| 530 args += [ "--dex-file=$_rebased_dex_path" ] | 566 args += [ "--dex-file=$_rebased_dex_path" ] |
| 531 } | 567 } |
| 532 if (defined(invoker.native_libs_dir) || _create_placeholder_lib) { | 568 if (defined(invoker.native_libs_dir) || _create_placeholder_lib) { |
| 533 args += [ "--android-abi=$android_app_abi" ] | 569 args += [ "--android-abi=$android_app_abi" ] |
| 534 } | 570 } |
| 535 if (defined(invoker.native_libs_dir)) { | 571 if (defined(invoker.native_libs_dir)) { |
| 536 _rebased_native_libs_dir = | 572 _rebased_native_libs_dir = |
| 537 rebase_path(invoker.native_libs_dir, root_build_dir) | 573 rebase_path(invoker.native_libs_dir, root_build_dir) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 | 665 |
| 630 _deps = [] | 666 _deps = [] |
| 631 if (defined(invoker.deps)) { | 667 if (defined(invoker.deps)) { |
| 632 _deps = invoker.deps | 668 _deps = invoker.deps |
| 633 } | 669 } |
| 634 _incremental_deps = [] | 670 _incremental_deps = [] |
| 635 if (defined(invoker.incremental_deps)) { | 671 if (defined(invoker.incremental_deps)) { |
| 636 _incremental_deps = invoker.incremental_deps | 672 _incremental_deps = invoker.incremental_deps |
| 637 } | 673 } |
| 638 | 674 |
| 675 # TODO(agrieve): Remove support for asset_location in favor of using |
| 676 # android_assets() everywhere (http://crbug.com/547162). |
| 639 if (defined(invoker.asset_location)) { | 677 if (defined(invoker.asset_location)) { |
| 640 _asset_location = invoker.asset_location | 678 _asset_location = invoker.asset_location |
| 641 assert(_asset_location != "") # Mark as used. | 679 assert(_asset_location != "") # Mark as used. |
| 642 } | 680 } |
| 643 | 681 |
| 644 _version_code = invoker.version_code | 682 _version_code = invoker.version_code |
| 645 _version_name = invoker.version_name | 683 _version_name = invoker.version_name |
| 646 assert(_version_code != -1) # Mark as used. | 684 assert(_version_code != -1) # Mark as used. |
| 647 assert(_version_name != "") # Mark as used. | 685 assert(_version_name != "") # Mark as used. |
| 648 | 686 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 package_resources_helper(_incremental_package_resources_target_name) { | 833 package_resources_helper(_incremental_package_resources_target_name) { |
| 796 forward_variables_from(invoker, [ "extensions_to_not_compress" ]) | 834 forward_variables_from(invoker, [ "extensions_to_not_compress" ]) |
| 797 deps = | 835 deps = |
| 798 _incremental_deps + [ ":$_generate_incremental_manifest_target_name" ] | 836 _incremental_deps + [ ":$_generate_incremental_manifest_target_name" ] |
| 799 android_manifest = _incremental_android_manifest | 837 android_manifest = _incremental_android_manifest |
| 800 resource_packaged_apk_path = _incremental_resource_packaged_apk_path | 838 resource_packaged_apk_path = _incremental_resource_packaged_apk_path |
| 801 } | 839 } |
| 802 | 840 |
| 803 package_target = "${target_name}__package" | 841 package_target = "${target_name}__package" |
| 804 package_apk(package_target) { | 842 package_apk(package_target) { |
| 805 forward_variables_from(invoker, [ "native_libs_dir" ]) | 843 forward_variables_from(invoker, |
| 844 [ |
| 845 "assets_build_config", |
| 846 "native_libs_dir", |
| 847 ]) |
| 806 deps = _deps + [ ":${_package_resources_target_name}" ] | 848 deps = _deps + [ ":${_package_resources_target_name}" ] |
| 807 | 849 |
| 808 if (defined(_dex_path)) { | 850 if (defined(_dex_path)) { |
| 809 dex_path = _dex_path | 851 dex_path = _dex_path |
| 810 } | 852 } |
| 811 | 853 |
| 812 output_apk_path = _packaged_apk_path | 854 output_apk_path = _packaged_apk_path |
| 813 resource_packaged_apk_path = _resource_packaged_apk_path | 855 resource_packaged_apk_path = _resource_packaged_apk_path |
| 814 } | 856 } |
| 815 | 857 |
| 816 _incremental_package_target = "${target_name}_incremental__package" | 858 _incremental_package_target = "${target_name}_incremental__package" |
| 817 package_apk(_incremental_package_target) { | 859 package_apk(_incremental_package_target) { |
| 860 forward_variables_from(invoker, [ "assets_build_config" ]) |
| 818 _dex_target = "//build/android/incremental_install:bootstrap_java__dex" | 861 _dex_target = "//build/android/incremental_install:bootstrap_java__dex" |
| 819 deps = _incremental_deps + [ | 862 deps = _incremental_deps + [ |
| 820 ":${_incremental_package_resources_target_name}", | 863 ":${_incremental_package_resources_target_name}", |
| 821 _dex_target, | 864 _dex_target, |
| 822 ] | 865 ] |
| 823 | 866 |
| 824 if (defined(_dex_path)) { | 867 if (defined(_dex_path)) { |
| 825 dex_path = | 868 dex_path = |
| 826 get_label_info(_dex_target, "target_gen_dir") + "/bootstrap.dex" | 869 get_label_info(_dex_target, "target_gen_dir") + "/bootstrap.dex" |
| 827 } | 870 } |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 ] | 1733 ] |
| 1691 args = [ | 1734 args = [ |
| 1692 "--depfile", | 1735 "--depfile", |
| 1693 rebase_path(depfile, root_build_dir), | 1736 rebase_path(depfile, root_build_dir), |
| 1694 "--script-output-path", | 1737 "--script-output-path", |
| 1695 rebase_path(generated_script, root_build_dir), | 1738 rebase_path(generated_script, root_build_dir), |
| 1696 ] | 1739 ] |
| 1697 args += test_runner_args | 1740 args += test_runner_args |
| 1698 } | 1741 } |
| 1699 } | 1742 } |
| OLD | NEW |