summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py')
-rw-r--r--deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py
index 834a8e6c95..f595c947bc 100644
--- a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py
+++ b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py
@@ -9,6 +9,9 @@ import os.path
import re
import tempfile
import sys
+import subprocess
+
+PY3 = bytes != str
# A minimal memoizing decorator. It'll blow up if the args aren't immutable,
@@ -337,11 +340,16 @@ def WriteOnDiff(filename):
class Writer(object):
"""Wrapper around file which only covers the target if it differs."""
def __init__(self):
+ # On Cygwin remove the "dir" argument because `C:` prefixed paths are treated as relative,
+ # consequently ending up with current dir "/cygdrive/c/..." being prefixed to those, which was
+ # obviously a non-existent path, for example: "/cygdrive/c/<some folder>/C:\<my win style abs path>".
+ # See https://docs.python.org/2/library/tempfile.html#tempfile.mkstemp for more details
+ base_temp_dir = "" if IsCygwin() else os.path.dirname(filename)
# Pick temporary file.
tmp_fd, self.tmp_path = tempfile.mkstemp(
suffix='.tmp',
prefix=os.path.split(filename)[1] + '.gyp.',
- dir=os.path.split(filename)[0])
+ dir=base_temp_dir)
try:
self.tmp_file = os.fdopen(tmp_fd, 'wb')
except Exception:
@@ -394,6 +402,9 @@ def WriteOnDiff(filename):
os.unlink(self.tmp_path)
raise
+ def write(self, s):
+ self.tmp_file.write(s.encode('utf-8'))
+
return Writer()
@@ -608,3 +619,15 @@ def CrossCompileRequested():
os.environ.get('AR_target') or
os.environ.get('CC_target') or
os.environ.get('CXX_target'))
+
+def IsCygwin():
+ try:
+ out = subprocess.Popen("uname",
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ stdout, stderr = out.communicate()
+ if PY3:
+ stdout = stdout.decode("utf-8")
+ return "CYGWIN" in str(stdout)
+ except Exception:
+ return False