Chromium Code Reviews| Index: build/android/gyp/apkbuilder.py |
| diff --git a/build/android/gyp/apkbuilder.py b/build/android/gyp/apkbuilder.py |
| index 36619137bd5834e6f1e23d802e1a5ecfa35a5e34..a20de9e35e15bdd86867b15e59c9e7412b6475bc 100755 |
| --- a/build/android/gyp/apkbuilder.py |
| +++ b/build/android/gyp/apkbuilder.py |
| @@ -50,8 +50,16 @@ def _ParseArgs(args): |
| help='GYP-list of native libraries to include. ' |
| 'Can be specified multiple times.', |
| default=[]) |
| + parser.add_argument('--secondary-native-libs', |
| + action='append', |
| + help='The libraries for secondary android-abi. ' |
|
agrieve
2016/03/23 18:11:19
You should say that this is a GYP-list
michaelbai
2016/03/23 18:55:33
Done.
|
| + 'Can be specified multiple times.', |
| + default=[]) |
| parser.add_argument('--android-abi', |
| help='Android architecture to use for native libraries') |
| + parser.add_argument('--secondary-android-abi', |
| + help='The secondary Android architecture to use for' |
| + 'secondary native libraries') |
| parser.add_argument('--native-lib-placeholders', |
| help='GYP-list of native library placeholders to add.', |
| default='[]') |
| @@ -70,10 +78,18 @@ def _ParseArgs(args): |
| for gyp_list in options.native_libs: |
| all_libs.extend(build_utils.ParseGypList(gyp_list)) |
| options.native_libs = all_libs |
| + secondary_libs = [] |
| + for gyp_list in options.secondary_native_libs: |
| + secondary_libs.extend(build_utils.ParseGypList(gyp_list)) |
| + options.secondary_native_libs = secondary_libs |
| + |
| if not options.android_abi and (options.native_libs or |
| options.native_lib_placeholders): |
| raise Exception('Must specify --android-abi with --native-libs') |
| + if not options.secondary_android_abi and options.secondary_native_libs: |
| + raise Exception('Must specify --secondary-android-abi with' |
| + ' --secondary-native-libs') |
| return options |
| @@ -143,6 +159,22 @@ def _CreateAssetsList(path_tuples): |
| return '\n'.join(dests) + '\n' |
| +def _AddNativeLibraries(out_apk, native_libs, android_abi, uncompress): |
| + """Add native libraries to APK.""" |
| + for path in native_libs: |
| + basename = os.path.basename(path) |
| + apk_path = 'lib/%s/%s' % (android_abi, basename) |
| + |
| + compress = None |
| + if (uncompress and os.path.splitext(basename)[1] == '.so'): |
| + compress = False |
| + |
| + build_utils.AddToZipHermetic(out_apk, |
| + apk_path, |
| + src_path=path, |
| + compress=compress) |
| + |
| + |
| def main(args): |
| args = build_utils.ExpandFileArgs(args) |
| options = _ParseArgs(args) |
| @@ -150,6 +182,12 @@ def main(args): |
| native_libs = sorted(options.native_libs) |
| input_paths = [options.resource_apk, __file__] + native_libs |
| + |
| + secondary_native_libs = [] |
| + if options.secondary_native_libs: |
| + secondary_native_libs = sorted(options.secondary_native_libs) |
| + input_paths += secondary_native_libs |
| + |
| if options.dex_file: |
| input_paths.append(options.dex_file) |
| @@ -160,6 +198,9 @@ def main(args): |
| options.native_lib_placeholders, |
| options.uncompress_shared_libraries] |
| + if options.secondary_android_abi: |
| + input_strings.append(options.secondary_android_abi) |
| + |
| _assets = _ExpandPaths(options.assets) |
| _uncompressed_assets = _ExpandPaths(options.uncompressed_assets) |
| @@ -208,19 +249,16 @@ def main(args): |
| src_path=options.dex_file) |
| # 4. Native libraries. |
| - for path in native_libs: |
| - basename = os.path.basename(path) |
| - apk_path = 'lib/%s/%s' % (options.android_abi, basename) |
| - |
| - compress = None |
| - if (options.uncompress_shared_libraries and |
| - os.path.splitext(basename)[1] == '.so'): |
| - compress = False |
| - |
| - build_utils.AddToZipHermetic(out_apk, |
| - apk_path, |
| - src_path=path, |
| - compress=compress) |
| + _AddNativeLibraries(out_apk, |
| + native_libs, |
| + options.android_abi, |
| + options.uncompress_shared_libraries) |
| + |
| + if options.secondary_android_abi: |
| + _AddNativeLibraries(out_apk, |
| + secondary_native_libs, |
| + options.secondary_android_abi, |
| + options.uncompress_shared_libraries) |
| for name in sorted(options.native_lib_placeholders): |
| # Empty libs files are ignored by md5check, but rezip requires them |