• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2
3# Copyright (c) 2009 Google Inc. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7import os
8import sys
9import subprocess
10
11PY3 = bytes != str
12
13# Below IsCygwin() function copied from pylib/gyp/common.py
14def IsCygwin():
15  try:
16    out = subprocess.Popen("uname",
17            stdout=subprocess.PIPE,
18            stderr=subprocess.STDOUT)
19    stdout, stderr = out.communicate()
20    if PY3:
21      stdout = stdout.decode("utf-8")
22    return "CYGWIN" in str(stdout)
23  except Exception:
24    return False
25
26
27def UnixifyPath(path):
28  try:
29    if not IsCygwin():
30      return path
31    out = subprocess.Popen(["cygpath", "-u", path],
32            stdout=subprocess.PIPE,
33            stderr=subprocess.STDOUT)
34    stdout, _ = out.communicate()
35    if PY3:
36      stdout = stdout.decode("utf-8")
37    return str(stdout)
38  except Exception:
39    return path
40
41
42# Make sure we're using the version of pylib in this repo, not one installed
43# elsewhere on the system. Also convert to Unix style path on Cygwin systems,
44# else the 'gyp' library will not be found
45path = UnixifyPath(sys.argv[0])
46sys.path.insert(0, os.path.join(os.path.dirname(path), 'pylib'))
47import gyp
48
49if __name__ == '__main__':
50  sys.exit(gyp.script_main())
51