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

Side by Side Diff: mojo/devtools/common/devtoolslib/default_paths.py

Issue 1242453003: Extract the shell runner into devtools. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Update more paths and devtools README. Created 5 years, 5 months 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
« no previous file with comments | « mojo/devtools/common/README.md ('k') | mojo/devtools/common/mojo_shell » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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, None
OLDNEW
« no previous file with comments | « mojo/devtools/common/README.md ('k') | mojo/devtools/common/mojo_shell » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698