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 24 matching lines...) Expand all Loading... |
35 help='Same as --assets, except disables compression.', | 35 help='Same as --assets, except disables compression.', |
36 default='[]') | 36 default='[]') |
37 parser.add_argument('--resource-apk', | 37 parser.add_argument('--resource-apk', |
38 help='An .ap_ file built using aapt', | 38 help='An .ap_ file built using aapt', |
39 required=True) | 39 required=True) |
40 parser.add_argument('--output-apk', | 40 parser.add_argument('--output-apk', |
41 help='Path to the output file', | 41 help='Path to the output file', |
42 required=True) | 42 required=True) |
43 parser.add_argument('--dex-file', | 43 parser.add_argument('--dex-file', |
44 help='Path to the classes.dex to use') | 44 help='Path to the classes.dex to use') |
45 # TODO(agrieve): Switch this to be a list of files rather than a directory. | 45 # TODO(agrieve): Pass all libs via --native-libs and remove --native-libs-dir. |
46 parser.add_argument('--native-libs-dir', | 46 parser.add_argument('--native-libs-dir', |
47 help='Directory containing native libraries to include', | 47 help='Directory containing native libraries to include', |
48 default=[]) | 48 default=[]) |
| 49 parser.add_argument('--native-libs', |
| 50 help='List of native libraries to include', |
| 51 default='[]') |
49 parser.add_argument('--android-abi', | 52 parser.add_argument('--android-abi', |
50 help='Android architecture to use for native libraries') | 53 help='Android architecture to use for native libraries') |
51 parser.add_argument('--native-lib-placeholders', | 54 parser.add_argument('--native-lib-placeholders', |
52 help='GYP-list of native library placeholders to add.', | 55 help='GYP-list of native library placeholders to add.', |
53 default='[]') | 56 default='[]') |
54 parser.add_argument('--emma-device-jar', | 57 parser.add_argument('--emma-device-jar', |
55 help='Path to emma_device.jar to include.') | 58 help='Path to emma_device.jar to include.') |
56 options = parser.parse_args(args) | 59 options = parser.parse_args(args) |
57 options.assets = build_utils.ParseGypList(options.assets) | 60 options.assets = build_utils.ParseGypList(options.assets) |
58 options.uncompressed_assets = build_utils.ParseGypList( | 61 options.uncompressed_assets = build_utils.ParseGypList( |
59 options.uncompressed_assets) | 62 options.uncompressed_assets) |
| 63 options.native_libs = build_utils.ParseGypList(options.native_libs) |
60 options.native_lib_placeholders = build_utils.ParseGypList( | 64 options.native_lib_placeholders = build_utils.ParseGypList( |
61 options.native_lib_placeholders) | 65 options.native_lib_placeholders) |
62 | 66 |
63 if not options.android_abi and (options.native_libs_dir or | 67 if not options.android_abi and (options.native_libs or |
| 68 options.native_libs_dir or |
64 options.native_lib_placeholders): | 69 options.native_lib_placeholders): |
65 raise Exception('Must specify --android-abi with --native-libs-dir') | 70 raise Exception('Must specify --android-abi when native libs exist.') |
66 return options | 71 return options |
67 | 72 |
68 | 73 |
69 def _ListSubPaths(path): | 74 def _ListSubPaths(path): |
70 """Returns a list of full paths to all files in the given path.""" | 75 """Returns a list of full paths to all files in the given path.""" |
71 return [os.path.join(path, name) for name in os.listdir(path)] | 76 return [os.path.join(path, name) for name in os.listdir(path)] |
72 | 77 |
73 | 78 |
74 def _SplitAssetPath(path): | 79 def _SplitAssetPath(path): |
75 """Returns (src, dest) given an asset path in the form src[:dest].""" | 80 """Returns (src, dest) given an asset path in the form src[:dest].""" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 apk_path) | 112 apk_path) |
108 except KeyError: | 113 except KeyError: |
109 build_utils.AddToZipHermetic(apk, apk_path, src_path=src_path, | 114 build_utils.AddToZipHermetic(apk, apk_path, src_path=src_path, |
110 compress=compress) | 115 compress=compress) |
111 | 116 |
112 | 117 |
113 def main(args): | 118 def main(args): |
114 args = build_utils.ExpandFileArgs(args) | 119 args = build_utils.ExpandFileArgs(args) |
115 options = _ParseArgs(args) | 120 options = _ParseArgs(args) |
116 | 121 |
117 native_libs = [] | 122 native_libs = options.native_libs |
118 if options.native_libs_dir: | 123 if options.native_libs_dir: |
119 native_libs = _ListSubPaths(options.native_libs_dir) | 124 native_libs += _ListSubPaths(options.native_libs_dir) |
120 | 125 |
121 input_paths = [options.resource_apk, __file__] + native_libs | 126 input_paths = [options.resource_apk, __file__] + native_libs |
122 if options.dex_file: | 127 if options.dex_file: |
123 input_paths.append(options.dex_file) | 128 input_paths.append(options.dex_file) |
124 | 129 |
125 if options.emma_device_jar: | 130 if options.emma_device_jar: |
126 input_paths.append(options.emma_device_jar) | 131 input_paths.append(options.emma_device_jar) |
127 | 132 |
128 input_strings = [options.android_abi, options.native_lib_placeholders] | 133 input_strings = [options.android_abi, options.native_lib_placeholders] |
129 | 134 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 build_utils.CallAndWriteDepfileIfStale( | 193 build_utils.CallAndWriteDepfileIfStale( |
189 on_stale_md5, | 194 on_stale_md5, |
190 options, | 195 options, |
191 input_paths=input_paths, | 196 input_paths=input_paths, |
192 input_strings=input_strings, | 197 input_strings=input_strings, |
193 output_paths=[options.output_apk]) | 198 output_paths=[options.output_apk]) |
194 | 199 |
195 | 200 |
196 if __name__ == '__main__': | 201 if __name__ == '__main__': |
197 main(sys.argv[1:]) | 202 main(sys.argv[1:]) |
OLD | NEW |