blob: 067f42e0f1ce62ab43eb5ed3fc55a7747d4e0689 [file] [log] [blame]
brettw@chromium.org67bb8612013-11-08 20:51:40 +00001#!/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
7Cloud Storage when you sync Chrome. The binaries go into platform-specific
8subdirectories in the source tree.
9
10This script makes there be one place for forwarding to the correct platform's
11binary. It will also automatically try to find the gn binary when run inside
12the chrome source tree, so users can just type "gn" on the command line
13(normally depot_tools is on the path)."""
14
nick@chromium.org3ac1c4e2014-01-16 02:44:42 +000015import gclient_utils
brettw@chromium.org67bb8612013-11-08 20:51:40 +000016import os
17import subprocess
18import sys
19
20
brettw@chromium.org67bb8612013-11-08 20:51:40 +000021def RunGN(sourceroot):
22 # The binaries in platform-specific subdirectories in src/tools/gn/bin.
nick@chromium.org3ac1c4e2014-01-16 02:44:42 +000023 gnpath = os.path.join(sourceroot,
24 'tools', 'gn', 'bin', gclient_utils.GetMacWinOrLinux(),
25 'gn' + gclient_utils.GetExeSuffix())
brettw@chromium.org67bb8612013-11-08 20:51:40 +000026 return subprocess.call([gnpath] + sys.argv[1:])
27
28
29def main(args):
nick@chromium.org3ac1c4e2014-01-16 02:44:42 +000030 sourceroot = gclient_utils.FindFileUpwards('.gn')
brettw@chromium.org67bb8612013-11-08 20:51:40 +000031 if not sourceroot:
32 print >> sys.stderr, '.gn file not found in any parent of the current path.'
33 sys.exit(1)
34 return RunGN(sourceroot)
35
nick@chromium.org3ac1c4e2014-01-16 02:44:42 +000036
brettw@chromium.org67bb8612013-11-08 20:51:40 +000037if __name__ == '__main__':
38 sys.exit(main(sys.argv))