GN: Enable loading libraries from apks
This enables all the bits for an apk that uses uncompressed native libraries that are loaded directly from the apk without being extracted on the device. BUG=359249 TBR=brettw NOTRY=true Review URL: https://codereview.chromium.org/654383002 Cr-Original-Commit-Position: refs/heads/master@{#300814} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 3151133068b2d1cfd44af0e8a546b640989aeb3d
This commit is contained in:
Родитель
848603da9e
Коммит
e6fc4f17db
|
@ -6,6 +6,7 @@
|
|||
{
|
||||
'targets': [
|
||||
{
|
||||
# GN: //build/android/rezip:rezip
|
||||
'target_name': 'rezip_apk_jar',
|
||||
'type': 'none',
|
||||
'variables': {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//build/config/android/rules.gni")
|
||||
|
||||
# GYP: //build/android/rezip.gyp:rezip_apk_jar
|
||||
java_library("rezip") {
|
||||
jar_path = "$root_build_dir/lib.java/rezip_apk.jar"
|
||||
DEPRECATED_java_in_dir = "."
|
||||
}
|
|
@ -236,6 +236,7 @@ template("create_apk") {
|
|||
_keystore_path = invoker.keystore_path
|
||||
_keystore_name = invoker.keystore_name
|
||||
_keystore_password = invoker.keystore_password
|
||||
_load_library_from_apk = invoker.load_library_from_apk
|
||||
|
||||
_deps = []
|
||||
if (defined(invoker.deps)) {
|
||||
|
@ -271,7 +272,7 @@ template("create_apk") {
|
|||
|
||||
script = "//build/android/gyp/package_resources.py"
|
||||
depfile = "${target_gen_dir}/${target_name}.d"
|
||||
source_prereqs = [
|
||||
inputs = [
|
||||
_android_manifest,
|
||||
_resources_zip,
|
||||
]
|
||||
|
@ -302,7 +303,7 @@ template("create_apk") {
|
|||
|
||||
depfile = "$target_gen_dir/$target_name.d"
|
||||
|
||||
source_prereqs = [
|
||||
inputs = [
|
||||
_dex_path,
|
||||
_resource_packaged_apk_path,
|
||||
_ant_script
|
||||
|
@ -344,7 +345,7 @@ template("create_apk") {
|
|||
depfile = "$target_gen_dir/$target_name.d"
|
||||
|
||||
sources = [_packaged_apk_path]
|
||||
source_prereqs = [_keystore_path]
|
||||
inputs = [_keystore_path]
|
||||
outputs = [depfile, _final_apk_path]
|
||||
|
||||
args = [
|
||||
|
@ -356,6 +357,16 @@ template("create_apk") {
|
|||
"--key-name", _keystore_name,
|
||||
"--key-passwd", _keystore_password,
|
||||
]
|
||||
if (_load_library_from_apk) {
|
||||
_rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar"
|
||||
inputs += [
|
||||
_rezip_jar_path
|
||||
]
|
||||
args += [
|
||||
"--load-library-from-zip-file=1",
|
||||
"--rezip-apk-jar-path", rebase_path(_rezip_jar_path, root_build_dir)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
group(target_name) {
|
||||
|
@ -446,7 +457,7 @@ template("java_prebuilt") {
|
|||
# dependencies srcjar outputs will be compiled and added to the output jar.
|
||||
# jar_path: Use this to explicitly set the output jar path. Defaults to
|
||||
# "${target_gen_dir}/${target_name}.jar.
|
||||
template("java_library") {
|
||||
template("compile_java") {
|
||||
if (defined(invoker.testonly)) { testonly = invoker.testonly }
|
||||
|
||||
assert(defined(invoker.java_files))
|
||||
|
@ -598,7 +609,7 @@ template("android_java_library") {
|
|||
_final_deps = []
|
||||
_final_datadeps = []
|
||||
|
||||
java_library("${target_name}__java_library") {
|
||||
compile_java("${target_name}__compile_java") {
|
||||
jar_path = _jar_path
|
||||
if (defined(invoker.jar_excluded_patterns)) {
|
||||
jar_excluded_patterns = invoker.jar_excluded_patterns
|
||||
|
@ -634,7 +645,7 @@ template("android_java_library") {
|
|||
|
||||
group(target_name) {
|
||||
deps = [
|
||||
":${target_name}__java_library",
|
||||
":${target_name}__compile_java",
|
||||
":${target_name}__dex",
|
||||
] + _final_deps + _final_datadeps
|
||||
}
|
||||
|
@ -672,7 +683,7 @@ template("process_resources") {
|
|||
)
|
||||
sources = rebase_path(sources_build_rel, ".", root_build_dir)
|
||||
|
||||
source_prereqs = [
|
||||
inputs = [
|
||||
build_config,
|
||||
android_manifest,
|
||||
]
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//base/android/linker/config.gni")
|
||||
import("//build/config/android/config.gni")
|
||||
import("//build/config/android/internal_rules.gni")
|
||||
import("//tools/grit/grit_rule.gni")
|
||||
|
@ -732,6 +733,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
|
||||
#
|
||||
|
@ -875,28 +938,6 @@ 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"
|
||||
|
||||
if (_use_chromium_linker) {
|
||||
_native_libs += [
|
||||
"$root_build_dir/lib.stripped/libchromium_android_linker.so"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
_keystore_path = android_default_keystore_path
|
||||
_keystore_name = android_default_keystore_name
|
||||
|
@ -913,6 +954,28 @@ template("android_apk") {
|
|||
_srcjar_deps += invoker.srcjar_deps
|
||||
}
|
||||
|
||||
_load_library_from_apk = false
|
||||
if (defined(invoker.load_library_from_apk)) {
|
||||
_load_library_from_apk = invoker.load_library_from_apk
|
||||
}
|
||||
|
||||
if (defined(invoker.native_libs)) {
|
||||
_use_chromium_linker = false
|
||||
if (defined(invoker.use_chromium_linker)) {
|
||||
_use_chromium_linker = (invoker.use_chromium_linker &&
|
||||
chromium_linker_supported)
|
||||
}
|
||||
|
||||
_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") {
|
||||
|
@ -945,7 +1008,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") {
|
||||
|
@ -1049,6 +1111,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
|
||||
|
|
Загрузка…
Ссылка в новой задаче