OLD | NEW |
---|---|
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): | 21 def RunGN(sourceroot): |
22 # The binaries in platform-specific subdirectories in src/tools/gn/bin. | 22 # The binaries in platform-specific subdirectories in src/tools/gn/bin. |
23 gnpath = os.path.join(sourceroot, | 23 gnpath = os.path.join(sourceroot, |
24 'tools', 'gn', 'bin', gclient_utils.GetMacWinOrLinux(), | 24 'tools', 'gn', 'bin', gclient_utils.GetMacWinOrLinux(), |
25 'gn' + gclient_utils.GetExeSuffix()) | 25 'gn' + gclient_utils.GetExeSuffix()) |
26 return subprocess.call([gnpath] + sys.argv[1:]) | 26 return subprocess.call([gnpath] + sys.argv[1:]) |
27 | 27 |
28 | 28 |
29 def main(args): | 29 def main(args): |
30 for arg in sys.argv: | |
31 # TODO(dpranke): It would be nice if '--root foo' worked in addition | |
brettw
2014/03/27 21:04:20
I disagree that this should be supported and I'd j
| |
32 # to '--root=foo', but that would be inconsistent with how GN parses | |
33 # command line args. If we fix that in GN, we should fix this wrapper, too. | |
34 if arg.startswith('--root='): | |
35 sourceroot = arg.replace('--root=', '') | |
36 dotfile_path = os.path.join(sourceroot, '.gn') | |
37 if not os.path.exists(dotfile_path): | |
38 print >> sys.stderr, 'gn.py: "%s" not found, exiting.' % dotfile_path | |
39 sys.exit(1) | |
40 return RunGN(sourceroot) | |
41 | |
30 sourceroot = gclient_utils.FindFileUpwards('.gn') | 42 sourceroot = gclient_utils.FindFileUpwards('.gn') |
31 if not sourceroot: | 43 if not sourceroot: |
32 print >> sys.stderr, '.gn file not found in any parent of the current path.' | 44 print >> sys.stderr, ('gn.py: No .gn file found in any parent of ' |
45 'the current path.') | |
46 print >> sys.stderr, ('\nYou need to either be inside a checkout, ' | |
47 'or use --root to specify the checkout root.') | |
33 sys.exit(1) | 48 sys.exit(1) |
34 return RunGN(sourceroot) | 49 return RunGN(sourceroot) |
35 | 50 |
36 | 51 |
37 if __name__ == '__main__': | 52 if __name__ == '__main__': |
38 sys.exit(main(sys.argv)) | 53 sys.exit(main(sys.argv)) |
OLD | NEW |