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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: build/config/android/rules.gni
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index af493bd9ff74a76276959e95a1ddc7feb13288fe..2bb432d4dc888710365a8c4254d65fb5facd5e52 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -626,6 +626,68 @@ template("android_library") {
}
}
+template("java_library") {
+ if (defined(invoker.testonly)) { testonly = invoker.testonly }
+
+ assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
+ || defined(invoker.srcjars))
+
+ _srcjar_deps = []
+ if (defined(invoker.srcjar_deps)) {
+ _srcjar_deps = invoker.srcjar_deps
+ }
+
+ _srcjars = []
+ if (defined(invoker.srcjars)) {
+ _srcjars = invoker.srcjars
+ }
+
+ _java_files = []
+ if (defined(invoker.java_files)) {
+ _java_files = invoker.java_files
+ } else if (defined(invoker.DEPRECATED_java_in_dir)) {
+ _src_dir = invoker.DEPRECATED_java_in_dir + "/src"
+ _src_dir_exists = exec_script("//build/dir_exists.py",
+ [ rebase_path(_src_dir, root_build_dir) ],
+ "string")
+ assert(_src_dir_exists == "False",
+ "In GN, java_in_dir should be the fully specified java directory " +
+ "(i.e. including the trailing \"/src\")")
+
+ _java_files_build_rel = exec_script(
+ "//build/android/gyp/find.py",
+ [
+ "--pattern",
+ "*.java",
+ rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir)
+ ],
+ "list lines"
+ )
+ _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
+ }
+ assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
+
+ # TODO(cjhopman): Write a proper build config so that java library
+ # dependencies work correctly.
+ _build_config = "$target_gen_dir/$target_name.build_config"
+ write_file(
+ _build_config,
+ "{ \"javac\": { \"classpath\": [], \"srcjars\": [] } }")
+
+ _jar_path = "$root_build_dir/lib.java/$target_name.jar"
+ if (defined(invoker.jar_path)) {
+ _jar_path = invoker.jar_path
+ }
+
+ compile_java(target_name) {
+ build_config = _build_config
+ jar_path = _jar_path
+ java_files = _java_files
+ srcjar_deps = _srcjar_deps
+ srcjars = _srcjars
+ }
+}
+
# Declare an Android library target for a prebuilt jar
#
@@ -768,27 +830,16 @@ template("android_apk") {
_dist_jar_path = _dist_jar_path_list[0]
_native_libs = []
- if (defined(invoker.native_libs)) {
- _use_chromium_linker = false
- if (defined(invoker.use_chromium_linker)) {
- _use_chromium_linker = invoker.use_chromium_linker
- }
- # TODO(GYP) add "|| profiling_full_stack_frames
- # Only enable the chromium linker on regular builds, since the
- # component build crashes on Android 4.4. See b/11379966
- if (is_component_build || cpu_arch == "arm64" || cpu_arch == "x64") {
- _use_chromium_linker = false
- }
-
- _native_libs = invoker.native_libs
- _native_libs_dir = base_path + "/libs"
+ _use_chromium_linker = false
+ if (defined(invoker.use_chromium_linker)) {
+ _use_chromium_linker = invoker.use_chromium_linker
+ }
+ assert(_use_chromium_linker || true)
rmcilroy 2014/10/21 10:55:45 I'm not sure what this is testing?
cjhopman 2014/10/21 17:28:52 Eh, this just marks _use_chromium_linker as "used"
- if (_use_chromium_linker) {
- _native_libs += [
- "$root_build_dir/lib.stripped/libchromium_android_linker.so"
- ]
- }
+ _load_library_from_apk = false
+ if (defined(invoker.load_library_from_apk)) {
+ _load_library_from_apk = invoker.load_library_from_apk
}
_keystore_path = android_default_keystore_path
@@ -806,6 +857,24 @@ template("android_apk") {
_srcjar_deps += invoker.srcjar_deps
}
+ if (defined(invoker.native_libs)) {
+ # TODO(GYP) add "|| profiling_full_stack_frames
+ # Only enable the chromium linker on regular builds, since the
+ # component build crashes on Android 4.4. See b/11379966
+ if (is_component_build || cpu_arch == "arm64" || cpu_arch == "x64") {
rmcilroy 2014/10/21 10:55:45 I realize you only moved this, but we still want _
cjhopman 2014/10/21 17:28:52 Done. It is not enabled in upstream targets for ar
rmcilroy 2014/10/21 21:21:03 You are right, I was thinking of downstream. Than
cjhopman 2014/10/22 21:44:07 In gyp we could do something similar... it would l
+ _use_chromium_linker = false
+ }
+
+ _native_libs = invoker.native_libs
+ _native_libs_dir = base_path + "/libs"
+
+ if (_use_chromium_linker) {
+ _native_libs += [
+ "$root_build_dir/lib.stripped/libchromium_android_linker.so"
+ ]
+ }
+ }
+
_rebased_build_config = rebase_path(build_config, root_build_dir)
write_build_config("${_template_name}__build_config") {
@@ -838,7 +907,6 @@ template("android_apk") {
_enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
}
- _load_library_from_apk = false
_native_lib_version_name = ""
java_cpp_template("${_template_name}__native_libraries_java") {
@@ -942,6 +1010,7 @@ template("android_apk") {
android_manifest = invoker.android_manifest
resources_zip = all_resources_zip_path
dex_path = final_dex_path
+ load_library_from_apk = _load_library_from_apk
if (defined(invoker.asset_location)) {
asset_location = invoker.asset_location

Powered by Google App Engine
This is Rietveld 408576698