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

Side by Side Diff: build/find_depot_tools.py

Issue 1408123011: Use find_depot_tools.py and vs_toolchain.py from chromium/src/build/ (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 5 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « DEPS ('k') | build/vs_toolchain.py » ('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 #!/usr/bin/python
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Small utility to find depot_tools."""
7
8 import os
9 import sys
10
11
12 def _IsRealDepotTools(path):
13 return os.path.isfile(os.path.join(path, 'gclient'))
14
15
16 def FindDepotTools():
17 """Search for depot_tools and return its path."""
18 # First look if depot_tools is already in PYTHONPATH.
19 for i in sys.path:
20 if i.rstrip(os.sep).endswith('depot_tools') and _IsRealDepotTools(i):
21 return i
22 # Then look if depot_tools is in PATH, common case.
23 for i in os.environ['PATH'].split(os.pathsep):
24 if _IsRealDepotTools(i):
25 return i.rstrip(os.sep)
26 # Rare case, it's not even in PATH, look upward up to root.
27 root_dir = os.path.dirname(os.path.abspath(__file__))
28 previous_dir = os.path.abspath(__file__)
29 while root_dir and root_dir != previous_dir:
30 i = os.path.join(root_dir, 'depot_tools')
31 if _IsRealDepotTools(i):
32 return i
33 previous_dir = root_dir
34 root_dir = os.path.dirname(root_dir)
35 return None
36
37
38 def main():
39 path = FindDepotTools()
40 if not path:
41 print >> sys.stderr, 'Failed to find depot_tools'
42 return 1
43 print path
44 return 0
45
46
47 if __name__ == '__main__':
48 sys.exit(main())
OLDNEW
« no previous file with comments | « DEPS ('k') | build/vs_toolchain.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698