You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gyp_main.py 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2009 Google Inc. 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. import os
  6. import sys
  7. import subprocess
  8. def IsCygwin():
  9. # Function copied from pylib/gyp/common.py
  10. try:
  11. out = subprocess.Popen(
  12. "uname", stdout=subprocess.PIPE, stderr=subprocess.STDOUT
  13. )
  14. stdout, _ = out.communicate()
  15. return "CYGWIN" in stdout.decode("utf-8")
  16. except Exception:
  17. return False
  18. def UnixifyPath(path):
  19. try:
  20. if not IsCygwin():
  21. return path
  22. out = subprocess.Popen(
  23. ["cygpath", "-u", path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
  24. )
  25. stdout, _ = out.communicate()
  26. return stdout.decode("utf-8")
  27. except Exception:
  28. return path
  29. # Make sure we're using the version of pylib in this repo, not one installed
  30. # elsewhere on the system. Also convert to Unix style path on Cygwin systems,
  31. # else the 'gyp' library will not be found
  32. path = UnixifyPath(sys.argv[0])
  33. sys.path.insert(0, os.path.join(os.path.dirname(path), "pylib"))
  34. import gyp # noqa: E402
  35. if __name__ == "__main__":
  36. sys.exit(gyp.script_main())