Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: build/config/android/rules.gni

Issue 654383002: GN: Enable loading libraries from apks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stack-debug
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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("//base/android/linker/config.gni")
5 import("//build/config/android/config.gni") 6 import("//build/config/android/config.gni")
6 import("//build/config/android/internal_rules.gni") 7 import("//build/config/android/internal_rules.gni")
7 import("//tools/grit/grit_rule.gni") 8 import("//tools/grit/grit_rule.gni")
8 9
9 assert(is_android) 10 assert(is_android)
10 11
11 12
12 # Declare a jni target 13 # Declare a jni target
13 # 14 #
14 # This target generates the native jni bindings for a set of .java files. 15 # This target generates the native jni bindings for a set of .java files.
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 620
620 if (defined(invoker.srcjar_deps)) { 621 if (defined(invoker.srcjar_deps)) {
621 srcjar_deps = invoker.srcjar_deps 622 srcjar_deps = invoker.srcjar_deps
622 } 623 }
623 if (defined(invoker.srcjars)) { 624 if (defined(invoker.srcjars)) {
624 srcjars = invoker.srcjars 625 srcjars = invoker.srcjars
625 } 626 }
626 } 627 }
627 } 628 }
628 629
630 template("java_library") {
rmcilroy 2014/10/21 21:21:03 I'm not sure how gn works, but this looks pretty s
cjhopman 2014/10/22 21:44:07 Yeah, it's similar. Almost all of the work is alre
631 if (defined(invoker.testonly)) { testonly = invoker.testonly }
632
633 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
634 || defined(invoker.srcjars))
635
636 _srcjar_deps = []
637 if (defined(invoker.srcjar_deps)) {
638 _srcjar_deps = invoker.srcjar_deps
639 }
640
641 _srcjars = []
642 if (defined(invoker.srcjars)) {
643 _srcjars = invoker.srcjars
644 }
645
646 _java_files = []
647 if (defined(invoker.java_files)) {
648 _java_files = invoker.java_files
649 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
650 _src_dir = invoker.DEPRECATED_java_in_dir + "/src"
651 _src_dir_exists = exec_script("//build/dir_exists.py",
652 [ rebase_path(_src_dir, root_build_dir) ],
653 "string")
654 assert(_src_dir_exists == "False",
655 "In GN, java_in_dir should be the fully specified java directory " +
656 "(i.e. including the trailing \"/src\")")
657
658 _java_files_build_rel = exec_script(
659 "//build/android/gyp/find.py",
660 [
661 "--pattern",
662 "*.java",
663 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir)
664 ],
665 "list lines"
666 )
667 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
668 }
669 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
670
671 # TODO(cjhopman): Write a proper build config so that java library
672 # dependencies work correctly.
673 _build_config = "$target_gen_dir/$target_name.build_config"
674 write_file(
675 _build_config,
676 "{ \"javac\": { \"classpath\": [], \"srcjars\": [] } }")
677
678 _jar_path = "$root_build_dir/lib.java/$target_name.jar"
679 if (defined(invoker.jar_path)) {
680 _jar_path = invoker.jar_path
681 }
682
683 compile_java(target_name) {
684 build_config = _build_config
685 jar_path = _jar_path
686 java_files = _java_files
687 srcjar_deps = _srcjar_deps
688 srcjars = _srcjars
689 }
690 }
691
629 692
630 # Declare an Android library target for a prebuilt jar 693 # Declare an Android library target for a prebuilt jar
631 # 694 #
632 # This target creates an Android library containing java code and Android 695 # This target creates an Android library containing java code and Android
633 # resources. 696 # resources.
634 # 697 #
635 # Variables 698 # Variables
636 # deps: Specifies the dependencies of this target. Java targets in this list 699 # deps: Specifies the dependencies of this target. Java targets in this list
637 # will be added to the javac classpath. Android resources in dependencies 700 # will be added to the javac classpath. Android resources in dependencies
638 # will be used when building this library. 701 # will be used when building this library.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } else if (defined(invoker.apk_name)) { 824 } else if (defined(invoker.apk_name)) {
762 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk" 825 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk"
763 } 826 }
764 _dist_jar_path_list = process_file_template( 827 _dist_jar_path_list = process_file_template(
765 [ _final_apk_path ], 828 [ _final_apk_path ],
766 "$root_build_dir/test.lib.java/{{source_name_part}}.jar" 829 "$root_build_dir/test.lib.java/{{source_name_part}}.jar"
767 ) 830 )
768 _dist_jar_path = _dist_jar_path_list[0] 831 _dist_jar_path = _dist_jar_path_list[0]
769 832
770 _native_libs = [] 833 _native_libs = []
771 if (defined(invoker.native_libs)) {
772 _use_chromium_linker = false
773 if (defined(invoker.use_chromium_linker)) {
774 _use_chromium_linker = invoker.use_chromium_linker
775 }
776
777 # TODO(GYP) add "|| profiling_full_stack_frames
778 # Only enable the chromium linker on regular builds, since the
779 # component build crashes on Android 4.4. See b/11379966
780 if (is_component_build || cpu_arch == "arm64" || cpu_arch == "x64") {
781 _use_chromium_linker = false
782 }
783
784 _native_libs = invoker.native_libs
785 _native_libs_dir = base_path + "/libs"
786
787 if (_use_chromium_linker) {
788 _native_libs += [
789 "$root_build_dir/lib.stripped/libchromium_android_linker.so"
790 ]
791 }
792 }
793 834
794 _keystore_path = android_default_keystore_path 835 _keystore_path = android_default_keystore_path
795 _keystore_name = android_default_keystore_name 836 _keystore_name = android_default_keystore_name
796 _keystore_password = android_default_keystore_password 837 _keystore_password = android_default_keystore_password
797 838
798 if (defined(invoker.keystore_path)) { 839 if (defined(invoker.keystore_path)) {
799 _keystore_path = invoker.keystore_path 840 _keystore_path = invoker.keystore_path
800 _keystore_name = invoker.keystore_name 841 _keystore_name = invoker.keystore_name
801 _keystore_password = invoker.keystore_password 842 _keystore_password = invoker.keystore_password
802 } 843 }
803 844
804 _srcjar_deps = [] 845 _srcjar_deps = []
805 if (defined(invoker.srcjar_deps)) { 846 if (defined(invoker.srcjar_deps)) {
806 _srcjar_deps += invoker.srcjar_deps 847 _srcjar_deps += invoker.srcjar_deps
807 } 848 }
808 849
850 _load_library_from_apk = false
851 if (defined(invoker.load_library_from_apk)) {
852 _load_library_from_apk = invoker.load_library_from_apk
853 }
854
855 if (defined(invoker.native_libs)) {
856 _use_chromium_linker = false
857 if (defined(invoker.use_chromium_linker)) {
858 _use_chromium_linker = (invoker.use_chromium_linker &&
859 chromium_linker_supported)
860 }
861
862 _native_libs = invoker.native_libs
863 _native_libs_dir = base_path + "/libs"
864
865 if (_use_chromium_linker) {
866 _native_libs += [
867 "$root_build_dir/lib.stripped/libchromium_android_linker.so"
868 ]
869 }
870 }
871
809 _rebased_build_config = rebase_path(build_config, root_build_dir) 872 _rebased_build_config = rebase_path(build_config, root_build_dir)
810 873
811 write_build_config("${_template_name}__build_config") { 874 write_build_config("${_template_name}__build_config") {
812 type = "android_apk" 875 type = "android_apk"
813 dex_path = final_dex_path 876 dex_path = final_dex_path
814 resources_zip = resources_zip_path 877 resources_zip = resources_zip_path
815 878
816 if (defined(invoker.deps)) { 879 if (defined(invoker.deps)) {
817 deps = invoker.deps 880 deps = invoker.deps
818 } 881 }
(...skipping 12 matching lines...) Expand all
831 generate_constant_ids = true 894 generate_constant_ids = true
832 } 895 }
833 _srcjar_deps += [":${_template_name}__process_resources"] 896 _srcjar_deps += [":${_template_name}__process_resources"]
834 897
835 if (_native_libs != []) { 898 if (_native_libs != []) {
836 _enable_chromium_linker_tests = false 899 _enable_chromium_linker_tests = false
837 if (defined(invoker.enable_chromium_linker_tests)) { 900 if (defined(invoker.enable_chromium_linker_tests)) {
838 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests 901 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
839 } 902 }
840 903
841 _load_library_from_apk = false
842 _native_lib_version_name = "" 904 _native_lib_version_name = ""
843 905
844 java_cpp_template("${_template_name}__native_libraries_java") { 906 java_cpp_template("${_template_name}__native_libraries_java") {
845 package_name = "org/chromium/base/library_loader" 907 package_name = "org/chromium/base/library_loader"
846 sources = [ 908 sources = [
847 "//base/android/java/templates/NativeLibraries.template", 909 "//base/android/java/templates/NativeLibraries.template",
848 ] 910 ]
849 inputs = [ 911 inputs = [
850 build_config, 912 build_config,
851 ] 913 ]
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 } 997 }
936 } 998 }
937 } 999 }
938 1000
939 final_deps += [":${_template_name}__create"] 1001 final_deps += [":${_template_name}__create"]
940 create_apk("${_template_name}__create") { 1002 create_apk("${_template_name}__create") {
941 apk_path = _final_apk_path 1003 apk_path = _final_apk_path
942 android_manifest = invoker.android_manifest 1004 android_manifest = invoker.android_manifest
943 resources_zip = all_resources_zip_path 1005 resources_zip = all_resources_zip_path
944 dex_path = final_dex_path 1006 dex_path = final_dex_path
1007 load_library_from_apk = _load_library_from_apk
945 1008
946 if (defined(invoker.asset_location)) { 1009 if (defined(invoker.asset_location)) {
947 asset_location = invoker.asset_location 1010 asset_location = invoker.asset_location
948 } 1011 }
949 1012
950 keystore_name = _keystore_name 1013 keystore_name = _keystore_name
951 keystore_path = _keystore_path 1014 keystore_path = _keystore_path
952 keystore_password = _keystore_password 1015 keystore_password = _keystore_password
953 1016
954 if (_native_libs != []) { 1017 if (_native_libs != []) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 } 1288 }
1226 1289
1227 # TODO(GYP): implement this. 1290 # TODO(GYP): implement this.
1228 template("uiautomator_test") { 1291 template("uiautomator_test") {
1229 if (defined(invoker.testonly)) { testonly = invoker.testonly } 1292 if (defined(invoker.testonly)) { testonly = invoker.testonly }
1230 assert(target_name != "") 1293 assert(target_name != "")
1231 assert(invoker.deps != [] || true) 1294 assert(invoker.deps != [] || true)
1232 group(target_name) { 1295 group(target_name) {
1233 } 1296 }
1234 } 1297 }
OLDNEW
« no previous file with comments | « build/config/android/internal_rules.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698