summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authoragrieve <agrieve@chromium.org>2015-11-16 14:45:50 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-16 22:46:46 +0000
commit2b9cc87893cdf97eca6ed44224783cea84d469d3 (patch)
tree89bc607a22c03e9721465d8cfb0c0c31a5b2de69 /build
parent81c5309cfd874d6d8a4f1ef8134f80c89d8e4c98 (diff)
downloadchromium_src-2b9cc87893cdf97eca6ed44224783cea84d469d3.zip
chromium_src-2b9cc87893cdf97eca6ed44224783cea84d469d3.tar.gz
chromium_src-2b9cc87893cdf97eca6ed44224783cea84d469d3.tar.bz2
Port placeholders logic GYP->GN
BUG=535390,384638 Review URL: https://codereview.chromium.org/1438413004 Cr-Commit-Position: refs/heads/master@{#359944}
Diffstat (limited to 'build')
-rwxr-xr-xbuild/android/gyp/apkbuilder.py22
-rw-r--r--build/config/android/internal_rules.gni18
-rw-r--r--build/config/android/rules.gni8
3 files changed, 32 insertions, 16 deletions
diff --git a/build/android/gyp/apkbuilder.py b/build/android/gyp/apkbuilder.py
index c44173f..f668c08 100755
--- a/build/android/gyp/apkbuilder.py
+++ b/build/android/gyp/apkbuilder.py
@@ -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')
diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni
index 9895c46..29b2088 100644
--- a/build/config/android/internal_rules.gni
+++ b/build/config/android/internal_rules.gni
@@ -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
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index 090f557..6da7fe4 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -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" ]
}
}