OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Adds the code parts to a resource APK.""" | 7 """Adds the code parts to a resource APK.""" |
8 | 8 |
9 import argparse | 9 import argparse |
10 import itertools | 10 import itertools |
(...skipping 27 matching lines...) Expand all Loading... |
38 help='Same as --assets, except disables compression.', | 38 help='Same as --assets, except disables compression.', |
39 default='[]') | 39 default='[]') |
40 parser.add_argument('--resource-apk', | 40 parser.add_argument('--resource-apk', |
41 help='An .ap_ file built using aapt', | 41 help='An .ap_ file built using aapt', |
42 required=True) | 42 required=True) |
43 parser.add_argument('--output-apk', | 43 parser.add_argument('--output-apk', |
44 help='Path to the output file', | 44 help='Path to the output file', |
45 required=True) | 45 required=True) |
46 parser.add_argument('--dex-file', | 46 parser.add_argument('--dex-file', |
47 help='Path to the classes.dex to use') | 47 help='Path to the classes.dex to use') |
48 # TODO(agrieve): Switch this to be a list of files rather than a directory. | 48 parser.add_argument('--native-libs', |
49 parser.add_argument('--native-libs-dir', | 49 action='append', |
50 help='Directory containing native libraries to include', | 50 help='GYP-list of native libraries to include. ' |
| 51 'Can be specified multiple times.', |
51 default=[]) | 52 default=[]) |
52 parser.add_argument('--android-abi', | 53 parser.add_argument('--android-abi', |
53 help='Android architecture to use for native libraries') | 54 help='Android architecture to use for native libraries') |
54 parser.add_argument('--native-lib-placeholders', | 55 parser.add_argument('--native-lib-placeholders', |
55 help='GYP-list of native library placeholders to add.', | 56 help='GYP-list of native library placeholders to add.', |
56 default='[]') | 57 default='[]') |
57 parser.add_argument('--emma-device-jar', | 58 parser.add_argument('--emma-device-jar', |
58 help='Path to emma_device.jar to include.') | 59 help='Path to emma_device.jar to include.') |
59 options = parser.parse_args(args) | 60 options = parser.parse_args(args) |
60 options.assets = build_utils.ParseGypList(options.assets) | 61 options.assets = build_utils.ParseGypList(options.assets) |
61 options.uncompressed_assets = build_utils.ParseGypList( | 62 options.uncompressed_assets = build_utils.ParseGypList( |
62 options.uncompressed_assets) | 63 options.uncompressed_assets) |
63 options.native_lib_placeholders = build_utils.ParseGypList( | 64 options.native_lib_placeholders = build_utils.ParseGypList( |
64 options.native_lib_placeholders) | 65 options.native_lib_placeholders) |
| 66 all_libs = [] |
| 67 for gyp_list in options.native_libs: |
| 68 all_libs.extend(build_utils.ParseGypList(gyp_list)) |
| 69 options.native_libs = all_libs |
65 | 70 |
66 if not options.android_abi and (options.native_libs_dir or | 71 if not options.android_abi and (options.native_libs or |
67 options.native_lib_placeholders): | 72 options.native_lib_placeholders): |
68 raise Exception('Must specify --android-abi with --native-libs-dir') | 73 raise Exception('Must specify --android-abi with --native-libs') |
69 return options | 74 return options |
70 | 75 |
71 | 76 |
72 def _ListSubPaths(path): | |
73 """Returns a list of full paths to all files in the given path.""" | |
74 return [os.path.join(path, name) for name in os.listdir(path)] | |
75 | |
76 | |
77 def _SplitAssetPath(path): | 77 def _SplitAssetPath(path): |
78 """Returns (src, dest) given an asset path in the form src[:dest].""" | 78 """Returns (src, dest) given an asset path in the form src[:dest].""" |
79 path_parts = path.split(':') | 79 path_parts = path.split(':') |
80 src_path = path_parts[0] | 80 src_path = path_parts[0] |
81 if len(path_parts) > 1: | 81 if len(path_parts) > 1: |
82 dest_path = path_parts[1] | 82 dest_path = path_parts[1] |
83 else: | 83 else: |
84 dest_path = os.path.basename(src_path) | 84 dest_path = os.path.basename(src_path) |
85 return src_path, dest_path | 85 return src_path, dest_path |
86 | 86 |
(...skipping 28 matching lines...) Expand all Loading... |
115 | 115 |
116 def _CreateAssetsList(paths): | 116 def _CreateAssetsList(paths): |
117 """Returns a newline-separated list of asset paths for the given paths.""" | 117 """Returns a newline-separated list of asset paths for the given paths.""" |
118 return '\n'.join(_SplitAssetPath(p)[1] for p in sorted(paths)) + '\n' | 118 return '\n'.join(_SplitAssetPath(p)[1] for p in sorted(paths)) + '\n' |
119 | 119 |
120 | 120 |
121 def main(args): | 121 def main(args): |
122 args = build_utils.ExpandFileArgs(args) | 122 args = build_utils.ExpandFileArgs(args) |
123 options = _ParseArgs(args) | 123 options = _ParseArgs(args) |
124 | 124 |
125 native_libs = [] | 125 native_libs = sorted(options.native_libs) |
126 if options.native_libs_dir: | |
127 native_libs = _ListSubPaths(options.native_libs_dir) | |
128 native_libs.sort() | |
129 | 126 |
130 input_paths = [options.resource_apk, __file__] + native_libs | 127 input_paths = [options.resource_apk, __file__] + native_libs |
131 if options.dex_file: | 128 if options.dex_file: |
132 input_paths.append(options.dex_file) | 129 input_paths.append(options.dex_file) |
133 | 130 |
134 if options.emma_device_jar: | 131 if options.emma_device_jar: |
135 input_paths.append(options.emma_device_jar) | 132 input_paths.append(options.emma_device_jar) |
136 | 133 |
137 input_strings = [options.android_abi, options.native_lib_placeholders] | 134 input_strings = [options.android_abi, options.native_lib_placeholders] |
138 | 135 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 build_utils.CallAndWriteDepfileIfStale( | 222 build_utils.CallAndWriteDepfileIfStale( |
226 on_stale_md5, | 223 on_stale_md5, |
227 options, | 224 options, |
228 input_paths=input_paths, | 225 input_paths=input_paths, |
229 input_strings=input_strings, | 226 input_strings=input_strings, |
230 output_paths=[options.output_apk]) | 227 output_paths=[options.output_apk]) |
231 | 228 |
232 | 229 |
233 if __name__ == '__main__': | 230 if __name__ == '__main__': |
234 main(sys.argv[1:]) | 231 main(sys.argv[1:]) |
OLD | NEW |