Port placeholders logic GYP->GN
BUG=535390,384638 Review URL: https://codereview.chromium.org/1438413004 Cr-Original-Commit-Position: refs/heads/master@{#359944} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 2b9cc87893cdf97eca6ed44224783cea84d469d3
This commit is contained in:
Родитель
d2dc7e6f1f
Коммит
cdad0052d5
|
@ -48,16 +48,19 @@ def _ParseArgs(args):
|
|||
default=[])
|
||||
parser.add_argument('--android-abi',
|
||||
help='Android architecture to use for native libraries')
|
||||
parser.add_argument('--create-placeholder-lib',
|
||||
action='store_true',
|
||||
help='Whether to add a dummy library file')
|
||||
parser.add_argument('--native-lib-placeholders',
|
||||
help='GYP-list of native library placeholders to add.',
|
||||
default='[]')
|
||||
options = parser.parse_args(args)
|
||||
if not options.android_abi and (options.native_libs_dir or
|
||||
options.create_placeholder_lib):
|
||||
raise Exception('Must specify --android-abi with --native-libs-dir')
|
||||
options.assets = build_utils.ParseGypList(options.assets)
|
||||
options.uncompressed_assets = build_utils.ParseGypList(
|
||||
options.uncompressed_assets)
|
||||
options.native_lib_placeholders = build_utils.ParseGypList(
|
||||
options.native_lib_placeholders)
|
||||
|
||||
if not options.android_abi and (options.native_libs_dir or
|
||||
options.native_lib_placeholders):
|
||||
raise Exception('Must specify --android-abi with --native-libs-dir')
|
||||
return options
|
||||
|
||||
|
||||
|
@ -119,7 +122,7 @@ def main(args):
|
|||
if options.dex_file:
|
||||
input_paths.append(options.dex_file)
|
||||
|
||||
input_strings = [options.create_placeholder_lib, options.android_abi]
|
||||
input_strings = [options.android_abi, options.native_lib_placeholders]
|
||||
|
||||
for path in itertools.chain(options.assets, options.uncompressed_assets):
|
||||
src_path, dest_path = _SplitAssetPath(path)
|
||||
|
@ -141,10 +144,11 @@ def main(args):
|
|||
for path in native_libs:
|
||||
basename = os.path.basename(path)
|
||||
apk.write(path, 'lib/%s/%s' % (options.android_abi, basename))
|
||||
if options.create_placeholder_lib:
|
||||
for name in options.native_lib_placeholders:
|
||||
# Make it non-empty so that its checksum is non-zero and is not
|
||||
# ignored by md5_check.
|
||||
apk.writestr('lib/%s/libplaceholder.so' % options.android_abi, ':-)')
|
||||
apk.writestr('lib/%s/%s' % (options.android_abi, name), ':)',
|
||||
zipfile.ZIP_STORED)
|
||||
if options.dex_file:
|
||||
apk.write(options.dex_file, 'classes.dex')
|
||||
|
||||
|
|
|
@ -545,8 +545,9 @@ template("process_java_prebuilt") {
|
|||
# dex_path: Path to classes.dex file to include (optional).
|
||||
# resource_packaged_apk_path: Path to .ap_ to use.
|
||||
# output_apk_path: Output path for the generated .apk.
|
||||
# native_lib_placeholders: List of placeholder filenames to add to the apk
|
||||
# (optional).
|
||||
# native_libs_dir: Directory containing native libraries.
|
||||
# create_placeholder_lib: Whether to add a dummy lib to the apk.
|
||||
template("package_apk") {
|
||||
action(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
|
@ -555,8 +556,10 @@ template("package_apk") {
|
|||
"public_deps",
|
||||
"testonly",
|
||||
])
|
||||
_create_placeholder_lib = defined(invoker.create_placeholder_lib) &&
|
||||
invoker.create_placeholder_lib
|
||||
_native_lib_placeholders = []
|
||||
if (defined(invoker.native_lib_placeholders)) {
|
||||
_native_lib_placeholders = invoker.native_lib_placeholders
|
||||
}
|
||||
|
||||
script = "//build/android/gyp/apkbuilder.py"
|
||||
depfile = "$target_gen_dir/$target_name.d"
|
||||
|
@ -599,7 +602,7 @@ template("package_apk") {
|
|||
_rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir)
|
||||
args += [ "--dex-file=$_rebased_dex_path" ]
|
||||
}
|
||||
if (defined(invoker.native_libs_dir) || _create_placeholder_lib) {
|
||||
if (defined(invoker.native_libs_dir) || _native_lib_placeholders != []) {
|
||||
args += [ "--android-abi=$android_app_abi" ]
|
||||
}
|
||||
if (defined(invoker.native_libs_dir)) {
|
||||
|
@ -607,8 +610,8 @@ template("package_apk") {
|
|||
rebase_path(invoker.native_libs_dir, root_build_dir)
|
||||
args += [ "--native-libs-dir=$_rebased_native_libs_dir/$android_app_abi" ]
|
||||
}
|
||||
if (_create_placeholder_lib) {
|
||||
args += [ "--create-placeholder-lib" ]
|
||||
if (_native_lib_placeholders != []) {
|
||||
args += [ "--native-lib-placeholders=$_native_lib_placeholders" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -878,6 +881,7 @@ template("create_apk") {
|
|||
forward_variables_from(invoker,
|
||||
[
|
||||
"assets_build_config",
|
||||
"native_lib_placeholders",
|
||||
"native_libs_dir",
|
||||
])
|
||||
deps = _deps + [ ":${_package_resources_target_name}" ]
|
||||
|
@ -906,7 +910,7 @@ template("create_apk") {
|
|||
|
||||
# http://crbug.com/384638
|
||||
if (defined(invoker.native_libs_dir)) {
|
||||
create_placeholder_lib = true
|
||||
native_lib_placeholders = [ "libfix.crbug.384638.so" ]
|
||||
}
|
||||
|
||||
output_apk_path = _incremental_packaged_apk_path
|
||||
|
|
|
@ -1186,6 +1186,8 @@ template("android_java_prebuilt") {
|
|||
# native_libs: List paths of native libraries to include in this apk. If these
|
||||
# libraries depend on other shared_library targets, those dependencies will
|
||||
# also be included in the apk.
|
||||
# native_lib_placeholders: List of placeholder filenames to add to the apk
|
||||
# (optional).
|
||||
# apk_under_test: For an instrumentation test apk, this is the target of the
|
||||
# tested apk.
|
||||
# include_all_resources - If true include all resource IDs in all generated
|
||||
|
@ -1655,6 +1657,12 @@ template("android_apk") {
|
|||
|
||||
if (_native_libs != [] && !_create_abi_split) {
|
||||
native_libs_dir = _native_libs_dir
|
||||
|
||||
# Placeholders are not necessary for L+, so add them here, but don't
|
||||
# bother to create them in the case of splits.
|
||||
# http://crbug.com/395038
|
||||
forward_variables_from(invoker, [ "native_lib_placeholders" ])
|
||||
|
||||
deps += [ ":$_prepare_native_target_name" ]
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче