Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: build/android/incremental_install/installer.py

Issue 1471393002: GN Incremental Install: Don't use proguarded dex when is_debug = false (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add warning Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2015 The Chromium Authors. All rights reserved. 3 # Copyright 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 """Install *_incremental.apk targets as well as their dependent files.""" 7 """Install *_incremental.apk targets as well as their dependent files."""
8 8
9 import argparse 9 import argparse
10 import glob 10 import glob
(...skipping 14 matching lines...) Expand all
25 from pylib.utils import time_profile 25 from pylib.utils import time_profile
26 26
27 prev_sys_path = list(sys.path) 27 prev_sys_path = list(sys.path)
28 sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, 'gyp')) 28 sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, 'gyp'))
29 from util import build_utils 29 from util import build_utils
30 sys.path = prev_sys_path 30 sys.path = prev_sys_path
31 31
32 32
33 def _TransformDexPaths(paths): 33 def _TransformDexPaths(paths):
34 """Given paths like ["/a/b/c", "/a/c/d"], returns ["b.c", "c.d"].""" 34 """Given paths like ["/a/b/c", "/a/c/d"], returns ["b.c", "c.d"]."""
35 if len(paths) == 1:
36 return [os.path.basename(paths[0])]
37
35 prefix_len = len(os.path.commonprefix(paths)) 38 prefix_len = len(os.path.commonprefix(paths))
36 return [p[prefix_len:].replace(os.sep, '.') for p in paths] 39 return [p[prefix_len:].replace(os.sep, '.') for p in paths]
37 40
38 41
39 def _Execute(concurrently, *funcs): 42 def _Execute(concurrently, *funcs):
40 """Calls all functions in |funcs| concurrently or in sequence.""" 43 """Calls all functions in |funcs| concurrently or in sequence."""
41 timer = time_profile.TimeProfile() 44 timer = time_profile.TimeProfile()
42 if concurrently: 45 if concurrently:
43 reraiser_thread.RunAsync(funcs) 46 reraiser_thread.RunAsync(funcs)
44 else: 47 else:
(...skipping 11 matching lines...) Expand all
56 def Uninstall(device, package): 59 def Uninstall(device, package):
57 """Uninstalls and removes all incremental files for the given package.""" 60 """Uninstalls and removes all incremental files for the given package."""
58 main_timer = time_profile.TimeProfile() 61 main_timer = time_profile.TimeProfile()
59 device.Uninstall(package) 62 device.Uninstall(package)
60 device.RunShellCommand(['rm', '-rf', _GetDeviceIncrementalDir(package)], 63 device.RunShellCommand(['rm', '-rf', _GetDeviceIncrementalDir(package)],
61 check_return=True) 64 check_return=True)
62 logging.info('Uninstall took %s seconds.', main_timer.GetDelta()) 65 logging.info('Uninstall took %s seconds.', main_timer.GetDelta())
63 66
64 67
65 def Install(device, apk, split_globs=None, lib_dir=None, dex_files=None, 68 def Install(device, apk, split_globs=None, lib_dir=None, dex_files=None,
66 enable_device_cache=True, use_concurrency=True): 69 enable_device_cache=True, use_concurrency=True,
70 show_proguard_warning=False):
67 """Installs the given incremental apk and all required supporting files. 71 """Installs the given incremental apk and all required supporting files.
68 72
69 Args: 73 Args:
70 device: A DeviceUtils instance. 74 device: A DeviceUtils instance.
71 apk: The path to the apk, or an ApkHelper instance. 75 apk: The path to the apk, or an ApkHelper instance.
72 split_globs: Glob patterns for any required apk splits (optional). 76 split_globs: Glob patterns for any required apk splits (optional).
73 lib_dir: Directory containing the app's native libraries (optional). 77 lib_dir: Directory containing the app's native libraries (optional).
74 dex_files: List of .dex.jar files that comprise the app's Dalvik code. 78 dex_files: List of .dex.jar files that comprise the app's Dalvik code.
75 enable_device_cache: Whether to enable on-device caching of checksums. 79 enable_device_cache: Whether to enable on-device caching of checksums.
76 use_concurrency: Whether to speed things up using multiple threads. 80 use_concurrency: Whether to speed things up using multiple threads.
81 show_proguard_warning: Whether to print a warning about Proguard not being
82 enabled after installing.
77 """ 83 """
78 main_timer = time_profile.TimeProfile() 84 main_timer = time_profile.TimeProfile()
79 install_timer = time_profile.TimeProfile() 85 install_timer = time_profile.TimeProfile()
80 push_native_timer = time_profile.TimeProfile() 86 push_native_timer = time_profile.TimeProfile()
81 push_dex_timer = time_profile.TimeProfile() 87 push_dex_timer = time_profile.TimeProfile()
82 88
83 apk = apk_helper.ToHelper(apk) 89 apk = apk_helper.ToHelper(apk)
84 apk_package = apk.GetPackageName() 90 apk_package = apk.GetPackageName()
85 device_incremental_dir = _GetDeviceIncrementalDir(apk_package) 91 device_incremental_dir = _GetDeviceIncrementalDir(apk_package)
86 92
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 179
174 _Execute(use_concurrency, do_install, do_push_files) 180 _Execute(use_concurrency, do_install, do_push_files)
175 181
176 finalize_timer = _Execute(use_concurrency, release_installer_lock, save_cache) 182 finalize_timer = _Execute(use_concurrency, release_installer_lock, save_cache)
177 183
178 logging.info( 184 logging.info(
179 'Took %s seconds (setup=%s, install=%s, libs=%s, dex=%s, finalize=%s)', 185 'Took %s seconds (setup=%s, install=%s, libs=%s, dex=%s, finalize=%s)',
180 main_timer.GetDelta(), setup_timer.GetDelta(), install_timer.GetDelta(), 186 main_timer.GetDelta(), setup_timer.GetDelta(), install_timer.GetDelta(),
181 push_native_timer.GetDelta(), push_dex_timer.GetDelta(), 187 push_native_timer.GetDelta(), push_dex_timer.GetDelta(),
182 finalize_timer.GetDelta()) 188 finalize_timer.GetDelta())
189 if show_proguard_warning:
190 logging.warning('Target had proguard enabled, but incremental install uses '
191 'non-proguarded .dex files. Performance characteristics '
192 'may differ.')
183 193
184 194
185 def main(): 195 def main():
186 parser = argparse.ArgumentParser() 196 parser = argparse.ArgumentParser()
187 parser.add_argument('apk_path', 197 parser.add_argument('apk_path',
188 help='The path to the APK to install.') 198 help='The path to the APK to install.')
189 parser.add_argument('--split', 199 parser.add_argument('--split',
190 action='append', 200 action='append',
191 dest='splits', 201 dest='splits',
192 help='A glob matching the apk splits. ' 202 help='A glob matching the apk splits. '
(...skipping 16 matching lines...) Expand all
209 action='store_false', 219 action='store_false',
210 default=True, 220 default=True,
211 dest='threading', 221 dest='threading',
212 help='Do not install and push concurrently') 222 help='Do not install and push concurrently')
213 parser.add_argument('--no-cache', 223 parser.add_argument('--no-cache',
214 action='store_false', 224 action='store_false',
215 default=True, 225 default=True,
216 dest='cache', 226 dest='cache',
217 help='Do not use cached information about what files are ' 227 help='Do not use cached information about what files are '
218 'currently on the target device.') 228 'currently on the target device.')
229 parser.add_argument('--show-proguard-warning',
230 action='store_true',
231 default=False,
232 help='Print a warning about proguard being disabled')
219 parser.add_argument('-v', 233 parser.add_argument('-v',
220 '--verbose', 234 '--verbose',
221 dest='verbose_count', 235 dest='verbose_count',
222 default=0, 236 default=0,
223 action='count', 237 action='count',
224 help='Verbose level (multiple times for more)') 238 help='Verbose level (multiple times for more)')
225 239
226 args = parser.parse_args() 240 args = parser.parse_args()
227 241
228 run_tests_helper.SetLogLevel(args.verbose_count) 242 run_tests_helper.SetLogLevel(args.verbose_count)
(...skipping 22 matching lines...) Expand all
251 for d, desc in zip(devices, descriptions): 265 for d, desc in zip(devices, descriptions):
252 msg += ' %s (%s)\n' % (d, desc) 266 msg += ' %s (%s)\n' % (d, desc)
253 raise Exception(msg) 267 raise Exception(msg)
254 268
255 apk = apk_helper.ToHelper(args.apk_path) 269 apk = apk_helper.ToHelper(args.apk_path)
256 if args.uninstall: 270 if args.uninstall:
257 Uninstall(device, apk.GetPackageName()) 271 Uninstall(device, apk.GetPackageName())
258 else: 272 else:
259 Install(device, apk, split_globs=args.splits, lib_dir=args.lib_dir, 273 Install(device, apk, split_globs=args.splits, lib_dir=args.lib_dir,
260 dex_files=args.dex_files, enable_device_cache=args.cache, 274 dex_files=args.dex_files, enable_device_cache=args.cache,
261 use_concurrency=args.threading) 275 use_concurrency=args.threading,
276 show_proguard_warning=args.show_proguard_warning)
262 277
263 278
264 if __name__ == '__main__': 279 if __name__ == '__main__':
265 sys.exit(main()) 280 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/incremental_install/create_install_script.py ('k') | build/config/android/rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698