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

Side by Side Diff: tools/find_depot_tools.py

Issue 2385643004: Enables GN build on windows (Closed)
Patch Set: Add .gitignore for build Created 4 years, 2 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
OLDNEW
(Empty)
1 # Copyright (c) 2011 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 """Small utility function to find depot_tools and add it to the python path.
5 Will throw an ImportError exception if depot_tools can't be found since it
6 imports breakpad.
7 """
8
9 import os
10 import sys
11
12
13 def IsRealDepotTools(path):
14 return os.path.isfile(os.path.join(path, 'gclient.py'))
15
16
17 def add_depot_tools_to_path():
18 """Search for depot_tools and add it to sys.path."""
19 # First look if depot_tools is already in PYTHONPATH.
20 for i in sys.path:
21 if i.rstrip(os.sep).endswith('depot_tools') and IsRealDepotTools(i):
22 return i
23 # Then look if depot_tools is in PATH, common case.
24 for i in os.environ['PATH'].split(os.pathsep):
25 if IsRealDepotTools(i):
26 sys.path.append(i.rstrip(os.sep))
27 return i
28 # Rare case, it's not even in PATH, look upward up to root.
29 root_dir = os.path.dirname(os.path.abspath(__file__))
30 previous_dir = os.path.abspath(__file__)
31 while root_dir and root_dir != previous_dir:
32 i = os.path.join(root_dir, 'depot_tools')
33 if IsRealDepotTools(i):
34 sys.path.append(i)
35 return i
36 previous_dir = root_dir
37 root_dir = os.path.dirname(root_dir)
38 print >> sys.stderr, 'Failed to find depot_tools'
39 return None
40
41 add_depot_tools_to_path()
42
43 # pylint: disable=W0611
44 import breakpad
OLDNEW
« no previous file with comments | « runtime/vm/BUILD.gn ('k') | tools/gn.py » ('j') | utils/invoke_dart.gni » ('J')

Powered by Google App Engine
This is Rietveld 408576698