Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """Supports inferring locations of files in default checkout layouts. | |
| 6 | |
| 7 These functions allow devtools scripts to work out-of-the-box with regular Mojo | |
| 8 checkouts. | |
| 9 """ | |
| 10 | |
| 11 import os.path | |
| 12 | |
| 13 | |
| 14 def _lowest_ancestor_containing_relpath(relpath): | |
| 15 """Returns the lowest ancestor of this file that contains |relpath|.""" | |
| 16 cur_dir_path = os.path.abspath(os.path.dirname(__file__)) | |
| 17 while True: | |
| 18 if os.path.exists(os.path.join(cur_dir_path, relpath)): | |
| 19 return cur_dir_path | |
| 20 | |
| 21 next_dir_path = os.path.dirname(cur_dir_path) | |
| 22 if next_dir_path != cur_dir_path: | |
| 23 cur_dir_path = next_dir_path | |
| 24 else: | |
| 25 return None | |
| 26 | |
| 27 | |
| 28 def infer_default_paths(is_android, is_debug, target_cpu): | |
| 29 """Infers the locations of select build output artifacts in a regular Mojo | |
| 30 checkout. | |
| 31 | |
| 32 Returns: | |
| 33 Tuple of path dictionary, error message. Only one of the two will be | |
| 34 not-None. | |
| 35 """ | |
| 36 build_dir = (('android_' if is_android else '') + | |
| 37 (target_cpu + '_' if target_cpu else '') + | |
| 38 ('Debug' if is_debug else 'Release')) | |
| 39 out_build_dir = os.path.join('out', build_dir) | |
| 40 | |
| 41 root_path = _lowest_ancestor_containing_relpath(out_build_dir) | |
| 42 if not root_path: | |
| 43 return None, ('Failed to find build directory: ' + out_build_dir) | |
| 44 | |
| 45 paths = {} | |
| 46 paths['root'] = root_path | |
| 47 build_dir_path = os.path.join(root_path, out_build_dir) | |
| 48 paths['build'] = build_dir_path | |
| 49 if is_android: | |
| 50 paths['shell'] = os.path.join(build_dir_path, 'apks', 'MojoShell.apk') | |
| 51 paths['adb'] = os.path.join(root_path, 'third_party', 'android_tools', | |
| 52 'sdk', 'platform-tools', 'adb') | |
| 53 else: | |
| 54 paths['shell'] = os.path.join(build_dir_path, 'mojo_shell') | |
| 55 | |
| 56 paths['sky_packages'] = os.path.join(build_dir_path, 'gen', 'dart-pkg', | |
| 57 'packages') | |
| 58 return paths, '' | |
|
qsr
2015/07/16 14:19:20
According to your doc, this should be paths, None
ppi
2015/07/16 14:23:45
Done.
| |
| OLD | NEW |