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

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: rebase 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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 726
726 if (defined(invoker.srcjar_deps)) { 727 if (defined(invoker.srcjar_deps)) {
727 srcjar_deps = invoker.srcjar_deps 728 srcjar_deps = invoker.srcjar_deps
728 } 729 }
729 if (defined(invoker.srcjars)) { 730 if (defined(invoker.srcjars)) {
730 srcjars = invoker.srcjars 731 srcjars = invoker.srcjars
731 } 732 }
732 } 733 }
733 } 734 }
734 735
736 template("java_library") {
737 if (defined(invoker.testonly)) { testonly = invoker.testonly }
738
739 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
740 || defined(invoker.srcjars))
741
742 _srcjar_deps = []
743 if (defined(invoker.srcjar_deps)) {
744 _srcjar_deps = invoker.srcjar_deps
745 }
746
747 _srcjars = []
748 if (defined(invoker.srcjars)) {
749 _srcjars = invoker.srcjars
750 }
751
752 _java_files = []
753 if (defined(invoker.java_files)) {
754 _java_files = invoker.java_files
755 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
756 _src_dir = invoker.DEPRECATED_java_in_dir + "/src"
757 _src_dir_exists = exec_script("//build/dir_exists.py",
758 [ rebase_path(_src_dir, root_build_dir) ],
759 "string")
760 assert(_src_dir_exists == "False",
761 "In GN, java_in_dir should be the fully specified java directory " +
762 "(i.e. including the trailing \"/src\")")
763
764 _java_files_build_rel = exec_script(
765 "//build/android/gyp/find.py",
766 [
767 "--pattern",
768 "*.java",
769 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir)
770 ],
771 "list lines"
772 )
773 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
774 }
775 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
776
777 # TODO(cjhopman): Write a proper build config so that java library
778 # dependencies work correctly.
779 _build_config = "$target_gen_dir/$target_name.build_config"
780 write_file(
781 _build_config,
782 "{ \"javac\": { \"classpath\": [], \"srcjars\": [] } }")
783
784 _jar_path = "$root_build_dir/lib.java/$target_name.jar"
785 if (defined(invoker.jar_path)) {
786 _jar_path = invoker.jar_path
787 }
788
789 compile_java(target_name) {
790 build_config = _build_config
791 jar_path = _jar_path
792 java_files = _java_files
793 srcjar_deps = _srcjar_deps
794 srcjars = _srcjars
795 }
796 }
797
735 798
736 # Declare an Android library target for a prebuilt jar 799 # Declare an Android library target for a prebuilt jar
737 # 800 #
738 # This target creates an Android library containing java code and Android 801 # This target creates an Android library containing java code and Android
739 # resources. 802 # resources.
740 # 803 #
741 # Variables 804 # Variables
742 # deps: Specifies the dependencies of this target. Java targets in this list 805 # deps: Specifies the dependencies of this target. Java targets in this list
743 # will be added to the javac classpath. Android resources in dependencies 806 # will be added to the javac classpath. Android resources in dependencies
744 # will be used when building this library. 807 # will be used when building this library.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 } else if (defined(invoker.apk_name)) { 931 } else if (defined(invoker.apk_name)) {
869 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk" 932 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk"
870 } 933 }
871 _dist_jar_path_list = process_file_template( 934 _dist_jar_path_list = process_file_template(
872 [ _final_apk_path ], 935 [ _final_apk_path ],
873 "$root_build_dir/test.lib.java/{{source_name_part}}.jar" 936 "$root_build_dir/test.lib.java/{{source_name_part}}.jar"
874 ) 937 )
875 _dist_jar_path = _dist_jar_path_list[0] 938 _dist_jar_path = _dist_jar_path_list[0]
876 939
877 _native_libs = [] 940 _native_libs = []
878 if (defined(invoker.native_libs)) {
879 _use_chromium_linker = false
880 if (defined(invoker.use_chromium_linker)) {
881 _use_chromium_linker = invoker.use_chromium_linker
882 }
883
884 # TODO(GYP) add "|| profiling_full_stack_frames
885 # Only enable the chromium linker on regular builds, since the
886 # component build crashes on Android 4.4. See b/11379966
887 if (is_component_build || cpu_arch == "arm64" || cpu_arch == "x64") {
888 _use_chromium_linker = false
889 }
890
891 _native_libs = invoker.native_libs
892 _native_libs_dir = base_path + "/libs"
893
894 if (_use_chromium_linker) {
895 _native_libs += [
896 "$root_build_dir/lib.stripped/libchromium_android_linker.so"
897 ]
898 }
899 }
900 941
901 _keystore_path = android_default_keystore_path 942 _keystore_path = android_default_keystore_path
902 _keystore_name = android_default_keystore_name 943 _keystore_name = android_default_keystore_name
903 _keystore_password = android_default_keystore_password 944 _keystore_password = android_default_keystore_password
904 945
905 if (defined(invoker.keystore_path)) { 946 if (defined(invoker.keystore_path)) {
906 _keystore_path = invoker.keystore_path 947 _keystore_path = invoker.keystore_path
907 _keystore_name = invoker.keystore_name 948 _keystore_name = invoker.keystore_name
908 _keystore_password = invoker.keystore_password 949 _keystore_password = invoker.keystore_password
909 } 950 }
910 951
911 _srcjar_deps = [] 952 _srcjar_deps = []
912 if (defined(invoker.srcjar_deps)) { 953 if (defined(invoker.srcjar_deps)) {
913 _srcjar_deps += invoker.srcjar_deps 954 _srcjar_deps += invoker.srcjar_deps
914 } 955 }
915 956
957 _load_library_from_apk = false
958 if (defined(invoker.load_library_from_apk)) {
959 _load_library_from_apk = invoker.load_library_from_apk
960 }
961
962 if (defined(invoker.native_libs)) {
963 _use_chromium_linker = false
964 if (defined(invoker.use_chromium_linker)) {
965 _use_chromium_linker = (invoker.use_chromium_linker &&
966 chromium_linker_supported)
967 }
968
969 _native_libs = invoker.native_libs
970 _native_libs_dir = base_path + "/libs"
971
972 if (_use_chromium_linker) {
973 _native_libs += [
974 "$root_build_dir/lib.stripped/libchromium_android_linker.so"
975 ]
976 }
977 }
978
916 _rebased_build_config = rebase_path(build_config, root_build_dir) 979 _rebased_build_config = rebase_path(build_config, root_build_dir)
917 980
918 write_build_config("${_template_name}__build_config") { 981 write_build_config("${_template_name}__build_config") {
919 type = "android_apk" 982 type = "android_apk"
920 dex_path = final_dex_path 983 dex_path = final_dex_path
921 resources_zip = resources_zip_path 984 resources_zip = resources_zip_path
922 985
923 if (defined(invoker.deps)) { 986 if (defined(invoker.deps)) {
924 deps = invoker.deps 987 deps = invoker.deps
925 } 988 }
(...skipping 12 matching lines...) Expand all
938 generate_constant_ids = true 1001 generate_constant_ids = true
939 } 1002 }
940 _srcjar_deps += [":${_template_name}__process_resources"] 1003 _srcjar_deps += [":${_template_name}__process_resources"]
941 1004
942 if (_native_libs != []) { 1005 if (_native_libs != []) {
943 _enable_chromium_linker_tests = false 1006 _enable_chromium_linker_tests = false
944 if (defined(invoker.enable_chromium_linker_tests)) { 1007 if (defined(invoker.enable_chromium_linker_tests)) {
945 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests 1008 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
946 } 1009 }
947 1010
948 _load_library_from_apk = false
949 _native_lib_version_name = "" 1011 _native_lib_version_name = ""
950 1012
951 java_cpp_template("${_template_name}__native_libraries_java") { 1013 java_cpp_template("${_template_name}__native_libraries_java") {
952 package_name = "org/chromium/base/library_loader" 1014 package_name = "org/chromium/base/library_loader"
953 sources = [ 1015 sources = [
954 "//base/android/java/templates/NativeLibraries.template", 1016 "//base/android/java/templates/NativeLibraries.template",
955 ] 1017 ]
956 inputs = [ 1018 inputs = [
957 build_config, 1019 build_config,
958 ] 1020 ]
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 } 1104 }
1043 } 1105 }
1044 } 1106 }
1045 1107
1046 final_deps += [":${_template_name}__create"] 1108 final_deps += [":${_template_name}__create"]
1047 create_apk("${_template_name}__create") { 1109 create_apk("${_template_name}__create") {
1048 apk_path = _final_apk_path 1110 apk_path = _final_apk_path
1049 android_manifest = invoker.android_manifest 1111 android_manifest = invoker.android_manifest
1050 resources_zip = all_resources_zip_path 1112 resources_zip = all_resources_zip_path
1051 dex_path = final_dex_path 1113 dex_path = final_dex_path
1114 load_library_from_apk = _load_library_from_apk
1052 1115
1053 if (defined(invoker.asset_location)) { 1116 if (defined(invoker.asset_location)) {
1054 asset_location = invoker.asset_location 1117 asset_location = invoker.asset_location
1055 } 1118 }
1056 1119
1057 keystore_name = _keystore_name 1120 keystore_name = _keystore_name
1058 keystore_path = _keystore_path 1121 keystore_path = _keystore_path
1059 keystore_password = _keystore_password 1122 keystore_password = _keystore_password
1060 1123
1061 if (_native_libs != []) { 1124 if (_native_libs != []) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 } 1395 }
1333 1396
1334 # TODO(GYP): implement this. 1397 # TODO(GYP): implement this.
1335 template("uiautomator_test") { 1398 template("uiautomator_test") {
1336 if (defined(invoker.testonly)) { testonly = invoker.testonly } 1399 if (defined(invoker.testonly)) { testonly = invoker.testonly }
1337 assert(target_name != "") 1400 assert(target_name != "")
1338 assert(invoker.deps != [] || true) 1401 assert(invoker.deps != [] || true)
1339 group(target_name) { 1402 group(target_name) {
1340 } 1403 }
1341 } 1404 }
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