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

Side by Side Diff: gn.py

Issue 341533006: Make gn wrapper use the one in buildtools rather than tools/gn/bin. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « gclient_utils.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This script is a wrapper around the GN binary that is pulled from Google 6 """This script is a wrapper around the GN binary that is pulled from Google
7 Cloud Storage when you sync Chrome. The binaries go into platform-specific 7 Cloud Storage when you sync Chrome. The binaries go into platform-specific
8 subdirectories in the source tree. 8 subdirectories in the source tree.
9 9
10 This script makes there be one place for forwarding to the correct platform's 10 This script makes there be one place for forwarding to the correct platform's
11 binary. It will also automatically try to find the gn binary when run inside 11 binary. It will also automatically try to find the gn binary when run inside
12 the chrome source tree, so users can just type "gn" on the command line 12 the chrome source tree, so users can just type "gn" on the command line
13 (normally depot_tools is on the path).""" 13 (normally depot_tools is on the path)."""
14 14
15 import gclient_utils 15 import gclient_utils
16 import os 16 import os
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 19
20 20
21 def RunGN(sourceroot):
22 # The binaries in platform-specific subdirectories in src/tools/gn/bin.
23 gnpath = os.path.join(sourceroot,
24 'tools', 'gn', 'bin', gclient_utils.GetMacWinOrLinux(),
25 'gn' + gclient_utils.GetExeSuffix())
26 return subprocess.call([gnpath] + sys.argv[1:])
27
28
29 def main(args): 21 def main(args):
30 for arg in sys.argv: 22 bin_path = gclient_utils.GetBuildtoolsPlatformBinaryPath()
31 if arg.startswith('--root='): 23 if not bin_path:
32 sourceroot = arg.replace('--root=', '') 24 print >> sys.stderr, ('gn.py: Could not find checkout in any parent of '
33 dotfile_path = os.path.join(sourceroot, '.gn') 25 'the current path.\nThis must be run inside a '
34 if not os.path.exists(dotfile_path): 26 'checkout.')
35 print >> sys.stderr, 'gn.py: "%s" not found, exiting.' % dotfile_path
36 sys.exit(1)
37 return RunGN(sourceroot)
38
39 sourceroot = gclient_utils.FindFileUpwards('.gn')
40 if not sourceroot:
41 print >> sys.stderr, ('gn.py: No .gn file found in any parent of '
42 'the current path.')
43 print >> sys.stderr, ('\nYou need to either be inside a checkout, '
44 'or use --root to specify the checkout root.')
45 sys.exit(1) 27 sys.exit(1)
46 return RunGN(sourceroot) 28 gn_path = os.path.join(bin_path, 'gn' + gclient_utils.GetExeSuffix())
29 return subprocess.call([gn_path] + sys.argv[1:])
47 30
48 31
49 if __name__ == '__main__': 32 if __name__ == '__main__':
50 sys.exit(main(sys.argv)) 33 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « gclient_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698