brettw@chromium.org | 67bb861 | 2013-11-08 20:51:40 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 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 |
| 4 | # found in the LICENSE file. |
| 5 | |
| 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 |
| 8 | subdirectories in the source tree. |
| 9 | |
| 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 |
| 12 | the chrome source tree, so users can just type "gn" on the command line |
| 13 | (normally depot_tools is on the path).""" |
| 14 | |
nick@chromium.org | 3ac1c4e | 2014-01-16 02:44:42 +0000 | [diff] [blame] | 15 | import gclient_utils |
brettw@chromium.org | 67bb861 | 2013-11-08 20:51:40 +0000 | [diff] [blame] | 16 | import os |
| 17 | import subprocess |
| 18 | import sys |
| 19 | |
| 20 | |
brettw@chromium.org | 67bb861 | 2013-11-08 20:51:40 +0000 | [diff] [blame] | 21 | def main(args): |
brettw@chromium.org | cc968fe | 2014-06-23 17:30:32 +0000 | [diff] [blame] | 22 | bin_path = gclient_utils.GetBuildtoolsPlatformBinaryPath() |
| 23 | if not bin_path: |
| 24 | print >> sys.stderr, ('gn.py: Could not find checkout in any parent of ' |
| 25 | 'the current path.\nThis must be run inside a ' |
| 26 | 'checkout.') |
kjellander@chromium.org | f7facfa | 2014-09-05 12:40:28 +0000 | [diff] [blame^] | 27 | return 1 |
brettw@chromium.org | cc968fe | 2014-06-23 17:30:32 +0000 | [diff] [blame] | 28 | gn_path = os.path.join(bin_path, 'gn' + gclient_utils.GetExeSuffix()) |
kjellander@chromium.org | f7facfa | 2014-09-05 12:40:28 +0000 | [diff] [blame^] | 29 | if not os.path.exists(gn_path): |
| 30 | print >> sys.stderr, 'gn.py: Could not find gn executable at: %s' % gn_path |
| 31 | return 2 |
| 32 | else: |
| 33 | return subprocess.call([gn_path] + sys.argv[1:]) |
brettw@chromium.org | 67bb861 | 2013-11-08 20:51:40 +0000 | [diff] [blame] | 34 | |
nick@chromium.org | 3ac1c4e | 2014-01-16 02:44:42 +0000 | [diff] [blame] | 35 | |
brettw@chromium.org | 67bb861 | 2013-11-08 20:51:40 +0000 | [diff] [blame] | 36 | if __name__ == '__main__': |
| 37 | sys.exit(main(sys.argv)) |