Chromium Code Reviews| 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 | 6 |
| 7 assert(is_android) | 7 assert(is_android) |
| 8 | 8 |
| 9 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) | 9 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) |
| 10 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) | 10 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) |
| 11 rebased_android_sdk_build_tools = | 11 rebased_android_sdk_build_tools = |
| 12 rebase_path(android_sdk_build_tools, root_build_dir) | 12 rebase_path(android_sdk_build_tools, root_build_dir) |
| 13 | 13 |
| 14 android_sdk_jar = "$android_sdk/android.jar" | 14 android_sdk_jar = "$android_sdk/android.jar" |
| 15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) | 15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) |
| 16 android_aapt_path = "$rebased_android_sdk_build_tools/aapt" | 16 android_aapt_path = "$rebased_android_sdk_build_tools/aapt" |
| 17 | 17 |
| 18 android_configuration_name = "Release" | |
| 19 if (is_debug) { | |
| 20 android_configuration_name = "Debug" | |
| 21 } | |
| 22 | |
| 18 template("android_lint") { | 23 template("android_lint") { |
| 19 set_sources_assignment_filter([]) | 24 set_sources_assignment_filter([]) |
| 20 if (defined(invoker.testonly)) { | 25 if (defined(invoker.testonly)) { |
| 21 testonly = invoker.testonly | 26 testonly = invoker.testonly |
| 22 } | 27 } |
| 23 | 28 |
| 24 jar_path = invoker.jar_path | 29 jar_path = invoker.jar_path |
| 25 android_manifest = invoker.android_manifest | 30 android_manifest = invoker.android_manifest |
| 26 java_files = invoker.java_files | 31 java_files = invoker.java_files |
| 27 base_path = "$target_gen_dir/$target_name" | 32 base_path = "$target_gen_dir/$target_name" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 if (defined(invoker.visibility)) { | 502 if (defined(invoker.visibility)) { |
| 498 visibility = invoker.visibility | 503 visibility = invoker.visibility |
| 499 } | 504 } |
| 500 public_deps = [ | 505 public_deps = [ |
| 501 ":${target_name}__jar_toc", | 506 ":${target_name}__jar_toc", |
| 502 ":$_output_jar_target", | 507 ":$_output_jar_target", |
| 503 ] | 508 ] |
| 504 } | 509 } |
| 505 } | 510 } |
| 506 | 511 |
| 512 # Creates an unsigned .apk | |
| 513 # | |
| 514 # Variables | |
| 515 # deps: Specifies the dependencies of this target. | |
| 516 # dex_path: Path to classes.dex file to include (optional). | |
| 517 # resource_packaged_apk_path: Path to .ap_ to use. | |
|
Dirk Pranke
2015/08/17 21:14:13
is `.ap_` a typo?
agrieve
2015/08/18 14:48:47
Awesomely, no. That's the actual extension chosen
| |
| 518 # output_apk_path: Output path for the generated .apk. | |
| 519 # native_libs_dir: Directory containing native libraries. | |
| 520 template("package_apk") { | |
| 521 action(target_name) { | |
| 522 if (defined(invoker.testonly)) { | |
| 523 testonly = invoker.testonly | |
| 524 } | |
| 525 script = "//build/android/gyp/ant.py" | |
| 526 _ant_script = "//build/android/ant/apk-package.xml" | |
| 527 | |
| 528 deps = invoker.deps | |
| 529 depfile = "$target_gen_dir/$target_name.d" | |
| 530 | |
| 531 inputs = [ | |
| 532 invoker.resource_packaged_apk_path, | |
| 533 _ant_script, | |
| 534 ] | |
| 535 if (defined(invoker.dex_path)) { | |
| 536 inputs += [ invoker.dex_path ] | |
| 537 } | |
|
Dirk Pranke
2015/08/17 21:14:13
you can (and should) use
forward_variables_f
agrieve
2015/08/18 14:48:47
Done.
| |
| 538 | |
| 539 outputs = [ | |
| 540 depfile, | |
| 541 invoker.output_apk_path, | |
| 542 ] | |
| 543 | |
| 544 _rebased_emma_jar = "" | |
| 545 _rebased_resource_packaged_apk_path = | |
| 546 rebase_path(invoker.resource_packaged_apk_path, root_build_dir) | |
| 547 _rebased_packaged_apk_path = | |
| 548 rebase_path(invoker.output_apk_path, root_build_dir) | |
| 549 _rebased_native_libs_dir = | |
| 550 rebase_path(invoker.native_libs_dir, root_build_dir) | |
| 551 args = [ | |
| 552 "--depfile", | |
| 553 rebase_path(depfile, root_build_dir), | |
| 554 "--", | |
| 555 "-quiet", | |
| 556 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root", | |
| 557 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools", | |
| 558 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path", | |
| 559 "-DCONFIGURATION_NAME=$android_configuration_name", | |
| 560 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir", | |
| 561 "-DOUT_DIR=", | |
| 562 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path", | |
| 563 "-DEMMA_INSTRUMENT=0", | |
| 564 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar", | |
| 565 "-Dbasedir=.", | |
| 566 "-buildfile", | |
| 567 rebase_path(_ant_script, root_build_dir), | |
| 568 ] | |
| 569 if (defined(invoker.dex_path)) { | |
| 570 _rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir) | |
| 571 args += [ | |
| 572 "-DDEX_FILE_PATH=$_rebased_dex_path", | |
| 573 "-DHAS_CODE=true", | |
| 574 ] | |
| 575 } else { | |
| 576 args += [ "-DHAS_CODE=false" ] | |
| 577 } | |
| 578 } | |
| 579 } | |
| 580 | |
| 507 template("finalize_apk") { | 581 template("finalize_apk") { |
| 508 action(target_name) { | 582 action(target_name) { |
| 509 script = "//build/android/gyp/finalize_apk.py" | 583 script = "//build/android/gyp/finalize_apk.py" |
| 510 depfile = "$target_gen_dir/$target_name.d" | 584 depfile = "$target_gen_dir/$target_name.d" |
| 511 | 585 |
| 512 if (defined(invoker.testonly)) { | 586 if (defined(invoker.testonly)) { |
| 513 testonly = invoker.testonly | 587 testonly = invoker.testonly |
| 514 } | 588 } |
| 515 | 589 |
| 516 sources = [ | 590 sources = [ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 # zipaligns the apk. | 640 # zipaligns the apk. |
| 567 template("create_apk") { | 641 template("create_apk") { |
| 568 set_sources_assignment_filter([]) | 642 set_sources_assignment_filter([]) |
| 569 if (defined(invoker.testonly)) { | 643 if (defined(invoker.testonly)) { |
| 570 testonly = invoker.testonly | 644 testonly = invoker.testonly |
| 571 } | 645 } |
| 572 | 646 |
| 573 _android_manifest = invoker.android_manifest | 647 _android_manifest = invoker.android_manifest |
| 574 _base_path = invoker.base_path | 648 _base_path = invoker.base_path |
| 575 _final_apk_path = invoker.apk_path | 649 _final_apk_path = invoker.apk_path |
| 650 _managed_final_apk_path_helper = | |
| 651 process_file_template([ _final_apk_path ], | |
| 652 "{{source_dir}}/{{source_name_part}}_managed.apk") | |
| 653 _managed_final_apk_path = _managed_final_apk_path_helper[0] | |
| 576 | 654 |
| 577 if (defined(invoker.resources_zip)) { | 655 if (defined(invoker.resources_zip)) { |
| 578 _resources_zip = invoker.resources_zip | 656 _resources_zip = invoker.resources_zip |
| 579 } | 657 } |
| 580 if (defined(invoker.dex_path)) { | 658 if (defined(invoker.dex_path)) { |
| 581 _dex_path = invoker.dex_path | 659 _dex_path = invoker.dex_path |
| 582 } | 660 } |
| 583 _load_library_from_apk = invoker.load_library_from_apk | 661 _load_library_from_apk = invoker.load_library_from_apk |
| 584 | 662 |
| 585 _package_deps = [] | 663 _package_deps = [] |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 596 _asset_location = invoker.asset_location | 674 _asset_location = invoker.asset_location |
| 597 } | 675 } |
| 598 | 676 |
| 599 _version_code = invoker.version_code | 677 _version_code = invoker.version_code |
| 600 _version_name = invoker.version_name | 678 _version_name = invoker.version_name |
| 601 | 679 |
| 602 _base_apk_path = _base_path + ".apk_intermediates" | 680 _base_apk_path = _base_path + ".apk_intermediates" |
| 603 | 681 |
| 604 _resource_packaged_apk_path = _base_apk_path + ".ap_" | 682 _resource_packaged_apk_path = _base_apk_path + ".ap_" |
| 605 _packaged_apk_path = _base_apk_path + ".unfinished.apk" | 683 _packaged_apk_path = _base_apk_path + ".unfinished.apk" |
| 684 _managed_packaged_apk_path = _base_apk_path + "_managed.unfinished.apk" | |
| 606 _shared_resources = | 685 _shared_resources = |
| 607 defined(invoker.shared_resources) && invoker.shared_resources | 686 defined(invoker.shared_resources) && invoker.shared_resources |
| 608 | 687 |
| 609 _configuration_name = "Release" | |
| 610 if (is_debug) { | |
| 611 _configuration_name = "Debug" | |
| 612 } | |
| 613 | |
| 614 _keystore_path = invoker.keystore_path | 688 _keystore_path = invoker.keystore_path |
| 615 _keystore_name = invoker.keystore_name | 689 _keystore_name = invoker.keystore_name |
| 616 _keystore_password = invoker.keystore_password | 690 _keystore_password = invoker.keystore_password |
| 617 | 691 |
| 618 _split_densities = [] | 692 _split_densities = [] |
| 619 if (defined(invoker.create_density_splits) && invoker.create_density_splits) { | 693 if (defined(invoker.create_density_splits) && invoker.create_density_splits) { |
| 620 _split_densities = [ | 694 _split_densities = [ |
| 621 "hdpi", | 695 "hdpi", |
| 622 "xhdpi", | 696 "xhdpi", |
| 623 "xxhdpi", | 697 "xxhdpi", |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 648 _resource_packaged_apk_path, | 722 _resource_packaged_apk_path, |
| 649 ] | 723 ] |
| 650 | 724 |
| 651 args = [ | 725 args = [ |
| 652 "--depfile", | 726 "--depfile", |
| 653 rebase_path(depfile, root_build_dir), | 727 rebase_path(depfile, root_build_dir), |
| 654 "--android-sdk", | 728 "--android-sdk", |
| 655 rebased_android_sdk, | 729 rebased_android_sdk, |
| 656 "--aapt-path", | 730 "--aapt-path", |
| 657 android_aapt_path, | 731 android_aapt_path, |
| 658 "--configuration-name=$_configuration_name", | 732 "--configuration-name=$android_configuration_name", |
| 659 "--android-manifest", | 733 "--android-manifest", |
| 660 rebase_path(_android_manifest, root_build_dir), | 734 rebase_path(_android_manifest, root_build_dir), |
| 661 "--version-code", | 735 "--version-code", |
| 662 _version_code, | 736 _version_code, |
| 663 "--version-name", | 737 "--version-name", |
| 664 _version_name, | 738 _version_name, |
| 665 "--apk-path", | 739 "--apk-path", |
| 666 rebase_path(_resource_packaged_apk_path, root_build_dir), | 740 rebase_path(_resource_packaged_apk_path, root_build_dir), |
| 667 ] | 741 ] |
| 668 | 742 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 695 } | 769 } |
| 696 if (defined(invoker.extensions_to_not_compress)) { | 770 if (defined(invoker.extensions_to_not_compress)) { |
| 697 args += [ | 771 args += [ |
| 698 "--no-compress", | 772 "--no-compress", |
| 699 invoker.extensions_to_not_compress, | 773 invoker.extensions_to_not_compress, |
| 700 ] | 774 ] |
| 701 } | 775 } |
| 702 } | 776 } |
| 703 | 777 |
| 704 package_target = "${target_name}__package" | 778 package_target = "${target_name}__package" |
| 705 action(package_target) { | 779 package_apk(package_target) { |
| 706 script = "//build/android/gyp/ant.py" | |
| 707 _ant_script = "//build/android/ant/apk-package.xml" | |
| 708 | |
| 709 deps = [ | 780 deps = [ |
| 710 ":${_package_resources_target_name}", | 781 ":${_package_resources_target_name}", |
| 711 ] | 782 ] |
| 712 if (defined(invoker.deps)) { | 783 if (defined(invoker.deps)) { |
| 713 deps += invoker.deps | 784 deps += invoker.deps |
| 714 } | 785 } |
| 715 depfile = "$target_gen_dir/$target_name.d" | 786 if (defined(_dex_path)) { |
| 787 dex_path = _dex_path | |
| 788 } | |
| 789 native_libs_dir = _native_libs_dir | |
| 790 output_apk_path = _packaged_apk_path | |
| 791 resource_packaged_apk_path = _resource_packaged_apk_path | |
| 792 } | |
| 716 | 793 |
| 717 inputs = [ | 794 _managed_package_target = "${target_name}_managed__package" |
| 718 _resource_packaged_apk_path, | 795 package_apk(_managed_package_target) { |
| 719 _ant_script, | 796 deps = [ |
| 797 ":${_package_resources_target_name}", | |
| 720 ] | 798 ] |
| 721 if (defined(_dex_path)) { | 799 if (defined(invoker.deps)) { |
| 722 inputs += [ _dex_path ] | 800 deps += invoker.deps |
|
Dirk Pranke
2015/08/17 21:14:13
same comment
agrieve
2015/08/18 14:48:47
Done.
| |
| 723 } | 801 } |
| 724 | 802 |
| 725 outputs = [ | 803 # TODO(agrieve): Multidex |
| 726 depfile, | 804 if (defined(_dex_path)) { |
| 727 _packaged_apk_path, | 805 dex_path = _dex_path |
| 728 ] | 806 } |
| 729 | 807 |
| 730 _rebased_emma_jar = "" | 808 # TODO(agrieve): Add a placeholder .so for http://crbug.com/384638 |
| 731 _rebased_resource_packaged_apk_path = | 809 native_libs_dir = "//build/android/empty/res" |
| 732 rebase_path(_resource_packaged_apk_path, root_build_dir) | 810 output_apk_path = _managed_packaged_apk_path |
| 733 _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir) | 811 resource_packaged_apk_path = _resource_packaged_apk_path |
| 734 _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir) | |
| 735 args = [ | |
| 736 "--depfile", | |
| 737 rebase_path(depfile, root_build_dir), | |
| 738 "--", | |
| 739 "-quiet", | |
| 740 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root", | |
| 741 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools", | |
| 742 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path", | |
| 743 "-DCONFIGURATION_NAME=$_configuration_name", | |
| 744 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir", | |
| 745 "-DOUT_DIR=", | |
| 746 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path", | |
| 747 "-DEMMA_INSTRUMENT=0", | |
| 748 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar", | |
| 749 "-Dbasedir=.", | |
| 750 "-buildfile", | |
| 751 rebase_path(_ant_script, root_build_dir), | |
| 752 ] | |
| 753 if (defined(_dex_path)) { | |
| 754 _rebased_dex_path = rebase_path(_dex_path, root_build_dir) | |
| 755 args += [ | |
| 756 "-DDEX_FILE_PATH=$_rebased_dex_path", | |
| 757 "-DHAS_CODE=true", | |
| 758 ] | |
| 759 } else { | |
| 760 args += [ "-DHAS_CODE=false" ] | |
| 761 } | |
| 762 } | 812 } |
| 763 | 813 |
| 764 _finalize_apk_rule_name = "${target_name}__finalize" | 814 _finalize_apk_rule_name = "${target_name}__finalize" |
| 765 finalize_apk(_finalize_apk_rule_name) { | 815 finalize_apk(_finalize_apk_rule_name) { |
| 766 input_apk_path = _packaged_apk_path | 816 input_apk_path = _packaged_apk_path |
| 767 output_apk_path = _final_apk_path | 817 output_apk_path = _final_apk_path |
| 768 keystore_path = _keystore_path | 818 keystore_path = _keystore_path |
| 769 keystore_name = _keystore_name | 819 keystore_name = _keystore_name |
| 770 keystore_password = _keystore_password | 820 keystore_password = _keystore_password |
| 771 rezip_apk = _load_library_from_apk | 821 rezip_apk = _load_library_from_apk |
| 772 | 822 |
| 773 public_deps = [ | 823 public_deps = [ |
| 774 # Generator of the _packaged_apk_path this target takes as input. | 824 # Generator of the _packaged_apk_path this target takes as input. |
| 775 ":$package_target", | 825 ":$package_target", |
| 776 ] | 826 ] |
| 777 } | 827 } |
| 778 | 828 |
| 779 _final_deps = [ ":${_finalize_apk_rule_name}" ] | 829 _managed_finalize_apk_rule_name = "${target_name}_managed__finalize" |
| 830 finalize_apk(_managed_finalize_apk_rule_name) { | |
| 831 input_apk_path = _managed_packaged_apk_path | |
| 832 output_apk_path = _managed_final_apk_path | |
| 833 keystore_path = _keystore_path | |
| 834 keystore_name = _keystore_name | |
| 835 keystore_password = _keystore_password | |
| 836 | |
| 837 public_deps = [ | |
| 838 ":$_managed_package_target", | |
| 839 ] | |
| 840 } | |
| 841 | |
| 842 _split_deps = [] | |
| 780 | 843 |
| 781 template("finalize_split") { | 844 template("finalize_split") { |
| 782 finalize_apk(target_name) { | 845 finalize_apk(target_name) { |
| 783 _config = invoker.split_config | 846 _config = invoker.split_config |
| 784 _type = invoker.split_type | 847 _type = invoker.split_type |
| 785 input_apk_path = "${_resource_packaged_apk_path}_${_config}" | 848 input_apk_path = "${_resource_packaged_apk_path}_${_config}" |
| 786 _output_paths = process_file_template( | 849 _output_paths = process_file_template( |
| 787 [ _final_apk_path ], | 850 [ _final_apk_path ], |
| 788 "{{source_dir}}/{{source_name_part}}-${_type}-${_config}.apk") | 851 "{{source_dir}}/{{source_name_part}}-${_type}-${_config}.apk") |
| 789 output_apk_path = _output_paths[0] | 852 output_apk_path = _output_paths[0] |
| 790 keystore_path = _keystore_path | 853 keystore_path = _keystore_path |
| 791 keystore_name = _keystore_name | 854 keystore_name = _keystore_name |
| 792 keystore_password = _keystore_password | 855 keystore_password = _keystore_password |
| 793 deps = [ | 856 deps = [ |
| 794 ":${_package_resources_target_name}", | 857 ":${_package_resources_target_name}", |
| 795 ] | 858 ] |
| 796 } | 859 } |
| 797 } | 860 } |
| 798 | 861 |
| 799 foreach(_split, _split_densities) { | 862 foreach(_split, _split_densities) { |
| 800 _split_rule = "${target_name}__finalize_${_split}_split" | 863 _split_rule = "${target_name}__finalize_${_split}_split" |
| 801 finalize_split(_split_rule) { | 864 finalize_split(_split_rule) { |
| 802 split_type = "density" | 865 split_type = "density" |
| 803 split_config = _split | 866 split_config = _split |
| 804 } | 867 } |
| 805 _final_deps += [ ":$_split_rule" ] | 868 _split_deps += [ ":$_split_rule" ] |
| 806 } | 869 } |
| 807 foreach(_split, _split_languages) { | 870 foreach(_split, _split_languages) { |
| 808 _split_rule = "${target_name}__finalize_${_split}_split" | 871 _split_rule = "${target_name}__finalize_${_split}_split" |
| 809 finalize_split(_split_rule) { | 872 finalize_split(_split_rule) { |
| 810 split_type = "lang" | 873 split_type = "lang" |
| 811 split_config = _split | 874 split_config = _split |
| 812 } | 875 } |
| 813 _final_deps += [ ":$_split_rule" ] | 876 _split_deps += [ ":$_split_rule" ] |
| 814 } | 877 } |
| 815 | 878 |
| 816 group(target_name) { | 879 group(target_name) { |
| 817 public_deps = _final_deps | 880 public_deps = [ ":${_finalize_apk_rule_name}" ] + _split_deps |
| 881 } | |
| 882 group("${target_name}_managed") { | |
| 883 public_deps = [ ":${_managed_finalize_apk_rule_name}" ] + _split_deps | |
| 818 } | 884 } |
| 819 } | 885 } |
| 820 | 886 |
| 821 template("java_prebuilt_impl") { | 887 template("java_prebuilt_impl") { |
| 822 set_sources_assignment_filter([]) | 888 set_sources_assignment_filter([]) |
| 823 if (defined(invoker.testonly)) { | 889 if (defined(invoker.testonly)) { |
| 824 testonly = invoker.testonly | 890 testonly = invoker.testonly |
| 825 } | 891 } |
| 826 _supports_android = | 892 _supports_android = |
| 827 defined(invoker.supports_android) && invoker.supports_android | 893 defined(invoker.supports_android) && invoker.supports_android |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1581 ] | 1647 ] |
| 1582 args = [ | 1648 args = [ |
| 1583 "--depfile", | 1649 "--depfile", |
| 1584 rebase_path(depfile, root_build_dir), | 1650 rebase_path(depfile, root_build_dir), |
| 1585 "--script-output-path", | 1651 "--script-output-path", |
| 1586 rebase_path(generated_script, root_build_dir), | 1652 rebase_path(generated_script, root_build_dir), |
| 1587 ] | 1653 ] |
| 1588 args += test_runner_args | 1654 args += test_runner_args |
| 1589 } | 1655 } |
| 1590 } | 1656 } |
| OLD | NEW |