Skip to content

Commit

Permalink
Merge pull request #10 from targos/sync
Browse files Browse the repository at this point in the history
Sync code base with nodejs/node
  • Loading branch information
ryzokuken committed Feb 24, 2020
2 parents e08cd34 + 2304675 commit 24b41b6
Show file tree
Hide file tree
Showing 52 changed files with 1,357 additions and 391 deletions.
38 changes: 36 additions & 2 deletions gyp_main.py
Expand Up @@ -6,10 +6,44 @@

import os
import sys
import subprocess

PY3 = bytes != str

# Below IsCygwin() function copied from pylib/gyp/common.py
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


def UnixifyPath(path):
try:
if not IsCygwin():
return path
out = subprocess.Popen(["cygpath", "-u", path],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout, _ = out.communicate()
if PY3:
stdout = stdout.decode("utf-8")
return str(stdout)
except Exception:
return path


# Make sure we're using the version of pylib in this repo, not one installed
# elsewhere on the system.
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), 'pylib'))
# elsewhere on the system. Also convert to Unix style path on Cygwin systems,
# else the 'gyp' library will not be found
path = UnixifyPath(sys.argv[0])
sys.path.insert(0, os.path.join(os.path.dirname(path), 'pylib'))
import gyp

if __name__ == '__main__':
Expand Down
8 changes: 5 additions & 3 deletions pylib/gyp/MSVSSettings.py
Expand Up @@ -522,8 +522,8 @@ def _ValidateSettings(validators, settings, stderr):
try:
tool_validators[setting](value)
except ValueError as e:
print('Warning: for %s/%s, %s' % (tool_name, setting, e),
file=stderr)
print('Warning: for %s/%s, %s' %
(tool_name, setting, e), file=stderr)
else:
_ValidateExclusionSetting(setting,
tool_validators,
Expand Down Expand Up @@ -976,7 +976,9 @@ def _ValidateSettings(validators, settings, stderr):
_Enumeration(['NotSet',
'Win32', # /env win32
'Itanium', # /env ia64
'X64'])) # /env x64
'X64', # /env x64
'ARM64', # /env arm64
]))
_Same(_midl, 'EnableErrorChecks',
_Enumeration(['EnableCustom',
'None', # /error none
Expand Down
2 changes: 2 additions & 0 deletions pylib/gyp/MSVSSettings_test.py
Expand Up @@ -1085,6 +1085,7 @@ def testConvertToMSBuildSettings_full_synthetic(self):
'GenerateManifest': 'true',
'IgnoreImportLibrary': 'true',
'LinkIncremental': 'false'}}
self.maxDiff = 9999 # on failure display a long diff
actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
msvs_settings,
self.stderr)
Expand Down Expand Up @@ -1476,6 +1477,7 @@ def testConvertToMSBuildSettings_actual(self):
'ResourceOutputFileName':
'$(IntDir)$(TargetFileName).embed.manifest.resfdsf'}
}
self.maxDiff = 9999 # on failure display a long diff
actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(
msvs_settings,
self.stderr)
Expand Down
Binary file removed pylib/gyp/MSVSUtil.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions pylib/gyp/MSVSVersion.py
Expand Up @@ -12,6 +12,8 @@
import gyp
import glob

PY3 = bytes != str


def JoinPath(*args):
return os.path.normpath(os.path.join(*args))
Expand Down Expand Up @@ -163,6 +165,8 @@ def _RegistryQueryBase(sysdir, key, value):
# Obtain the stdout from reg.exe, reading to the end so p.returncode is valid
# Note that the error text may be in [1] in some cases
text = p.communicate()[0]
if PY3:
text = text.decode('utf-8')
# Check return code from reg.exe; officially 0==success and 1==error
if p.returncode:
return None
Expand Down Expand Up @@ -385,6 +389,8 @@ def _ConvertToCygpath(path):
if sys.platform == 'cygwin':
p = subprocess.Popen(['cygpath', path], stdout=subprocess.PIPE)
path = p.communicate()[0].strip()
if PY3:
path = path.decode('utf-8')
return path


Expand Down
Binary file removed pylib/gyp/MSVSVersion.pyc
Binary file not shown.
Binary file removed pylib/gyp/__init__.pyc
Binary file not shown.
Binary file modified pylib/gyp/__pycache__/MSVSUtil.cpython-37.pyc
Binary file not shown.
Binary file modified pylib/gyp/__pycache__/MSVSVersion.cpython-37.pyc
Binary file not shown.
Binary file modified pylib/gyp/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file modified pylib/gyp/__pycache__/common.cpython-37.pyc
Binary file not shown.
Binary file modified pylib/gyp/__pycache__/input.cpython-37.pyc
Binary file not shown.
Binary file modified pylib/gyp/__pycache__/msvs_emulation.cpython-37.pyc
Binary file not shown.
Binary file modified pylib/gyp/__pycache__/ninja_syntax.cpython-37.pyc
Binary file not shown.
Binary file modified pylib/gyp/__pycache__/simple_copy.cpython-37.pyc
Binary file not shown.
Binary file modified pylib/gyp/__pycache__/xcode_emulation.cpython-37.pyc
Binary file not shown.
Binary file removed pylib/gyp/__pycache__/xcode_ninja.cpython-37.pyc
Binary file not shown.
Binary file removed pylib/gyp/__pycache__/xcodeproj_file.cpython-37.pyc
Binary file not shown.
28 changes: 24 additions & 4 deletions pylib/gyp/common.py
Expand Up @@ -8,12 +8,15 @@
import re
import tempfile
import sys
import subprocess

try:
from collections.abc import MutableSet
except ImportError:
from collections import MutableSet

PY3 = bytes != str


# A minimal memoizing decorator. It'll blow up if the args aren't immutable,
# among other "problems".
Expand Down Expand Up @@ -341,11 +344,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:
Expand Down Expand Up @@ -426,16 +434,16 @@ def GetFlavor(params):
return flavors[sys.platform]
if sys.platform.startswith('sunos'):
return 'solaris'
if sys.platform.startswith('freebsd'):
return 'freebsd'
if sys.platform.startswith('dragonfly'):
if sys.platform.startswith(('dragonfly', 'freebsd')):
return 'freebsd'
if sys.platform.startswith('openbsd'):
return 'openbsd'
if sys.platform.startswith('netbsd'):
return 'netbsd'
if sys.platform.startswith('aix'):
return 'aix'
if sys.platform.startswith(('os390', 'zos')):
return 'zos'

return 'linux'

Expand Down Expand Up @@ -620,3 +628,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
Binary file removed pylib/gyp/common.pyc
Binary file not shown.
Binary file removed pylib/gyp/generator/__init__.pyc
Binary file not shown.
Binary file modified pylib/gyp/generator/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file removed pylib/gyp/generator/__pycache__/make.cpython-37.pyc
Binary file not shown.
Binary file modified pylib/gyp/generator/__pycache__/ninja.cpython-37.pyc
Binary file not shown.
Binary file removed pylib/gyp/generator/__pycache__/xcode.cpython-37.pyc
Binary file not shown.

0 comments on commit 24b41b6

Please sign in to comment.