Commit 972780b

Browse files
authored
gyp: sync code base with nodejs repo (#1975)
PR-URL: #1975 Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent dab0305 commit 972780b

28 files changed

Lines changed: 971 additions & 390 deletions

‎gyp/AUTHORS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Ryan Norton <rnorton10@gmail.com>
1111
David J. Sankel <david@sankelsoftware.com>
1212
Eric N. Vander Weele <ericvw@gmail.com>
1313
Tom Freudenberg <th.freudenberg@gmail.com>
14+
Julien Brianceau <jbriance@cisco.com>
15+
Refael Ackermann <refack@gmail.com>

‎gyp/DEPS‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎gyp/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GYP can Generate Your Projects.
2+
===================================
3+
4+
Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check out ```md-pages``` branch to read those documents offline.

‎gyp/codereview.settings‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎gyp/pylib/gyp/MSVSNew.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importhashlib
88
importos
99
importrandom
10+
fromoperatorimportattrgetter
1011

1112
importgyp.common
1213

@@ -59,9 +60,6 @@ def __cmp__(self, other):
5960
# Sort by name then guid (so things are in order on vs2008).
6061
returncmp((self.name, self.get_guid()), (other.name, other.get_guid()))
6162

62-
def__lt__(self, other):
63-
returnself.__cmp__(other) <0
64-
6563

6664
classMSVSFolder(MSVSSolutionEntry):
6765
"""Folder in a Visual Studio project or solution."""
@@ -89,7 +87,7 @@ def __init__(self, path, name = None, entries = None,
8987
self.guid=guid
9088

9189
# Copy passed lists (or set to empty lists)
92-
self.entries=sorted(list(entriesor []))
90+
self.entries=sorted(entriesor [], key=attrgetter('path'))
9391
self.items=list(itemsor [])
9492

9593
self.entry_type_guid=ENTRY_TYPE_GUIDS['folder']
@@ -233,7 +231,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
233231
ifisinstance(e, MSVSFolder):
234232
entries_to_check+=e.entries
235233

236-
all_entries=sorted(all_entries)
234+
all_entries=sorted(all_entries, key=attrgetter('path'))
237235

238236
# Open file and print header
239237
f=writer(self.path)

‎gyp/pylib/gyp/MSVSSettings.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
467467
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
468468
exceptValueErrorase:
469469
print('Warning: while converting %s/%s to MSBuild, '
470-
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
470+
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
471471
else:
472472
_ValidateExclusionSetting(msvs_setting,
473473
msvs_tool,
@@ -477,7 +477,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
477477
stderr)
478478
else:
479479
print('Warning: unrecognized tool %s while converting to '
480-
'MSBuild.'%msvs_tool_name, file=stderr)
480+
'MSBuild.'%msvs_tool_name, file=stderr)
481481
returnmsbuild_settings
482482

483483

@@ -598,6 +598,7 @@ def _ValidateSettings(validators, settings, stderr):
598598
_Same(_compile, 'UseFullPaths', _boolean) # /FC
599599
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
600600
_Same(_compile, 'XMLDocumentationFileName', _file_name)
601+
_Same(_compile, 'CompileAsWinRT', _boolean) # /ZW
601602

602603
_Same(_compile, 'AssemblerOutput',
603604
_Enumeration(['NoListing',

‎gyp/pylib/gyp/MSVSSettings_test.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
"""Unit tests for the MSVSSettings.py file."""
88

9-
try:
10-
fromcStringIOimportStringIO
11-
exceptImportError:
12-
fromioimportStringIO
13-
149
importunittest
1510
importgyp.MSVSSettingsasMSVSSettings
1611

12+
try:
13+
fromStringIOimportStringIO# Python 2
14+
exceptImportError:
15+
fromioimportStringIO# Python 3
16+
1717

1818
classTestSequenceFunctions(unittest.TestCase):
1919

‎gyp/pylib/gyp/MSVSUtil.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'loadable_module': 'dll',
1515
'shared_library': 'dll',
1616
'static_library': 'lib',
17+
'windows_driver': 'sys',
1718
}
1819

1920

@@ -110,7 +111,7 @@ def ShardTargets(target_list, target_dicts):
110111
else:
111112
new_target_dicts[t] =target_dicts[t]
112113
# Shard dependencies.
113-
fortinnew_target_dicts:
114+
fortinsorted(new_target_dicts):
114115
fordeptypein ('dependencies', 'dependencies_original'):
115116
dependencies=copy.copy(new_target_dicts[t].get(deptype, []))
116117
new_dependencies= []

‎gyp/pylib/gyp/MSVSVersion.py‎

Lines changed: 104 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
PY3=bytes!=str
1616

1717

18+
defJoinPath(*args):
19+
returnos.path.normpath(os.path.join(*args))
20+
21+
1822
classVisualStudioVersion(object):
1923
"""Information regarding a version of Visual Studio."""
2024

2125
def__init__(self, short_name, description,
2226
solution_version, project_version, flat_sln, uses_vcxproj,
23-
path, sdk_based, default_toolset=None):
27+
path, sdk_based, default_toolset=None, compatible_sdks=None):
2428
self.short_name=short_name
2529
self.description=description
2630
self.solution_version=solution_version
@@ -30,6 +34,9 @@ def __init__(self, short_name, description,
3034
self.path=path
3135
self.sdk_based=sdk_based
3236
self.default_toolset=default_toolset
37+
compatible_sdks=compatible_sdksor []
38+
compatible_sdks.sort(key=lambdav: float(v.replace('v', '')), reverse=True)
39+
self.compatible_sdks=compatible_sdks
3340

3441
defShortName(self):
3542
returnself.short_name
@@ -70,43 +77,67 @@ def DefaultToolset(self):
7077
of a user override."""
7178
returnself.default_toolset
7279

73-
defSetupScript(self, target_arch):
80+
81+
def_SetupScriptInternal(self, target_arch):
7482
"""Returns a command (with arguments) to be used to set up the
7583
environment."""
76-
# Check if we are running in the SDK command line environment and use
77-
# the setup script from the SDK if so. |target_arch| should be either
78-
# 'x86' or 'x64'.
79-
asserttarget_archin ('x86', 'x64')
80-
sdk_dir=os.environ.get('WindowsSDKDir')
81-
ifself.sdk_basedandsdk_dir:
82-
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
83-
'/'+target_arch]
84-
else:
85-
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
86-
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
87-
# isn't always.
88-
iftarget_arch=='x86':
89-
ifself.short_name>='2013'andself.short_name[-1] !='e'and (
90-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
91-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
92-
# VS2013 and later, non-Express have a x64-x86 cross that we want
93-
# to prefer.
94-
return [os.path.normpath(
95-
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
96-
# Otherwise, the standard x86 compiler.
97-
return [os.path.normpath(
98-
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
84+
asserttarget_archin ('x86', 'x64'), "target_arch not supported"
85+
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
86+
# depot_tools build tools and should run SetEnv.Cmd to set up the
87+
# environment. The check for WindowsSDKDir alone is not sufficient because
88+
# this is set by running vcvarsall.bat.
89+
sdk_dir=os.environ.get('WindowsSDKDir', '')
90+
setup_path=JoinPath(sdk_dir, 'Bin', 'SetEnv.Cmd')
91+
ifself.sdk_basedandsdk_dirandos.path.exists(setup_path):
92+
return [setup_path, '/'+target_arch]
93+
94+
is_host_arch_x64= (
95+
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
96+
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'
97+
)
98+
99+
# For VS2017 (and newer) it's fairly easy
100+
ifself.short_name>='2017':
101+
script_path=JoinPath(self.path,
102+
'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
103+
104+
# Always use a native executable, cross-compiling if necessary.
105+
host_arch='amd64'ifis_host_arch_x64else'x86'
106+
msvc_target_arch='amd64'iftarget_arch=='x64'else'x86'
107+
arg=host_arch
108+
ifhost_arch!=msvc_target_arch:
109+
arg+='_'+msvc_target_arch
110+
111+
return [script_path, arg]
112+
113+
# We try to find the best version of the env setup batch.
114+
vcvarsall=JoinPath(self.path, 'VC', 'vcvarsall.bat')
115+
iftarget_arch=='x86':
116+
ifself.short_name>='2013'andself.short_name[-1] !='e'and \
117+
is_host_arch_x64:
118+
# VS2013 and later, non-Express have a x64-x86 cross that we want
119+
# to prefer.
120+
return [vcvarsall, 'amd64_x86']
99121
else:
100-
asserttarget_arch=='x64'
101-
arg='x86_amd64'
102-
# Use the 64-on-64 compiler if we're not using an express
103-
# edition and we're running on a 64bit OS.
104-
ifself.short_name[-1] !='e'and (
105-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
106-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
107-
arg='amd64'
108-
return [os.path.normpath(
109-
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
122+
# Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
123+
# for x86 because vcvarsall calls vcvars32, which it can only find if
124+
# VS??COMNTOOLS is set, which isn't guaranteed.
125+
return [JoinPath(self.path, 'Common7', 'Tools', 'vsvars32.bat')]
126+
eliftarget_arch=='x64':
127+
arg='x86_amd64'
128+
# Use the 64-on-64 compiler if we're not using an express edition and
129+
# we're running on a 64bit OS.
130+
ifself.short_name[-1] !='e'andis_host_arch_x64:
131+
arg='amd64'
132+
return [vcvarsall, arg]
133+
134+
defSetupScript(self, target_arch):
135+
script_data=self._SetupScriptInternal(target_arch)
136+
script_path=script_data[0]
137+
ifnotos.path.exists(script_path):
138+
raiseException('%s is missing - make sure VC++ tools are installed.'%
139+
script_path)
140+
returnscript_data
110141

111142

112143
def_RegistryQueryBase(sysdir, key, value):
@@ -181,11 +212,11 @@ def _RegistryGetValueUsingWinReg(key, value):
181212
ImportError if _winreg is unavailable.
182213
"""
183214
try:
184-
# Python 2
185-
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
215+
# Python 2
216+
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
186217
exceptImportError:
187-
# Python 3
188-
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
218+
# Python 3
219+
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
189220

190221
try:
191222
root, subkey=key.split('\\', 1)
@@ -236,6 +267,26 @@ def _CreateVersion(name, path, sdk_based=False):
236267
ifpath:
237268
path=os.path.normpath(path)
238269
versions= {
270+
'2019': VisualStudioVersion('2019',
271+
'Visual Studio 2019',
272+
solution_version='12.00',
273+
project_version='16.0',
274+
flat_sln=False,
275+
uses_vcxproj=True,
276+
path=path,
277+
sdk_based=sdk_based,
278+
default_toolset='v142',
279+
compatible_sdks=['v8.1', 'v10.0']),
280+
'2017': VisualStudioVersion('2017',
281+
'Visual Studio 2017',
282+
solution_version='12.00',
283+
project_version='15.0',
284+
flat_sln=False,
285+
uses_vcxproj=True,
286+
path=path,
287+
sdk_based=sdk_based,
288+
default_toolset='v141',
289+
compatible_sdks=['v8.1', 'v10.0']),
239290
'2015': VisualStudioVersion('2015',
240291
'Visual Studio 2015',
241292
solution_version='12.00',
@@ -350,14 +401,15 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
350401
A list of visual studio versions installed in descending order of
351402
usage preference.
352403
Base this on the registry and a quick check if devenv.exe exists.
353-
Only versions 8-10 are considered.
354404
Possibilities are:
355405
2005(e) - Visual Studio 2005 (8)
356406
2008(e) - Visual Studio 2008 (9)
357407
2010(e) - Visual Studio 2010 (10)
358408
2012(e) - Visual Studio 2012 (11)
359409
2013(e) - Visual Studio 2013 (12)
360410
2015 - Visual Studio 2015 (14)
411+
2017 - Visual Studio 2017 (15)
412+
2019 - Visual Studio 2019 (16)
361413
Where (e) is e for express editions of MSVS and blank otherwise.
362414
"""
363415
version_to_year= {
@@ -367,6 +419,8 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
367419
'11.0': '2012',
368420
'12.0': '2013',
369421
'14.0': '2015',
422+
'15.0': '2017',
423+
'16.0': '2019',
370424
}
371425
versions= []
372426
forversioninversions_to_check:
@@ -397,13 +451,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
397451

398452
# The old method above does not work when only SDK is installed.
399453
keys= [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
400-
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
454+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
455+
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
456+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
401457
forindexinrange(len(keys)):
402458
path=_RegistryGetValue(keys[index], version)
403459
ifnotpath:
404460
continue
405461
path=_ConvertToCygpath(path)
406-
ifversion!='14.0': # There is no Express edition for 2015.
462+
ifversion=='15.0':
463+
ifos.path.exists(path):
464+
versions.append(_CreateVersion('2017', path))
465+
elifversion!='14.0': # There is no Express edition for 2015.
407466
versions.append(_CreateVersion(version_to_year[version] +'e',
408467
os.path.join(path, '..'), sdk_based=True))
409468

@@ -422,7 +481,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422481
ifversion=='auto':
423482
version=os.environ.get('GYP_MSVS_VERSION', 'auto')
424483
version_map= {
425-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
484+
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
426485
'2005': ('8.0',),
427486
'2005e': ('8.0',),
428487
'2008': ('9.0',),
@@ -434,6 +493,8 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
434493
'2013': ('12.0',),
435494
'2013e': ('12.0',),
436495
'2015': ('14.0',),
496+
'2017': ('15.0',),
497+
'2019': ('16.0',),
437498
}
438499
override_path=os.environ.get('GYP_MSVS_OVERRIDE_PATH')
439500
ifoverride_path:

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Commit 972780b

Browse files
authored
gyp: sync code base with nodejs repo (#1975)
PR-URL: #1975 Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent dab0305 commit 972780b

28 files changed

Lines changed: 971 additions & 390 deletions

‎gyp/AUTHORS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Ryan Norton <rnorton10@gmail.com>
1111
David J. Sankel <david@sankelsoftware.com>
1212
Eric N. Vander Weele <ericvw@gmail.com>
1313
Tom Freudenberg <th.freudenberg@gmail.com>
14+
Julien Brianceau <jbriance@cisco.com>
15+
Refael Ackermann <refack@gmail.com>

‎gyp/DEPS‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎gyp/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GYP can Generate Your Projects.
2+
===================================
3+
4+
Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check out ```md-pages``` branch to read those documents offline.

‎gyp/codereview.settings‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎gyp/pylib/gyp/MSVSNew.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importhashlib
88
importos
99
importrandom
10+
fromoperatorimportattrgetter
1011

1112
importgyp.common
1213

@@ -59,9 +60,6 @@ def __cmp__(self, other):
5960
# Sort by name then guid (so things are in order on vs2008).
6061
returncmp((self.name, self.get_guid()), (other.name, other.get_guid()))
6162

62-
def__lt__(self, other):
63-
returnself.__cmp__(other) <0
64-
6563

6664
classMSVSFolder(MSVSSolutionEntry):
6765
"""Folder in a Visual Studio project or solution."""
@@ -89,7 +87,7 @@ def __init__(self, path, name = None, entries = None,
8987
self.guid=guid
9088

9189
# Copy passed lists (or set to empty lists)
92-
self.entries=sorted(list(entriesor []))
90+
self.entries=sorted(entriesor [], key=attrgetter('path'))
9391
self.items=list(itemsor [])
9492

9593
self.entry_type_guid=ENTRY_TYPE_GUIDS['folder']
@@ -233,7 +231,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
233231
ifisinstance(e, MSVSFolder):
234232
entries_to_check+=e.entries
235233

236-
all_entries=sorted(all_entries)
234+
all_entries=sorted(all_entries, key=attrgetter('path'))
237235

238236
# Open file and print header
239237
f=writer(self.path)

‎gyp/pylib/gyp/MSVSSettings.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
467467
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
468468
exceptValueErrorase:
469469
print('Warning: while converting %s/%s to MSBuild, '
470-
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
470+
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
471471
else:
472472
_ValidateExclusionSetting(msvs_setting,
473473
msvs_tool,
@@ -477,7 +477,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
477477
stderr)
478478
else:
479479
print('Warning: unrecognized tool %s while converting to '
480-
'MSBuild.'%msvs_tool_name, file=stderr)
480+
'MSBuild.'%msvs_tool_name, file=stderr)
481481
returnmsbuild_settings
482482

483483

@@ -598,6 +598,7 @@ def _ValidateSettings(validators, settings, stderr):
598598
_Same(_compile, 'UseFullPaths', _boolean) # /FC
599599
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
600600
_Same(_compile, 'XMLDocumentationFileName', _file_name)
601+
_Same(_compile, 'CompileAsWinRT', _boolean) # /ZW
601602

602603
_Same(_compile, 'AssemblerOutput',
603604
_Enumeration(['NoListing',

‎gyp/pylib/gyp/MSVSSettings_test.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
"""Unit tests for the MSVSSettings.py file."""
88

9-
try:
10-
fromcStringIOimportStringIO
11-
exceptImportError:
12-
fromioimportStringIO
13-
149
importunittest
1510
importgyp.MSVSSettingsasMSVSSettings
1611

12+
try:
13+
fromStringIOimportStringIO# Python 2
14+
exceptImportError:
15+
fromioimportStringIO# Python 3
16+
1717

1818
classTestSequenceFunctions(unittest.TestCase):
1919

‎gyp/pylib/gyp/MSVSUtil.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'loadable_module': 'dll',
1515
'shared_library': 'dll',
1616
'static_library': 'lib',
17+
'windows_driver': 'sys',
1718
}
1819

1920

@@ -110,7 +111,7 @@ def ShardTargets(target_list, target_dicts):
110111
else:
111112
new_target_dicts[t] =target_dicts[t]
112113
# Shard dependencies.
113-
fortinnew_target_dicts:
114+
fortinsorted(new_target_dicts):
114115
fordeptypein ('dependencies', 'dependencies_original'):
115116
dependencies=copy.copy(new_target_dicts[t].get(deptype, []))
116117
new_dependencies= []

‎gyp/pylib/gyp/MSVSVersion.py‎

Lines changed: 104 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
PY3=bytes!=str
1616

1717

18+
defJoinPath(*args):
19+
returnos.path.normpath(os.path.join(*args))
20+
21+
1822
classVisualStudioVersion(object):
1923
"""Information regarding a version of Visual Studio."""
2024

2125
def__init__(self, short_name, description,
2226
solution_version, project_version, flat_sln, uses_vcxproj,
23-
path, sdk_based, default_toolset=None):
27+
path, sdk_based, default_toolset=None, compatible_sdks=None):
2428
self.short_name=short_name
2529
self.description=description
2630
self.solution_version=solution_version
@@ -30,6 +34,9 @@ def __init__(self, short_name, description,
3034
self.path=path
3135
self.sdk_based=sdk_based
3236
self.default_toolset=default_toolset
37+
compatible_sdks=compatible_sdksor []
38+
compatible_sdks.sort(key=lambdav: float(v.replace('v', '')), reverse=True)
39+
self.compatible_sdks=compatible_sdks
3340

3441
defShortName(self):
3542
returnself.short_name
@@ -70,43 +77,67 @@ def DefaultToolset(self):
7077
of a user override."""
7178
returnself.default_toolset
7279

73-
defSetupScript(self, target_arch):
80+
81+
def_SetupScriptInternal(self, target_arch):
7482
"""Returns a command (with arguments) to be used to set up the
7583
environment."""
76-
# Check if we are running in the SDK command line environment and use
77-
# the setup script from the SDK if so. |target_arch| should be either
78-
# 'x86' or 'x64'.
79-
asserttarget_archin ('x86', 'x64')
80-
sdk_dir=os.environ.get('WindowsSDKDir')
81-
ifself.sdk_basedandsdk_dir:
82-
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
83-
'/'+target_arch]
84-
else:
85-
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
86-
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
87-
# isn't always.
88-
iftarget_arch=='x86':
89-
ifself.short_name>='2013'andself.short_name[-1] !='e'and (
90-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
91-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
92-
# VS2013 and later, non-Express have a x64-x86 cross that we want
93-
# to prefer.
94-
return [os.path.normpath(
95-
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
96-
# Otherwise, the standard x86 compiler.
97-
return [os.path.normpath(
98-
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
84+
asserttarget_archin ('x86', 'x64'), "target_arch not supported"
85+
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
86+
# depot_tools build tools and should run SetEnv.Cmd to set up the
87+
# environment. The check for WindowsSDKDir alone is not sufficient because
88+
# this is set by running vcvarsall.bat.
89+
sdk_dir=os.environ.get('WindowsSDKDir', '')
90+
setup_path=JoinPath(sdk_dir, 'Bin', 'SetEnv.Cmd')
91+
ifself.sdk_basedandsdk_dirandos.path.exists(setup_path):
92+
return [setup_path, '/'+target_arch]
93+
94+
is_host_arch_x64= (
95+
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
96+
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'
97+
)
98+
99+
# For VS2017 (and newer) it's fairly easy
100+
ifself.short_name>='2017':
101+
script_path=JoinPath(self.path,
102+
'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
103+
104+
# Always use a native executable, cross-compiling if necessary.
105+
host_arch='amd64'ifis_host_arch_x64else'x86'
106+
msvc_target_arch='amd64'iftarget_arch=='x64'else'x86'
107+
arg=host_arch
108+
ifhost_arch!=msvc_target_arch:
109+
arg+='_'+msvc_target_arch
110+
111+
return [script_path, arg]
112+
113+
# We try to find the best version of the env setup batch.
114+
vcvarsall=JoinPath(self.path, 'VC', 'vcvarsall.bat')
115+
iftarget_arch=='x86':
116+
ifself.short_name>='2013'andself.short_name[-1] !='e'and \
117+
is_host_arch_x64:
118+
# VS2013 and later, non-Express have a x64-x86 cross that we want
119+
# to prefer.
120+
return [vcvarsall, 'amd64_x86']
99121
else:
100-
asserttarget_arch=='x64'
101-
arg='x86_amd64'
102-
# Use the 64-on-64 compiler if we're not using an express
103-
# edition and we're running on a 64bit OS.
104-
ifself.short_name[-1] !='e'and (
105-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
106-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
107-
arg='amd64'
108-
return [os.path.normpath(
109-
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
122+
# Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
123+
# for x86 because vcvarsall calls vcvars32, which it can only find if
124+
# VS??COMNTOOLS is set, which isn't guaranteed.
125+
return [JoinPath(self.path, 'Common7', 'Tools', 'vsvars32.bat')]
126+
eliftarget_arch=='x64':
127+
arg='x86_amd64'
128+
# Use the 64-on-64 compiler if we're not using an express edition and
129+
# we're running on a 64bit OS.
130+
ifself.short_name[-1] !='e'andis_host_arch_x64:
131+
arg='amd64'
132+
return [vcvarsall, arg]
133+
134+
defSetupScript(self, target_arch):
135+
script_data=self._SetupScriptInternal(target_arch)
136+
script_path=script_data[0]
137+
ifnotos.path.exists(script_path):
138+
raiseException('%s is missing - make sure VC++ tools are installed.'%
139+
script_path)
140+
returnscript_data
110141

111142

112143
def_RegistryQueryBase(sysdir, key, value):
@@ -181,11 +212,11 @@ def _RegistryGetValueUsingWinReg(key, value):
181212
ImportError if _winreg is unavailable.
182213
"""
183214
try:
184-
# Python 2
185-
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
215+
# Python 2
216+
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
186217
exceptImportError:
187-
# Python 3
188-
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
218+
# Python 3
219+
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
189220

190221
try:
191222
root, subkey=key.split('\\', 1)
@@ -236,6 +267,26 @@ def _CreateVersion(name, path, sdk_based=False):
236267
ifpath:
237268
path=os.path.normpath(path)
238269
versions= {
270+
'2019': VisualStudioVersion('2019',
271+
'Visual Studio 2019',
272+
solution_version='12.00',
273+
project_version='16.0',
274+
flat_sln=False,
275+
uses_vcxproj=True,
276+
path=path,
277+
sdk_based=sdk_based,
278+
default_toolset='v142',
279+
compatible_sdks=['v8.1', 'v10.0']),
280+
'2017': VisualStudioVersion('2017',
281+
'Visual Studio 2017',
282+
solution_version='12.00',
283+
project_version='15.0',
284+
flat_sln=False,
285+
uses_vcxproj=True,
286+
path=path,
287+
sdk_based=sdk_based,
288+
default_toolset='v141',
289+
compatible_sdks=['v8.1', 'v10.0']),
239290
'2015': VisualStudioVersion('2015',
240291
'Visual Studio 2015',
241292
solution_version='12.00',
@@ -350,14 +401,15 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
350401
A list of visual studio versions installed in descending order of
351402
usage preference.
352403
Base this on the registry and a quick check if devenv.exe exists.
353-
Only versions 8-10 are considered.
354404
Possibilities are:
355405
2005(e) - Visual Studio 2005 (8)
356406
2008(e) - Visual Studio 2008 (9)
357407
2010(e) - Visual Studio 2010 (10)
358408
2012(e) - Visual Studio 2012 (11)
359409
2013(e) - Visual Studio 2013 (12)
360410
2015 - Visual Studio 2015 (14)
411+
2017 - Visual Studio 2017 (15)
412+
2019 - Visual Studio 2019 (16)
361413
Where (e) is e for express editions of MSVS and blank otherwise.
362414
"""
363415
version_to_year= {
@@ -367,6 +419,8 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
367419
'11.0': '2012',
368420
'12.0': '2013',
369421
'14.0': '2015',
422+
'15.0': '2017',
423+
'16.0': '2019',
370424
}
371425
versions= []
372426
forversioninversions_to_check:
@@ -397,13 +451,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
397451

398452
# The old method above does not work when only SDK is installed.
399453
keys= [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
400-
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
454+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
455+
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
456+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
401457
forindexinrange(len(keys)):
402458
path=_RegistryGetValue(keys[index], version)
403459
ifnotpath:
404460
continue
405461
path=_ConvertToCygpath(path)
406-
ifversion!='14.0': # There is no Express edition for 2015.
462+
ifversion=='15.0':
463+
ifos.path.exists(path):
464+
versions.append(_CreateVersion('2017', path))
465+
elifversion!='14.0': # There is no Express edition for 2015.
407466
versions.append(_CreateVersion(version_to_year[version] +'e',
408467
os.path.join(path, '..'), sdk_based=True))
409468

@@ -422,7 +481,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422481
ifversion=='auto':
423482
version=os.environ.get('GYP_MSVS_VERSION', 'auto')
424483
version_map= {
425-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
484+
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
426485
'2005': ('8.0',),
427486
'2005e': ('8.0',),
428487
'2008': ('9.0',),
@@ -434,6 +493,8 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
434493
'2013': ('12.0',),
435494
'2013e': ('12.0',),
436495
'2015': ('14.0',),
496+
'2017': ('15.0',),
497+
'2019': ('16.0',),
437498
}
438499
override_path=os.environ.get('GYP_MSVS_OVERRIDE_PATH')
439500
ifoverride_path:

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 972780b

Browse files
authored
gyp: sync code base with nodejs repo (#1975)
PR-URL: #1975 Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent dab0305 commit 972780b

28 files changed

Lines changed: 971 additions & 390 deletions

‎gyp/AUTHORS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Ryan Norton <rnorton10@gmail.com>
1111
David J. Sankel <david@sankelsoftware.com>
1212
Eric N. Vander Weele <ericvw@gmail.com>
1313
Tom Freudenberg <th.freudenberg@gmail.com>
14+
Julien Brianceau <jbriance@cisco.com>
15+
Refael Ackermann <refack@gmail.com>

‎gyp/DEPS‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎gyp/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GYP can Generate Your Projects.
2+
===================================
3+
4+
Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check out ```md-pages``` branch to read those documents offline.

‎gyp/codereview.settings‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎gyp/pylib/gyp/MSVSNew.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importhashlib
88
importos
99
importrandom
10+
fromoperatorimportattrgetter
1011

1112
importgyp.common
1213

@@ -59,9 +60,6 @@ def __cmp__(self, other):
5960
# Sort by name then guid (so things are in order on vs2008).
6061
returncmp((self.name, self.get_guid()), (other.name, other.get_guid()))
6162

62-
def__lt__(self, other):
63-
returnself.__cmp__(other) <0
64-
6563

6664
classMSVSFolder(MSVSSolutionEntry):
6765
"""Folder in a Visual Studio project or solution."""
@@ -89,7 +87,7 @@ def __init__(self, path, name = None, entries = None,
8987
self.guid=guid
9088

9189
# Copy passed lists (or set to empty lists)
92-
self.entries=sorted(list(entriesor []))
90+
self.entries=sorted(entriesor [], key=attrgetter('path'))
9391
self.items=list(itemsor [])
9492

9593
self.entry_type_guid=ENTRY_TYPE_GUIDS['folder']
@@ -233,7 +231,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
233231
ifisinstance(e, MSVSFolder):
234232
entries_to_check+=e.entries
235233

236-
all_entries=sorted(all_entries)
234+
all_entries=sorted(all_entries, key=attrgetter('path'))
237235

238236
# Open file and print header
239237
f=writer(self.path)

‎gyp/pylib/gyp/MSVSSettings.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
467467
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
468468
exceptValueErrorase:
469469
print('Warning: while converting %s/%s to MSBuild, '
470-
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
470+
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
471471
else:
472472
_ValidateExclusionSetting(msvs_setting,
473473
msvs_tool,
@@ -477,7 +477,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
477477
stderr)
478478
else:
479479
print('Warning: unrecognized tool %s while converting to '
480-
'MSBuild.'%msvs_tool_name, file=stderr)
480+
'MSBuild.'%msvs_tool_name, file=stderr)
481481
returnmsbuild_settings
482482

483483

@@ -598,6 +598,7 @@ def _ValidateSettings(validators, settings, stderr):
598598
_Same(_compile, 'UseFullPaths', _boolean) # /FC
599599
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
600600
_Same(_compile, 'XMLDocumentationFileName', _file_name)
601+
_Same(_compile, 'CompileAsWinRT', _boolean) # /ZW
601602

602603
_Same(_compile, 'AssemblerOutput',
603604
_Enumeration(['NoListing',

‎gyp/pylib/gyp/MSVSSettings_test.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
"""Unit tests for the MSVSSettings.py file."""
88

9-
try:
10-
fromcStringIOimportStringIO
11-
exceptImportError:
12-
fromioimportStringIO
13-
149
importunittest
1510
importgyp.MSVSSettingsasMSVSSettings
1611

12+
try:
13+
fromStringIOimportStringIO# Python 2
14+
exceptImportError:
15+
fromioimportStringIO# Python 3
16+
1717

1818
classTestSequenceFunctions(unittest.TestCase):
1919

‎gyp/pylib/gyp/MSVSUtil.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'loadable_module': 'dll',
1515
'shared_library': 'dll',
1616
'static_library': 'lib',
17+
'windows_driver': 'sys',
1718
}
1819

1920

@@ -110,7 +111,7 @@ def ShardTargets(target_list, target_dicts):
110111
else:
111112
new_target_dicts[t] =target_dicts[t]
112113
# Shard dependencies.
113-
fortinnew_target_dicts:
114+
fortinsorted(new_target_dicts):
114115
fordeptypein ('dependencies', 'dependencies_original'):
115116
dependencies=copy.copy(new_target_dicts[t].get(deptype, []))
116117
new_dependencies= []

‎gyp/pylib/gyp/MSVSVersion.py‎

Lines changed: 104 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
PY3=bytes!=str
1616

1717

18+
defJoinPath(*args):
19+
returnos.path.normpath(os.path.join(*args))
20+
21+
1822
classVisualStudioVersion(object):
1923
"""Information regarding a version of Visual Studio."""
2024

2125
def__init__(self, short_name, description,
2226
solution_version, project_version, flat_sln, uses_vcxproj,
23-
path, sdk_based, default_toolset=None):
27+
path, sdk_based, default_toolset=None, compatible_sdks=None):
2428
self.short_name=short_name
2529
self.description=description
2630
self.solution_version=solution_version
@@ -30,6 +34,9 @@ def __init__(self, short_name, description,
3034
self.path=path
3135
self.sdk_based=sdk_based
3236
self.default_toolset=default_toolset
37+
compatible_sdks=compatible_sdksor []
38+
compatible_sdks.sort(key=lambdav: float(v.replace('v', '')), reverse=True)
39+
self.compatible_sdks=compatible_sdks
3340

3441
defShortName(self):
3542
returnself.short_name
@@ -70,43 +77,67 @@ def DefaultToolset(self):
7077
of a user override."""
7178
returnself.default_toolset
7279

73-
defSetupScript(self, target_arch):
80+
81+
def_SetupScriptInternal(self, target_arch):
7482
"""Returns a command (with arguments) to be used to set up the
7583
environment."""
76-
# Check if we are running in the SDK command line environment and use
77-
# the setup script from the SDK if so. |target_arch| should be either
78-
# 'x86' or 'x64'.
79-
asserttarget_archin ('x86', 'x64')
80-
sdk_dir=os.environ.get('WindowsSDKDir')
81-
ifself.sdk_basedandsdk_dir:
82-
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
83-
'/'+target_arch]
84-
else:
85-
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
86-
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
87-
# isn't always.
88-
iftarget_arch=='x86':
89-
ifself.short_name>='2013'andself.short_name[-1] !='e'and (
90-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
91-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
92-
# VS2013 and later, non-Express have a x64-x86 cross that we want
93-
# to prefer.
94-
return [os.path.normpath(
95-
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
96-
# Otherwise, the standard x86 compiler.
97-
return [os.path.normpath(
98-
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
84+
asserttarget_archin ('x86', 'x64'), "target_arch not supported"
85+
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
86+
# depot_tools build tools and should run SetEnv.Cmd to set up the
87+
# environment. The check for WindowsSDKDir alone is not sufficient because
88+
# this is set by running vcvarsall.bat.
89+
sdk_dir=os.environ.get('WindowsSDKDir', '')
90+
setup_path=JoinPath(sdk_dir, 'Bin', 'SetEnv.Cmd')
91+
ifself.sdk_basedandsdk_dirandos.path.exists(setup_path):
92+
return [setup_path, '/'+target_arch]
93+
94+
is_host_arch_x64= (
95+
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
96+
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'
97+
)
98+
99+
# For VS2017 (and newer) it's fairly easy
100+
ifself.short_name>='2017':
101+
script_path=JoinPath(self.path,
102+
'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
103+
104+
# Always use a native executable, cross-compiling if necessary.
105+
host_arch='amd64'ifis_host_arch_x64else'x86'
106+
msvc_target_arch='amd64'iftarget_arch=='x64'else'x86'
107+
arg=host_arch
108+
ifhost_arch!=msvc_target_arch:
109+
arg+='_'+msvc_target_arch
110+
111+
return [script_path, arg]
112+
113+
# We try to find the best version of the env setup batch.
114+
vcvarsall=JoinPath(self.path, 'VC', 'vcvarsall.bat')
115+
iftarget_arch=='x86':
116+
ifself.short_name>='2013'andself.short_name[-1] !='e'and \
117+
is_host_arch_x64:
118+
# VS2013 and later, non-Express have a x64-x86 cross that we want
119+
# to prefer.
120+
return [vcvarsall, 'amd64_x86']
99121
else:
100-
asserttarget_arch=='x64'
101-
arg='x86_amd64'
102-
# Use the 64-on-64 compiler if we're not using an express
103-
# edition and we're running on a 64bit OS.
104-
ifself.short_name[-1] !='e'and (
105-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
106-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
107-
arg='amd64'
108-
return [os.path.normpath(
109-
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
122+
# Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
123+
# for x86 because vcvarsall calls vcvars32, which it can only find if
124+
# VS??COMNTOOLS is set, which isn't guaranteed.
125+
return [JoinPath(self.path, 'Common7', 'Tools', 'vsvars32.bat')]
126+
eliftarget_arch=='x64':
127+
arg='x86_amd64'
128+
# Use the 64-on-64 compiler if we're not using an express edition and
129+
# we're running on a 64bit OS.
130+
ifself.short_name[-1] !='e'andis_host_arch_x64:
131+
arg='amd64'
132+
return [vcvarsall, arg]
133+
134+
defSetupScript(self, target_arch):
135+
script_data=self._SetupScriptInternal(target_arch)
136+
script_path=script_data[0]
137+
ifnotos.path.exists(script_path):
138+
raiseException('%s is missing - make sure VC++ tools are installed.'%
139+
script_path)
140+
returnscript_data
110141

111142

112143
def_RegistryQueryBase(sysdir, key, value):
@@ -181,11 +212,11 @@ def _RegistryGetValueUsingWinReg(key, value):
181212
ImportError if _winreg is unavailable.
182213
"""
183214
try:
184-
# Python 2
185-
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
215+
# Python 2
216+
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
186217
exceptImportError:
187-
# Python 3
188-
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
218+
# Python 3
219+
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
189220

190221
try:
191222
root, subkey=key.split('\\', 1)
@@ -236,6 +267,26 @@ def _CreateVersion(name, path, sdk_based=False):
236267
ifpath:
237268
path=os.path.normpath(path)
238269
versions= {
270+
'2019': VisualStudioVersion('2019',
271+
'Visual Studio 2019',
272+
solution_version='12.00',
273+
project_version='16.0',
274+
flat_sln=False,
275+
uses_vcxproj=True,
276+
path=path,
277+
sdk_based=sdk_based,
278+
default_toolset='v142',
279+
compatible_sdks=['v8.1', 'v10.0']),
280+
'2017': VisualStudioVersion('2017',
281+
'Visual Studio 2017',
282+
solution_version='12.00',
283+
project_version='15.0',
284+
flat_sln=False,
285+
uses_vcxproj=True,
286+
path=path,
287+
sdk_based=sdk_based,
288+
default_toolset='v141',
289+
compatible_sdks=['v8.1', 'v10.0']),
239290
'2015': VisualStudioVersion('2015',
240291
'Visual Studio 2015',
241292
solution_version='12.00',
@@ -350,14 +401,15 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
350401
A list of visual studio versions installed in descending order of
351402
usage preference.
352403
Base this on the registry and a quick check if devenv.exe exists.
353-
Only versions 8-10 are considered.
354404
Possibilities are:
355405
2005(e) - Visual Studio 2005 (8)
356406
2008(e) - Visual Studio 2008 (9)
357407
2010(e) - Visual Studio 2010 (10)
358408
2012(e) - Visual Studio 2012 (11)
359409
2013(e) - Visual Studio 2013 (12)
360410
2015 - Visual Studio 2015 (14)
411+
2017 - Visual Studio 2017 (15)
412+
2019 - Visual Studio 2019 (16)
361413
Where (e) is e for express editions of MSVS and blank otherwise.
362414
"""
363415
version_to_year= {
@@ -367,6 +419,8 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
367419
'11.0': '2012',
368420
'12.0': '2013',
369421
'14.0': '2015',
422+
'15.0': '2017',
423+
'16.0': '2019',
370424
}
371425
versions= []
372426
forversioninversions_to_check:
@@ -397,13 +451,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
397451

398452
# The old method above does not work when only SDK is installed.
399453
keys= [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
400-
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
454+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
455+
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
456+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
401457
forindexinrange(len(keys)):
402458
path=_RegistryGetValue(keys[index], version)
403459
ifnotpath:
404460
continue
405461
path=_ConvertToCygpath(path)
406-
ifversion!='14.0': # There is no Express edition for 2015.
462+
ifversion=='15.0':
463+
ifos.path.exists(path):
464+
versions.append(_CreateVersion('2017', path))
465+
elifversion!='14.0': # There is no Express edition for 2015.
407466
versions.append(_CreateVersion(version_to_year[version] +'e',
408467
os.path.join(path, '..'), sdk_based=True))
409468

@@ -422,7 +481,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422481
ifversion=='auto':
423482
version=os.environ.get('GYP_MSVS_VERSION', 'auto')
424483
version_map= {
425-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
484+
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
426485
'2005': ('8.0',),
427486
'2005e': ('8.0',),
428487
'2008': ('9.0',),
@@ -434,6 +493,8 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
434493
'2013': ('12.0',),
435494
'2013e': ('12.0',),
436495
'2015': ('14.0',),
496+
'2017': ('15.0',),
497+
'2019': ('16.0',),
437498
}
438499
override_path=os.environ.get('GYP_MSVS_OVERRIDE_PATH')
439500
ifoverride_path:

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 972780b

Browse files
authored
gyp: sync code base with nodejs repo (#1975)
PR-URL: #1975 Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent dab0305 commit 972780b

28 files changed

Lines changed: 971 additions & 390 deletions

‎gyp/AUTHORS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Ryan Norton <rnorton10@gmail.com>
1111
David J. Sankel <david@sankelsoftware.com>
1212
Eric N. Vander Weele <ericvw@gmail.com>
1313
Tom Freudenberg <th.freudenberg@gmail.com>
14+
Julien Brianceau <jbriance@cisco.com>
15+
Refael Ackermann <refack@gmail.com>

‎gyp/DEPS‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎gyp/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GYP can Generate Your Projects.
2+
===================================
3+
4+
Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check out ```md-pages``` branch to read those documents offline.

‎gyp/codereview.settings‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎gyp/pylib/gyp/MSVSNew.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importhashlib
88
importos
99
importrandom
10+
fromoperatorimportattrgetter
1011

1112
importgyp.common
1213

@@ -59,9 +60,6 @@ def __cmp__(self, other):
5960
# Sort by name then guid (so things are in order on vs2008).
6061
returncmp((self.name, self.get_guid()), (other.name, other.get_guid()))
6162

62-
def__lt__(self, other):
63-
returnself.__cmp__(other) <0
64-
6563

6664
classMSVSFolder(MSVSSolutionEntry):
6765
"""Folder in a Visual Studio project or solution."""
@@ -89,7 +87,7 @@ def __init__(self, path, name = None, entries = None,
8987
self.guid=guid
9088

9189
# Copy passed lists (or set to empty lists)
92-
self.entries=sorted(list(entriesor []))
90+
self.entries=sorted(entriesor [], key=attrgetter('path'))
9391
self.items=list(itemsor [])
9492

9593
self.entry_type_guid=ENTRY_TYPE_GUIDS['folder']
@@ -233,7 +231,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
233231
ifisinstance(e, MSVSFolder):
234232
entries_to_check+=e.entries
235233

236-
all_entries=sorted(all_entries)
234+
all_entries=sorted(all_entries, key=attrgetter('path'))
237235

238236
# Open file and print header
239237
f=writer(self.path)

‎gyp/pylib/gyp/MSVSSettings.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
467467
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
468468
exceptValueErrorase:
469469
print('Warning: while converting %s/%s to MSBuild, '
470-
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
470+
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
471471
else:
472472
_ValidateExclusionSetting(msvs_setting,
473473
msvs_tool,
@@ -477,7 +477,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
477477
stderr)
478478
else:
479479
print('Warning: unrecognized tool %s while converting to '
480-
'MSBuild.'%msvs_tool_name, file=stderr)
480+
'MSBuild.'%msvs_tool_name, file=stderr)
481481
returnmsbuild_settings
482482

483483

@@ -598,6 +598,7 @@ def _ValidateSettings(validators, settings, stderr):
598598
_Same(_compile, 'UseFullPaths', _boolean) # /FC
599599
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
600600
_Same(_compile, 'XMLDocumentationFileName', _file_name)
601+
_Same(_compile, 'CompileAsWinRT', _boolean) # /ZW
601602

602603
_Same(_compile, 'AssemblerOutput',
603604
_Enumeration(['NoListing',

‎gyp/pylib/gyp/MSVSSettings_test.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
"""Unit tests for the MSVSSettings.py file."""
88

9-
try:
10-
fromcStringIOimportStringIO
11-
exceptImportError:
12-
fromioimportStringIO
13-
149
importunittest
1510
importgyp.MSVSSettingsasMSVSSettings
1611

12+
try:
13+
fromStringIOimportStringIO# Python 2
14+
exceptImportError:
15+
fromioimportStringIO# Python 3
16+
1717

1818
classTestSequenceFunctions(unittest.TestCase):
1919

‎gyp/pylib/gyp/MSVSUtil.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'loadable_module': 'dll',
1515
'shared_library': 'dll',
1616
'static_library': 'lib',
17+
'windows_driver': 'sys',
1718
}
1819

1920

@@ -110,7 +111,7 @@ def ShardTargets(target_list, target_dicts):
110111
else:
111112
new_target_dicts[t] =target_dicts[t]
112113
# Shard dependencies.
113-
fortinnew_target_dicts:
114+
fortinsorted(new_target_dicts):
114115
fordeptypein ('dependencies', 'dependencies_original'):
115116
dependencies=copy.copy(new_target_dicts[t].get(deptype, []))
116117
new_dependencies= []

‎gyp/pylib/gyp/MSVSVersion.py‎

Lines changed: 104 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
PY3=bytes!=str
1616

1717

18+
defJoinPath(*args):
19+
returnos.path.normpath(os.path.join(*args))
20+
21+
1822
classVisualStudioVersion(object):
1923
"""Information regarding a version of Visual Studio."""
2024

2125
def__init__(self, short_name, description,
2226
solution_version, project_version, flat_sln, uses_vcxproj,
23-
path, sdk_based, default_toolset=None):
27+
path, sdk_based, default_toolset=None, compatible_sdks=None):
2428
self.short_name=short_name
2529
self.description=description
2630
self.solution_version=solution_version
@@ -30,6 +34,9 @@ def __init__(self, short_name, description,
3034
self.path=path
3135
self.sdk_based=sdk_based
3236
self.default_toolset=default_toolset
37+
compatible_sdks=compatible_sdksor []
38+
compatible_sdks.sort(key=lambdav: float(v.replace('v', '')), reverse=True)
39+
self.compatible_sdks=compatible_sdks
3340

3441
defShortName(self):
3542
returnself.short_name
@@ -70,43 +77,67 @@ def DefaultToolset(self):
7077
of a user override."""
7178
returnself.default_toolset
7279

73-
defSetupScript(self, target_arch):
80+
81+
def_SetupScriptInternal(self, target_arch):
7482
"""Returns a command (with arguments) to be used to set up the
7583
environment."""
76-
# Check if we are running in the SDK command line environment and use
77-
# the setup script from the SDK if so. |target_arch| should be either
78-
# 'x86' or 'x64'.
79-
asserttarget_archin ('x86', 'x64')
80-
sdk_dir=os.environ.get('WindowsSDKDir')
81-
ifself.sdk_basedandsdk_dir:
82-
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
83-
'/'+target_arch]
84-
else:
85-
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
86-
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
87-
# isn't always.
88-
iftarget_arch=='x86':
89-
ifself.short_name>='2013'andself.short_name[-1] !='e'and (
90-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
91-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
92-
# VS2013 and later, non-Express have a x64-x86 cross that we want
93-
# to prefer.
94-
return [os.path.normpath(
95-
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
96-
# Otherwise, the standard x86 compiler.
97-
return [os.path.normpath(
98-
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
84+
asserttarget_archin ('x86', 'x64'), "target_arch not supported"
85+
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
86+
# depot_tools build tools and should run SetEnv.Cmd to set up the
87+
# environment. The check for WindowsSDKDir alone is not sufficient because
88+
# this is set by running vcvarsall.bat.
89+
sdk_dir=os.environ.get('WindowsSDKDir', '')
90+
setup_path=JoinPath(sdk_dir, 'Bin', 'SetEnv.Cmd')
91+
ifself.sdk_basedandsdk_dirandos.path.exists(setup_path):
92+
return [setup_path, '/'+target_arch]
93+
94+
is_host_arch_x64= (
95+
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
96+
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'
97+
)
98+
99+
# For VS2017 (and newer) it's fairly easy
100+
ifself.short_name>='2017':
101+
script_path=JoinPath(self.path,
102+
'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
103+
104+
# Always use a native executable, cross-compiling if necessary.
105+
host_arch='amd64'ifis_host_arch_x64else'x86'
106+
msvc_target_arch='amd64'iftarget_arch=='x64'else'x86'
107+
arg=host_arch
108+
ifhost_arch!=msvc_target_arch:
109+
arg+='_'+msvc_target_arch
110+
111+
return [script_path, arg]
112+
113+
# We try to find the best version of the env setup batch.
114+
vcvarsall=JoinPath(self.path, 'VC', 'vcvarsall.bat')
115+
iftarget_arch=='x86':
116+
ifself.short_name>='2013'andself.short_name[-1] !='e'and \
117+
is_host_arch_x64:
118+
# VS2013 and later, non-Express have a x64-x86 cross that we want
119+
# to prefer.
120+
return [vcvarsall, 'amd64_x86']
99121
else:
100-
asserttarget_arch=='x64'
101-
arg='x86_amd64'
102-
# Use the 64-on-64 compiler if we're not using an express
103-
# edition and we're running on a 64bit OS.
104-
ifself.short_name[-1] !='e'and (
105-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
106-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
107-
arg='amd64'
108-
return [os.path.normpath(
109-
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
122+
# Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
123+
# for x86 because vcvarsall calls vcvars32, which it can only find if
124+
# VS??COMNTOOLS is set, which isn't guaranteed.
125+
return [JoinPath(self.path, 'Common7', 'Tools', 'vsvars32.bat')]
126+
eliftarget_arch=='x64':
127+
arg='x86_amd64'
128+
# Use the 64-on-64 compiler if we're not using an express edition and
129+
# we're running on a 64bit OS.
130+
ifself.short_name[-1] !='e'andis_host_arch_x64:
131+
arg='amd64'
132+
return [vcvarsall, arg]
133+
134+
defSetupScript(self, target_arch):
135+
script_data=self._SetupScriptInternal(target_arch)
136+
script_path=script_data[0]
137+
ifnotos.path.exists(script_path):
138+
raiseException('%s is missing - make sure VC++ tools are installed.'%
139+
script_path)
140+
returnscript_data
110141

111142

112143
def_RegistryQueryBase(sysdir, key, value):
@@ -181,11 +212,11 @@ def _RegistryGetValueUsingWinReg(key, value):
181212
ImportError if _winreg is unavailable.
182213
"""
183214
try:
184-
# Python 2
185-
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
215+
# Python 2
216+
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
186217
exceptImportError:
187-
# Python 3
188-
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
218+
# Python 3
219+
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
189220

190221
try:
191222
root, subkey=key.split('\\', 1)
@@ -236,6 +267,26 @@ def _CreateVersion(name, path, sdk_based=False):
236267
ifpath:
237268
path=os.path.normpath(path)
238269
versions= {
270+
'2019': VisualStudioVersion('2019',
271+
'Visual Studio 2019',
272+
solution_version='12.00',
273+
project_version='16.0',
274+
flat_sln=False,
275+
uses_vcxproj=True,
276+
path=path,
277+
sdk_based=sdk_based,
278+
default_toolset='v142',
279+
compatible_sdks=['v8.1', 'v10.0']),
280+
'2017': VisualStudioVersion('2017',
281+
'Visual Studio 2017',
282+
solution_version='12.00',
283+
project_version='15.0',
284+
flat_sln=False,
285+
uses_vcxproj=True,
286+
path=path,
287+
sdk_based=sdk_based,
288+
default_toolset='v141',
289+
compatible_sdks=['v8.1', 'v10.0']),
239290
'2015': VisualStudioVersion('2015',
240291
'Visual Studio 2015',
241292
solution_version='12.00',
@@ -350,14 +401,15 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
350401
A list of visual studio versions installed in descending order of
351402
usage preference.
352403
Base this on the registry and a quick check if devenv.exe exists.
353-
Only versions 8-10 are considered.
354404
Possibilities are:
355405
2005(e) - Visual Studio 2005 (8)
356406
2008(e) - Visual Studio 2008 (9)
357407
2010(e) - Visual Studio 2010 (10)
358408
2012(e) - Visual Studio 2012 (11)
359409
2013(e) - Visual Studio 2013 (12)
360410
2015 - Visual Studio 2015 (14)
411+
2017 - Visual Studio 2017 (15)
412+
2019 - Visual Studio 2019 (16)
361413
Where (e) is e for express editions of MSVS and blank otherwise.
362414
"""
363415
version_to_year= {
@@ -367,6 +419,8 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
367419
'11.0': '2012',
368420
'12.0': '2013',
369421
'14.0': '2015',
422+
'15.0': '2017',
423+
'16.0': '2019',
370424
}
371425
versions= []
372426
forversioninversions_to_check:
@@ -397,13 +451,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
397451

398452
# The old method above does not work when only SDK is installed.
399453
keys= [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
400-
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
454+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
455+
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
456+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
401457
forindexinrange(len(keys)):
402458
path=_RegistryGetValue(keys[index], version)
403459
ifnotpath:
404460
continue
405461
path=_ConvertToCygpath(path)
406-
ifversion!='14.0': # There is no Express edition for 2015.
462+
ifversion=='15.0':
463+
ifos.path.exists(path):
464+
versions.append(_CreateVersion('2017', path))
465+
elifversion!='14.0': # There is no Express edition for 2015.
407466
versions.append(_CreateVersion(version_to_year[version] +'e',
408467
os.path.join(path, '..'), sdk_based=True))
409468

@@ -422,7 +481,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422481
ifversion=='auto':
423482
version=os.environ.get('GYP_MSVS_VERSION', 'auto')
424483
version_map= {
425-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
484+
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
426485
'2005': ('8.0',),
427486
'2005e': ('8.0',),
428487
'2008': ('9.0',),
@@ -434,6 +493,8 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
434493
'2013': ('12.0',),
435494
'2013e': ('12.0',),
436495
'2015': ('14.0',),
496+
'2017': ('15.0',),
497+
'2019': ('16.0',),
437498
}
438499
override_path=os.environ.get('GYP_MSVS_OVERRIDE_PATH')
439500
ifoverride_path:

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Commit 972780b

Browse files
authored
gyp: sync code base with nodejs repo (#1975)
PR-URL: #1975 Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent dab0305 commit 972780b

28 files changed

Lines changed: 971 additions & 390 deletions

‎gyp/AUTHORS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Ryan Norton <rnorton10@gmail.com>
1111
David J. Sankel <david@sankelsoftware.com>
1212
Eric N. Vander Weele <ericvw@gmail.com>
1313
Tom Freudenberg <th.freudenberg@gmail.com>
14+
Julien Brianceau <jbriance@cisco.com>
15+
Refael Ackermann <refack@gmail.com>

‎gyp/DEPS‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎gyp/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GYP can Generate Your Projects.
2+
===================================
3+
4+
Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check out ```md-pages``` branch to read those documents offline.

‎gyp/codereview.settings‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎gyp/pylib/gyp/MSVSNew.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importhashlib
88
importos
99
importrandom
10+
fromoperatorimportattrgetter
1011

1112
importgyp.common
1213

@@ -59,9 +60,6 @@ def __cmp__(self, other):
5960
# Sort by name then guid (so things are in order on vs2008).
6061
returncmp((self.name, self.get_guid()), (other.name, other.get_guid()))
6162

62-
def__lt__(self, other):
63-
returnself.__cmp__(other) <0
64-
6563

6664
classMSVSFolder(MSVSSolutionEntry):
6765
"""Folder in a Visual Studio project or solution."""
@@ -89,7 +87,7 @@ def __init__(self, path, name = None, entries = None,
8987
self.guid=guid
9088

9189
# Copy passed lists (or set to empty lists)
92-
self.entries=sorted(list(entriesor []))
90+
self.entries=sorted(entriesor [], key=attrgetter('path'))
9391
self.items=list(itemsor [])
9492

9593
self.entry_type_guid=ENTRY_TYPE_GUIDS['folder']
@@ -233,7 +231,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
233231
ifisinstance(e, MSVSFolder):
234232
entries_to_check+=e.entries
235233

236-
all_entries=sorted(all_entries)
234+
all_entries=sorted(all_entries, key=attrgetter('path'))
237235

238236
# Open file and print header
239237
f=writer(self.path)

‎gyp/pylib/gyp/MSVSSettings.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
467467
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
468468
exceptValueErrorase:
469469
print('Warning: while converting %s/%s to MSBuild, '
470-
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
470+
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
471471
else:
472472
_ValidateExclusionSetting(msvs_setting,
473473
msvs_tool,
@@ -477,7 +477,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
477477
stderr)
478478
else:
479479
print('Warning: unrecognized tool %s while converting to '
480-
'MSBuild.'%msvs_tool_name, file=stderr)
480+
'MSBuild.'%msvs_tool_name, file=stderr)
481481
returnmsbuild_settings
482482

483483

@@ -598,6 +598,7 @@ def _ValidateSettings(validators, settings, stderr):
598598
_Same(_compile, 'UseFullPaths', _boolean) # /FC
599599
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
600600
_Same(_compile, 'XMLDocumentationFileName', _file_name)
601+
_Same(_compile, 'CompileAsWinRT', _boolean) # /ZW
601602

602603
_Same(_compile, 'AssemblerOutput',
603604
_Enumeration(['NoListing',

‎gyp/pylib/gyp/MSVSSettings_test.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
"""Unit tests for the MSVSSettings.py file."""
88

9-
try:
10-
fromcStringIOimportStringIO
11-
exceptImportError:
12-
fromioimportStringIO
13-
149
importunittest
1510
importgyp.MSVSSettingsasMSVSSettings
1611

12+
try:
13+
fromStringIOimportStringIO# Python 2
14+
exceptImportError:
15+
fromioimportStringIO# Python 3
16+
1717

1818
classTestSequenceFunctions(unittest.TestCase):
1919

‎gyp/pylib/gyp/MSVSUtil.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'loadable_module': 'dll',
1515
'shared_library': 'dll',
1616
'static_library': 'lib',
17+
'windows_driver': 'sys',
1718
}
1819

1920

@@ -110,7 +111,7 @@ def ShardTargets(target_list, target_dicts):
110111
else:
111112
new_target_dicts[t] =target_dicts[t]
112113
# Shard dependencies.
113-
fortinnew_target_dicts:
114+
fortinsorted(new_target_dicts):
114115
fordeptypein ('dependencies', 'dependencies_original'):
115116
dependencies=copy.copy(new_target_dicts[t].get(deptype, []))
116117
new_dependencies= []

‎gyp/pylib/gyp/MSVSVersion.py‎

Lines changed: 104 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
PY3=bytes!=str
1616

1717

18+
defJoinPath(*args):
19+
returnos.path.normpath(os.path.join(*args))
20+
21+
1822
classVisualStudioVersion(object):
1923
"""Information regarding a version of Visual Studio."""
2024

2125
def__init__(self, short_name, description,
2226
solution_version, project_version, flat_sln, uses_vcxproj,
23-
path, sdk_based, default_toolset=None):
27+
path, sdk_based, default_toolset=None, compatible_sdks=None):
2428
self.short_name=short_name
2529
self.description=description
2630
self.solution_version=solution_version
@@ -30,6 +34,9 @@ def __init__(self, short_name, description,
3034
self.path=path
3135
self.sdk_based=sdk_based
3236
self.default_toolset=default_toolset
37+
compatible_sdks=compatible_sdksor []
38+
compatible_sdks.sort(key=lambdav: float(v.replace('v', '')), reverse=True)
39+
self.compatible_sdks=compatible_sdks
3340

3441
defShortName(self):
3542
returnself.short_name
@@ -70,43 +77,67 @@ def DefaultToolset(self):
7077
of a user override."""
7178
returnself.default_toolset
7279

73-
defSetupScript(self, target_arch):
80+
81+
def_SetupScriptInternal(self, target_arch):
7482
"""Returns a command (with arguments) to be used to set up the
7583
environment."""
76-
# Check if we are running in the SDK command line environment and use
77-
# the setup script from the SDK if so. |target_arch| should be either
78-
# 'x86' or 'x64'.
79-
asserttarget_archin ('x86', 'x64')
80-
sdk_dir=os.environ.get('WindowsSDKDir')
81-
ifself.sdk_basedandsdk_dir:
82-
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
83-
'/'+target_arch]
84-
else:
85-
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
86-
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
87-
# isn't always.
88-
iftarget_arch=='x86':
89-
ifself.short_name>='2013'andself.short_name[-1] !='e'and (
90-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
91-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
92-
# VS2013 and later, non-Express have a x64-x86 cross that we want
93-
# to prefer.
94-
return [os.path.normpath(
95-
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
96-
# Otherwise, the standard x86 compiler.
97-
return [os.path.normpath(
98-
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
84+
asserttarget_archin ('x86', 'x64'), "target_arch not supported"
85+
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
86+
# depot_tools build tools and should run SetEnv.Cmd to set up the
87+
# environment. The check for WindowsSDKDir alone is not sufficient because
88+
# this is set by running vcvarsall.bat.
89+
sdk_dir=os.environ.get('WindowsSDKDir', '')
90+
setup_path=JoinPath(sdk_dir, 'Bin', 'SetEnv.Cmd')
91+
ifself.sdk_basedandsdk_dirandos.path.exists(setup_path):
92+
return [setup_path, '/'+target_arch]
93+
94+
is_host_arch_x64= (
95+
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
96+
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'
97+
)
98+
99+
# For VS2017 (and newer) it's fairly easy
100+
ifself.short_name>='2017':
101+
script_path=JoinPath(self.path,
102+
'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
103+
104+
# Always use a native executable, cross-compiling if necessary.
105+
host_arch='amd64'ifis_host_arch_x64else'x86'
106+
msvc_target_arch='amd64'iftarget_arch=='x64'else'x86'
107+
arg=host_arch
108+
ifhost_arch!=msvc_target_arch:
109+
arg+='_'+msvc_target_arch
110+
111+
return [script_path, arg]
112+
113+
# We try to find the best version of the env setup batch.
114+
vcvarsall=JoinPath(self.path, 'VC', 'vcvarsall.bat')
115+
iftarget_arch=='x86':
116+
ifself.short_name>='2013'andself.short_name[-1] !='e'and \
117+
is_host_arch_x64:
118+
# VS2013 and later, non-Express have a x64-x86 cross that we want
119+
# to prefer.
120+
return [vcvarsall, 'amd64_x86']
99121
else:
100-
asserttarget_arch=='x64'
101-
arg='x86_amd64'
102-
# Use the 64-on-64 compiler if we're not using an express
103-
# edition and we're running on a 64bit OS.
104-
ifself.short_name[-1] !='e'and (
105-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
106-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
107-
arg='amd64'
108-
return [os.path.normpath(
109-
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
122+
# Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
123+
# for x86 because vcvarsall calls vcvars32, which it can only find if
124+
# VS??COMNTOOLS is set, which isn't guaranteed.
125+
return [JoinPath(self.path, 'Common7', 'Tools', 'vsvars32.bat')]
126+
eliftarget_arch=='x64':
127+
arg='x86_amd64'
128+
# Use the 64-on-64 compiler if we're not using an express edition and
129+
# we're running on a 64bit OS.
130+
ifself.short_name[-1] !='e'andis_host_arch_x64:
131+
arg='amd64'
132+
return [vcvarsall, arg]
133+
134+
defSetupScript(self, target_arch):
135+
script_data=self._SetupScriptInternal(target_arch)
136+
script_path=script_data[0]
137+
ifnotos.path.exists(script_path):
138+
raiseException('%s is missing - make sure VC++ tools are installed.'%
139+
script_path)
140+
returnscript_data
110141

111142

112143
def_RegistryQueryBase(sysdir, key, value):
@@ -181,11 +212,11 @@ def _RegistryGetValueUsingWinReg(key, value):
181212
ImportError if _winreg is unavailable.
182213
"""
183214
try:
184-
# Python 2
185-
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
215+
# Python 2
216+
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
186217
exceptImportError:
187-
# Python 3
188-
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
218+
# Python 3
219+
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
189220

190221
try:
191222
root, subkey=key.split('\\', 1)
@@ -236,6 +267,26 @@ def _CreateVersion(name, path, sdk_based=False):
236267
ifpath:
237268
path=os.path.normpath(path)
238269
versions= {
270+
'2019': VisualStudioVersion('2019',
271+
'Visual Studio 2019',
272+
solution_version='12.00',
273+
project_version='16.0',
274+
flat_sln=False,
275+
uses_vcxproj=True,
276+
path=path,
277+
sdk_based=sdk_based,
278+
default_toolset='v142',
279+
compatible_sdks=['v8.1', 'v10.0']),
280+
'2017': VisualStudioVersion('2017',
281+
'Visual Studio 2017',
282+
solution_version='12.00',
283+
project_version='15.0',
284+
flat_sln=False,
285+
uses_vcxproj=True,
286+
path=path,
287+
sdk_based=sdk_based,
288+
default_toolset='v141',
289+
compatible_sdks=['v8.1', 'v10.0']),
239290
'2015': VisualStudioVersion('2015',
240291
'Visual Studio 2015',
241292
solution_version='12.00',
@@ -350,14 +401,15 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
350401
A list of visual studio versions installed in descending order of
351402
usage preference.
352403
Base this on the registry and a quick check if devenv.exe exists.
353-
Only versions 8-10 are considered.
354404
Possibilities are:
355405
2005(e) - Visual Studio 2005 (8)
356406
2008(e) - Visual Studio 2008 (9)
357407
2010(e) - Visual Studio 2010 (10)
358408
2012(e) - Visual Studio 2012 (11)
359409
2013(e) - Visual Studio 2013 (12)
360410
2015 - Visual Studio 2015 (14)
411+
2017 - Visual Studio 2017 (15)
412+
2019 - Visual Studio 2019 (16)
361413
Where (e) is e for express editions of MSVS and blank otherwise.
362414
"""
363415
version_to_year= {
@@ -367,6 +419,8 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
367419
'11.0': '2012',
368420
'12.0': '2013',
369421
'14.0': '2015',
422+
'15.0': '2017',
423+
'16.0': '2019',
370424
}
371425
versions= []
372426
forversioninversions_to_check:
@@ -397,13 +451,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
397451

398452
# The old method above does not work when only SDK is installed.
399453
keys= [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
400-
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
454+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
455+
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
456+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
401457
forindexinrange(len(keys)):
402458
path=_RegistryGetValue(keys[index], version)
403459
ifnotpath:
404460
continue
405461
path=_ConvertToCygpath(path)
406-
ifversion!='14.0': # There is no Express edition for 2015.
462+
ifversion=='15.0':
463+
ifos.path.exists(path):
464+
versions.append(_CreateVersion('2017', path))
465+
elifversion!='14.0': # There is no Express edition for 2015.
407466
versions.append(_CreateVersion(version_to_year[version] +'e',
408467
os.path.join(path, '..'), sdk_based=True))
409468

@@ -422,7 +481,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422481
ifversion=='auto':
423482
version=os.environ.get('GYP_MSVS_VERSION', 'auto')
424483
version_map= {
425-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
484+
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
426485
'2005': ('8.0',),
427486
'2005e': ('8.0',),
428487
'2008': ('9.0',),
@@ -434,6 +493,8 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
434493
'2013': ('12.0',),
435494
'2013e': ('12.0',),
436495
'2015': ('14.0',),
496+
'2017': ('15.0',),
497+
'2019': ('16.0',),
437498
}
438499
override_path=os.environ.get('GYP_MSVS_OVERRIDE_PATH')
439500
ifoverride_path:

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 972780b

Browse files
authored
gyp: sync code base with nodejs repo (#1975)
PR-URL: #1975 Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent dab0305 commit 972780b

28 files changed

Lines changed: 971 additions & 390 deletions

‎gyp/AUTHORS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Ryan Norton <rnorton10@gmail.com>
1111
David J. Sankel <david@sankelsoftware.com>
1212
Eric N. Vander Weele <ericvw@gmail.com>
1313
Tom Freudenberg <th.freudenberg@gmail.com>
14+
Julien Brianceau <jbriance@cisco.com>
15+
Refael Ackermann <refack@gmail.com>

‎gyp/DEPS‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎gyp/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GYP can Generate Your Projects.
2+
===================================
3+
4+
Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check out ```md-pages``` branch to read those documents offline.

‎gyp/codereview.settings‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎gyp/pylib/gyp/MSVSNew.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importhashlib
88
importos
99
importrandom
10+
fromoperatorimportattrgetter
1011

1112
importgyp.common
1213

@@ -59,9 +60,6 @@ def __cmp__(self, other):
5960
# Sort by name then guid (so things are in order on vs2008).
6061
returncmp((self.name, self.get_guid()), (other.name, other.get_guid()))
6162

62-
def__lt__(self, other):
63-
returnself.__cmp__(other) <0
64-
6563

6664
classMSVSFolder(MSVSSolutionEntry):
6765
"""Folder in a Visual Studio project or solution."""
@@ -89,7 +87,7 @@ def __init__(self, path, name = None, entries = None,
8987
self.guid=guid
9088

9189
# Copy passed lists (or set to empty lists)
92-
self.entries=sorted(list(entriesor []))
90+
self.entries=sorted(entriesor [], key=attrgetter('path'))
9391
self.items=list(itemsor [])
9492

9593
self.entry_type_guid=ENTRY_TYPE_GUIDS['folder']
@@ -233,7 +231,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
233231
ifisinstance(e, MSVSFolder):
234232
entries_to_check+=e.entries
235233

236-
all_entries=sorted(all_entries)
234+
all_entries=sorted(all_entries, key=attrgetter('path'))
237235

238236
# Open file and print header
239237
f=writer(self.path)

‎gyp/pylib/gyp/MSVSSettings.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
467467
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
468468
exceptValueErrorase:
469469
print('Warning: while converting %s/%s to MSBuild, '
470-
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
470+
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
471471
else:
472472
_ValidateExclusionSetting(msvs_setting,
473473
msvs_tool,
@@ -477,7 +477,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
477477
stderr)
478478
else:
479479
print('Warning: unrecognized tool %s while converting to '
480-
'MSBuild.'%msvs_tool_name, file=stderr)
480+
'MSBuild.'%msvs_tool_name, file=stderr)
481481
returnmsbuild_settings
482482

483483

@@ -598,6 +598,7 @@ def _ValidateSettings(validators, settings, stderr):
598598
_Same(_compile, 'UseFullPaths', _boolean) # /FC
599599
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
600600
_Same(_compile, 'XMLDocumentationFileName', _file_name)
601+
_Same(_compile, 'CompileAsWinRT', _boolean) # /ZW
601602

602603
_Same(_compile, 'AssemblerOutput',
603604
_Enumeration(['NoListing',

‎gyp/pylib/gyp/MSVSSettings_test.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
"""Unit tests for the MSVSSettings.py file."""
88

9-
try:
10-
fromcStringIOimportStringIO
11-
exceptImportError:
12-
fromioimportStringIO
13-
149
importunittest
1510
importgyp.MSVSSettingsasMSVSSettings
1611

12+
try:
13+
fromStringIOimportStringIO# Python 2
14+
exceptImportError:
15+
fromioimportStringIO# Python 3
16+
1717

1818
classTestSequenceFunctions(unittest.TestCase):
1919

‎gyp/pylib/gyp/MSVSUtil.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'loadable_module': 'dll',
1515
'shared_library': 'dll',
1616
'static_library': 'lib',
17+
'windows_driver': 'sys',
1718
}
1819

1920

@@ -110,7 +111,7 @@ def ShardTargets(target_list, target_dicts):
110111
else:
111112
new_target_dicts[t] =target_dicts[t]
112113
# Shard dependencies.
113-
fortinnew_target_dicts:
114+
fortinsorted(new_target_dicts):
114115
fordeptypein ('dependencies', 'dependencies_original'):
115116
dependencies=copy.copy(new_target_dicts[t].get(deptype, []))
116117
new_dependencies= []

‎gyp/pylib/gyp/MSVSVersion.py‎

Lines changed: 104 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
PY3=bytes!=str
1616

1717

18+
defJoinPath(*args):
19+
returnos.path.normpath(os.path.join(*args))
20+
21+
1822
classVisualStudioVersion(object):
1923
"""Information regarding a version of Visual Studio."""
2024

2125
def__init__(self, short_name, description,
2226
solution_version, project_version, flat_sln, uses_vcxproj,
23-
path, sdk_based, default_toolset=None):
27+
path, sdk_based, default_toolset=None, compatible_sdks=None):
2428
self.short_name=short_name
2529
self.description=description
2630
self.solution_version=solution_version
@@ -30,6 +34,9 @@ def __init__(self, short_name, description,
3034
self.path=path
3135
self.sdk_based=sdk_based
3236
self.default_toolset=default_toolset
37+
compatible_sdks=compatible_sdksor []
38+
compatible_sdks.sort(key=lambdav: float(v.replace('v', '')), reverse=True)
39+
self.compatible_sdks=compatible_sdks
3340

3441
defShortName(self):
3542
returnself.short_name
@@ -70,43 +77,67 @@ def DefaultToolset(self):
7077
of a user override."""
7178
returnself.default_toolset
7279

73-
defSetupScript(self, target_arch):
80+
81+
def_SetupScriptInternal(self, target_arch):
7482
"""Returns a command (with arguments) to be used to set up the
7583
environment."""
76-
# Check if we are running in the SDK command line environment and use
77-
# the setup script from the SDK if so. |target_arch| should be either
78-
# 'x86' or 'x64'.
79-
asserttarget_archin ('x86', 'x64')
80-
sdk_dir=os.environ.get('WindowsSDKDir')
81-
ifself.sdk_basedandsdk_dir:
82-
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
83-
'/'+target_arch]
84-
else:
85-
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
86-
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
87-
# isn't always.
88-
iftarget_arch=='x86':
89-
ifself.short_name>='2013'andself.short_name[-1] !='e'and (
90-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
91-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
92-
# VS2013 and later, non-Express have a x64-x86 cross that we want
93-
# to prefer.
94-
return [os.path.normpath(
95-
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
96-
# Otherwise, the standard x86 compiler.
97-
return [os.path.normpath(
98-
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
84+
asserttarget_archin ('x86', 'x64'), "target_arch not supported"
85+
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
86+
# depot_tools build tools and should run SetEnv.Cmd to set up the
87+
# environment. The check for WindowsSDKDir alone is not sufficient because
88+
# this is set by running vcvarsall.bat.
89+
sdk_dir=os.environ.get('WindowsSDKDir', '')
90+
setup_path=JoinPath(sdk_dir, 'Bin', 'SetEnv.Cmd')
91+
ifself.sdk_basedandsdk_dirandos.path.exists(setup_path):
92+
return [setup_path, '/'+target_arch]
93+
94+
is_host_arch_x64= (
95+
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
96+
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'
97+
)
98+
99+
# For VS2017 (and newer) it's fairly easy
100+
ifself.short_name>='2017':
101+
script_path=JoinPath(self.path,
102+
'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
103+
104+
# Always use a native executable, cross-compiling if necessary.
105+
host_arch='amd64'ifis_host_arch_x64else'x86'
106+
msvc_target_arch='amd64'iftarget_arch=='x64'else'x86'
107+
arg=host_arch
108+
ifhost_arch!=msvc_target_arch:
109+
arg+='_'+msvc_target_arch
110+
111+
return [script_path, arg]
112+
113+
# We try to find the best version of the env setup batch.
114+
vcvarsall=JoinPath(self.path, 'VC', 'vcvarsall.bat')
115+
iftarget_arch=='x86':
116+
ifself.short_name>='2013'andself.short_name[-1] !='e'and \
117+
is_host_arch_x64:
118+
# VS2013 and later, non-Express have a x64-x86 cross that we want
119+
# to prefer.
120+
return [vcvarsall, 'amd64_x86']
99121
else:
100-
asserttarget_arch=='x64'
101-
arg='x86_amd64'
102-
# Use the 64-on-64 compiler if we're not using an express
103-
# edition and we're running on a 64bit OS.
104-
ifself.short_name[-1] !='e'and (
105-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
106-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
107-
arg='amd64'
108-
return [os.path.normpath(
109-
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
122+
# Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
123+
# for x86 because vcvarsall calls vcvars32, which it can only find if
124+
# VS??COMNTOOLS is set, which isn't guaranteed.
125+
return [JoinPath(self.path, 'Common7', 'Tools', 'vsvars32.bat')]
126+
eliftarget_arch=='x64':
127+
arg='x86_amd64'
128+
# Use the 64-on-64 compiler if we're not using an express edition and
129+
# we're running on a 64bit OS.
130+
ifself.short_name[-1] !='e'andis_host_arch_x64:
131+
arg='amd64'
132+
return [vcvarsall, arg]
133+
134+
defSetupScript(self, target_arch):
135+
script_data=self._SetupScriptInternal(target_arch)
136+
script_path=script_data[0]
137+
ifnotos.path.exists(script_path):
138+
raiseException('%s is missing - make sure VC++ tools are installed.'%
139+
script_path)
140+
returnscript_data
110141

111142

112143
def_RegistryQueryBase(sysdir, key, value):
@@ -181,11 +212,11 @@ def _RegistryGetValueUsingWinReg(key, value):
181212
ImportError if _winreg is unavailable.
182213
"""
183214
try:
184-
# Python 2
185-
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
215+
# Python 2
216+
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
186217
exceptImportError:
187-
# Python 3
188-
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
218+
# Python 3
219+
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
189220

190221
try:
191222
root, subkey=key.split('\\', 1)
@@ -236,6 +267,26 @@ def _CreateVersion(name, path, sdk_based=False):
236267
ifpath:
237268
path=os.path.normpath(path)
238269
versions= {
270+
'2019': VisualStudioVersion('2019',
271+
'Visual Studio 2019',
272+
solution_version='12.00',
273+
project_version='16.0',
274+
flat_sln=False,
275+
uses_vcxproj=True,
276+
path=path,
277+
sdk_based=sdk_based,
278+
default_toolset='v142',
279+
compatible_sdks=['v8.1', 'v10.0']),
280+
'2017': VisualStudioVersion('2017',
281+
'Visual Studio 2017',
282+
solution_version='12.00',
283+
project_version='15.0',
284+
flat_sln=False,
285+
uses_vcxproj=True,
286+
path=path,
287+
sdk_based=sdk_based,
288+
default_toolset='v141',
289+
compatible_sdks=['v8.1', 'v10.0']),
239290
'2015': VisualStudioVersion('2015',
240291
'Visual Studio 2015',
241292
solution_version='12.00',
@@ -350,14 +401,15 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
350401
A list of visual studio versions installed in descending order of
351402
usage preference.
352403
Base this on the registry and a quick check if devenv.exe exists.
353-
Only versions 8-10 are considered.
354404
Possibilities are:
355405
2005(e) - Visual Studio 2005 (8)
356406
2008(e) - Visual Studio 2008 (9)
357407
2010(e) - Visual Studio 2010 (10)
358408
2012(e) - Visual Studio 2012 (11)
359409
2013(e) - Visual Studio 2013 (12)
360410
2015 - Visual Studio 2015 (14)
411+
2017 - Visual Studio 2017 (15)
412+
2019 - Visual Studio 2019 (16)
361413
Where (e) is e for express editions of MSVS and blank otherwise.
362414
"""
363415
version_to_year= {
@@ -367,6 +419,8 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
367419
'11.0': '2012',
368420
'12.0': '2013',
369421
'14.0': '2015',
422+
'15.0': '2017',
423+
'16.0': '2019',
370424
}
371425
versions= []
372426
forversioninversions_to_check:
@@ -397,13 +451,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
397451

398452
# The old method above does not work when only SDK is installed.
399453
keys= [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
400-
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
454+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
455+
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
456+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
401457
forindexinrange(len(keys)):
402458
path=_RegistryGetValue(keys[index], version)
403459
ifnotpath:
404460
continue
405461
path=_ConvertToCygpath(path)
406-
ifversion!='14.0': # There is no Express edition for 2015.
462+
ifversion=='15.0':
463+
ifos.path.exists(path):
464+
versions.append(_CreateVersion('2017', path))
465+
elifversion!='14.0': # There is no Express edition for 2015.
407466
versions.append(_CreateVersion(version_to_year[version] +'e',
408467
os.path.join(path, '..'), sdk_based=True))
409468

@@ -422,7 +481,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422481
ifversion=='auto':
423482
version=os.environ.get('GYP_MSVS_VERSION', 'auto')
424483
version_map= {
425-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
484+
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
426485
'2005': ('8.0',),
427486
'2005e': ('8.0',),
428487
'2008': ('9.0',),
@@ -434,6 +493,8 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
434493
'2013': ('12.0',),
435494
'2013e': ('12.0',),
436495
'2015': ('14.0',),
496+
'2017': ('15.0',),
497+
'2019': ('16.0',),
437498
}
438499
override_path=os.environ.get('GYP_MSVS_OVERRIDE_PATH')
439500
ifoverride_path:

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 972780b

Browse files
authored
gyp: sync code base with nodejs repo (#1975)
PR-URL: #1975 Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent dab0305 commit 972780b

28 files changed

Lines changed: 971 additions & 390 deletions

‎gyp/AUTHORS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Ryan Norton <rnorton10@gmail.com>
1111
David J. Sankel <david@sankelsoftware.com>
1212
Eric N. Vander Weele <ericvw@gmail.com>
1313
Tom Freudenberg <th.freudenberg@gmail.com>
14+
Julien Brianceau <jbriance@cisco.com>
15+
Refael Ackermann <refack@gmail.com>

‎gyp/DEPS‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎gyp/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GYP can Generate Your Projects.
2+
===================================
3+
4+
Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check out ```md-pages``` branch to read those documents offline.

‎gyp/codereview.settings‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎gyp/pylib/gyp/MSVSNew.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importhashlib
88
importos
99
importrandom
10+
fromoperatorimportattrgetter
1011

1112
importgyp.common
1213

@@ -59,9 +60,6 @@ def __cmp__(self, other):
5960
# Sort by name then guid (so things are in order on vs2008).
6061
returncmp((self.name, self.get_guid()), (other.name, other.get_guid()))
6162

62-
def__lt__(self, other):
63-
returnself.__cmp__(other) <0
64-
6563

6664
classMSVSFolder(MSVSSolutionEntry):
6765
"""Folder in a Visual Studio project or solution."""
@@ -89,7 +87,7 @@ def __init__(self, path, name = None, entries = None,
8987
self.guid=guid
9088

9189
# Copy passed lists (or set to empty lists)
92-
self.entries=sorted(list(entriesor []))
90+
self.entries=sorted(entriesor [], key=attrgetter('path'))
9391
self.items=list(itemsor [])
9492

9593
self.entry_type_guid=ENTRY_TYPE_GUIDS['folder']
@@ -233,7 +231,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
233231
ifisinstance(e, MSVSFolder):
234232
entries_to_check+=e.entries
235233

236-
all_entries=sorted(all_entries)
234+
all_entries=sorted(all_entries, key=attrgetter('path'))
237235

238236
# Open file and print header
239237
f=writer(self.path)

‎gyp/pylib/gyp/MSVSSettings.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
467467
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
468468
exceptValueErrorase:
469469
print('Warning: while converting %s/%s to MSBuild, '
470-
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
470+
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
471471
else:
472472
_ValidateExclusionSetting(msvs_setting,
473473
msvs_tool,
@@ -477,7 +477,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
477477
stderr)
478478
else:
479479
print('Warning: unrecognized tool %s while converting to '
480-
'MSBuild.'%msvs_tool_name, file=stderr)
480+
'MSBuild.'%msvs_tool_name, file=stderr)
481481
returnmsbuild_settings
482482

483483

@@ -598,6 +598,7 @@ def _ValidateSettings(validators, settings, stderr):
598598
_Same(_compile, 'UseFullPaths', _boolean) # /FC
599599
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
600600
_Same(_compile, 'XMLDocumentationFileName', _file_name)
601+
_Same(_compile, 'CompileAsWinRT', _boolean) # /ZW
601602

602603
_Same(_compile, 'AssemblerOutput',
603604
_Enumeration(['NoListing',

‎gyp/pylib/gyp/MSVSSettings_test.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
"""Unit tests for the MSVSSettings.py file."""
88

9-
try:
10-
fromcStringIOimportStringIO
11-
exceptImportError:
12-
fromioimportStringIO
13-
149
importunittest
1510
importgyp.MSVSSettingsasMSVSSettings
1611

12+
try:
13+
fromStringIOimportStringIO# Python 2
14+
exceptImportError:
15+
fromioimportStringIO# Python 3
16+
1717

1818
classTestSequenceFunctions(unittest.TestCase):
1919

‎gyp/pylib/gyp/MSVSUtil.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'loadable_module': 'dll',
1515
'shared_library': 'dll',
1616
'static_library': 'lib',
17+
'windows_driver': 'sys',
1718
}
1819

1920

@@ -110,7 +111,7 @@ def ShardTargets(target_list, target_dicts):
110111
else:
111112
new_target_dicts[t] =target_dicts[t]
112113
# Shard dependencies.
113-
fortinnew_target_dicts:
114+
fortinsorted(new_target_dicts):
114115
fordeptypein ('dependencies', 'dependencies_original'):
115116
dependencies=copy.copy(new_target_dicts[t].get(deptype, []))
116117
new_dependencies= []

‎gyp/pylib/gyp/MSVSVersion.py‎

Lines changed: 104 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
PY3=bytes!=str
1616

1717

18+
defJoinPath(*args):
19+
returnos.path.normpath(os.path.join(*args))
20+
21+
1822
classVisualStudioVersion(object):
1923
"""Information regarding a version of Visual Studio."""
2024

2125
def__init__(self, short_name, description,
2226
solution_version, project_version, flat_sln, uses_vcxproj,
23-
path, sdk_based, default_toolset=None):
27+
path, sdk_based, default_toolset=None, compatible_sdks=None):
2428
self.short_name=short_name
2529
self.description=description
2630
self.solution_version=solution_version
@@ -30,6 +34,9 @@ def __init__(self, short_name, description,
3034
self.path=path
3135
self.sdk_based=sdk_based
3236
self.default_toolset=default_toolset
37+
compatible_sdks=compatible_sdksor []
38+
compatible_sdks.sort(key=lambdav: float(v.replace('v', '')), reverse=True)
39+
self.compatible_sdks=compatible_sdks
3340

3441
defShortName(self):
3542
returnself.short_name
@@ -70,43 +77,67 @@ def DefaultToolset(self):
7077
of a user override."""
7178
returnself.default_toolset
7279

73-
defSetupScript(self, target_arch):
80+
81+
def_SetupScriptInternal(self, target_arch):
7482
"""Returns a command (with arguments) to be used to set up the
7583
environment."""
76-
# Check if we are running in the SDK command line environment and use
77-
# the setup script from the SDK if so. |target_arch| should be either
78-
# 'x86' or 'x64'.
79-
asserttarget_archin ('x86', 'x64')
80-
sdk_dir=os.environ.get('WindowsSDKDir')
81-
ifself.sdk_basedandsdk_dir:
82-
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
83-
'/'+target_arch]
84-
else:
85-
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
86-
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
87-
# isn't always.
88-
iftarget_arch=='x86':
89-
ifself.short_name>='2013'andself.short_name[-1] !='e'and (
90-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
91-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
92-
# VS2013 and later, non-Express have a x64-x86 cross that we want
93-
# to prefer.
94-
return [os.path.normpath(
95-
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
96-
# Otherwise, the standard x86 compiler.
97-
return [os.path.normpath(
98-
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
84+
asserttarget_archin ('x86', 'x64'), "target_arch not supported"
85+
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
86+
# depot_tools build tools and should run SetEnv.Cmd to set up the
87+
# environment. The check for WindowsSDKDir alone is not sufficient because
88+
# this is set by running vcvarsall.bat.
89+
sdk_dir=os.environ.get('WindowsSDKDir', '')
90+
setup_path=JoinPath(sdk_dir, 'Bin', 'SetEnv.Cmd')
91+
ifself.sdk_basedandsdk_dirandos.path.exists(setup_path):
92+
return [setup_path, '/'+target_arch]
93+
94+
is_host_arch_x64= (
95+
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
96+
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'
97+
)
98+
99+
# For VS2017 (and newer) it's fairly easy
100+
ifself.short_name>='2017':
101+
script_path=JoinPath(self.path,
102+
'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
103+
104+
# Always use a native executable, cross-compiling if necessary.
105+
host_arch='amd64'ifis_host_arch_x64else'x86'
106+
msvc_target_arch='amd64'iftarget_arch=='x64'else'x86'
107+
arg=host_arch
108+
ifhost_arch!=msvc_target_arch:
109+
arg+='_'+msvc_target_arch
110+
111+
return [script_path, arg]
112+
113+
# We try to find the best version of the env setup batch.
114+
vcvarsall=JoinPath(self.path, 'VC', 'vcvarsall.bat')
115+
iftarget_arch=='x86':
116+
ifself.short_name>='2013'andself.short_name[-1] !='e'and \
117+
is_host_arch_x64:
118+
# VS2013 and later, non-Express have a x64-x86 cross that we want
119+
# to prefer.
120+
return [vcvarsall, 'amd64_x86']
99121
else:
100-
asserttarget_arch=='x64'
101-
arg='x86_amd64'
102-
# Use the 64-on-64 compiler if we're not using an express
103-
# edition and we're running on a 64bit OS.
104-
ifself.short_name[-1] !='e'and (
105-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
106-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
107-
arg='amd64'
108-
return [os.path.normpath(
109-
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
122+
# Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
123+
# for x86 because vcvarsall calls vcvars32, which it can only find if
124+
# VS??COMNTOOLS is set, which isn't guaranteed.
125+
return [JoinPath(self.path, 'Common7', 'Tools', 'vsvars32.bat')]
126+
eliftarget_arch=='x64':
127+
arg='x86_amd64'
128+
# Use the 64-on-64 compiler if we're not using an express edition and
129+
# we're running on a 64bit OS.
130+
ifself.short_name[-1] !='e'andis_host_arch_x64:
131+
arg='amd64'
132+
return [vcvarsall, arg]
133+
134+
defSetupScript(self, target_arch):
135+
script_data=self._SetupScriptInternal(target_arch)
136+
script_path=script_data[0]
137+
ifnotos.path.exists(script_path):
138+
raiseException('%s is missing - make sure VC++ tools are installed.'%
139+
script_path)
140+
returnscript_data
110141

111142

112143
def_RegistryQueryBase(sysdir, key, value):
@@ -181,11 +212,11 @@ def _RegistryGetValueUsingWinReg(key, value):
181212
ImportError if _winreg is unavailable.
182213
"""
183214
try:
184-
# Python 2
185-
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
215+
# Python 2
216+
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
186217
exceptImportError:
187-
# Python 3
188-
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
218+
# Python 3
219+
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
189220

190221
try:
191222
root, subkey=key.split('\\', 1)
@@ -236,6 +267,26 @@ def _CreateVersion(name, path, sdk_based=False):
236267
ifpath:
237268
path=os.path.normpath(path)
238269
versions= {
270+
'2019': VisualStudioVersion('2019',
271+
'Visual Studio 2019',
272+
solution_version='12.00',
273+
project_version='16.0',
274+
flat_sln=False,
275+
uses_vcxproj=True,
276+
path=path,
277+
sdk_based=sdk_based,
278+
default_toolset='v142',
279+
compatible_sdks=['v8.1', 'v10.0']),
280+
'2017': VisualStudioVersion('2017',
281+
'Visual Studio 2017',
282+
solution_version='12.00',
283+
project_version='15.0',
284+
flat_sln=False,
285+
uses_vcxproj=True,
286+
path=path,
287+
sdk_based=sdk_based,
288+
default_toolset='v141',
289+
compatible_sdks=['v8.1', 'v10.0']),
239290
'2015': VisualStudioVersion('2015',
240291
'Visual Studio 2015',
241292
solution_version='12.00',
@@ -350,14 +401,15 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
350401
A list of visual studio versions installed in descending order of
351402
usage preference.
352403
Base this on the registry and a quick check if devenv.exe exists.
353-
Only versions 8-10 are considered.
354404
Possibilities are:
355405
2005(e) - Visual Studio 2005 (8)
356406
2008(e) - Visual Studio 2008 (9)
357407
2010(e) - Visual Studio 2010 (10)
358408
2012(e) - Visual Studio 2012 (11)
359409
2013(e) - Visual Studio 2013 (12)
360410
2015 - Visual Studio 2015 (14)
411+
2017 - Visual Studio 2017 (15)
412+
2019 - Visual Studio 2019 (16)
361413
Where (e) is e for express editions of MSVS and blank otherwise.
362414
"""
363415
version_to_year= {
@@ -367,6 +419,8 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
367419
'11.0': '2012',
368420
'12.0': '2013',
369421
'14.0': '2015',
422+
'15.0': '2017',
423+
'16.0': '2019',
370424
}
371425
versions= []
372426
forversioninversions_to_check:
@@ -397,13 +451,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
397451

398452
# The old method above does not work when only SDK is installed.
399453
keys= [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
400-
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
454+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
455+
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
456+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
401457
forindexinrange(len(keys)):
402458
path=_RegistryGetValue(keys[index], version)
403459
ifnotpath:
404460
continue
405461
path=_ConvertToCygpath(path)
406-
ifversion!='14.0': # There is no Express edition for 2015.
462+
ifversion=='15.0':
463+
ifos.path.exists(path):
464+
versions.append(_CreateVersion('2017', path))
465+
elifversion!='14.0': # There is no Express edition for 2015.
407466
versions.append(_CreateVersion(version_to_year[version] +'e',
408467
os.path.join(path, '..'), sdk_based=True))
409468

@@ -422,7 +481,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422481
ifversion=='auto':
423482
version=os.environ.get('GYP_MSVS_VERSION', 'auto')
424483
version_map= {
425-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
484+
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
426485
'2005': ('8.0',),
427486
'2005e': ('8.0',),
428487
'2008': ('9.0',),
@@ -434,6 +493,8 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
434493
'2013': ('12.0',),
435494
'2013e': ('12.0',),
436495
'2015': ('14.0',),
496+
'2017': ('15.0',),
497+
'2019': ('16.0',),
437498
}
438499
override_path=os.environ.get('GYP_MSVS_OVERRIDE_PATH')
439500
ifoverride_path:

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Commit 972780b

Browse files
authored
gyp: sync code base with nodejs repo (#1975)
PR-URL: #1975 Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Christian Clauss <cclauss@me.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent dab0305 commit 972780b

28 files changed

Lines changed: 971 additions & 390 deletions

‎gyp/AUTHORS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ Ryan Norton <rnorton10@gmail.com>
1111
David J. Sankel <david@sankelsoftware.com>
1212
Eric N. Vander Weele <ericvw@gmail.com>
1313
Tom Freudenberg <th.freudenberg@gmail.com>
14+
Julien Brianceau <jbriance@cisco.com>
15+
Refael Ackermann <refack@gmail.com>

‎gyp/DEPS‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎gyp/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GYP can Generate Your Projects.
2+
===================================
3+
4+
Documents are available at [gyp.gsrc.io](https://gyp.gsrc.io), or you can check out ```md-pages``` branch to read those documents offline.

‎gyp/codereview.settings‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎gyp/pylib/gyp/MSVSNew.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
importhashlib
88
importos
99
importrandom
10+
fromoperatorimportattrgetter
1011

1112
importgyp.common
1213

@@ -59,9 +60,6 @@ def __cmp__(self, other):
5960
# Sort by name then guid (so things are in order on vs2008).
6061
returncmp((self.name, self.get_guid()), (other.name, other.get_guid()))
6162

62-
def__lt__(self, other):
63-
returnself.__cmp__(other) <0
64-
6563

6664
classMSVSFolder(MSVSSolutionEntry):
6765
"""Folder in a Visual Studio project or solution."""
@@ -89,7 +87,7 @@ def __init__(self, path, name = None, entries = None,
8987
self.guid=guid
9088

9189
# Copy passed lists (or set to empty lists)
92-
self.entries=sorted(list(entriesor []))
90+
self.entries=sorted(entriesor [], key=attrgetter('path'))
9391
self.items=list(itemsor [])
9492

9593
self.entry_type_guid=ENTRY_TYPE_GUIDS['folder']
@@ -233,7 +231,7 @@ def Write(self, writer=gyp.common.WriteOnDiff):
233231
ifisinstance(e, MSVSFolder):
234232
entries_to_check+=e.entries
235233

236-
all_entries=sorted(all_entries)
234+
all_entries=sorted(all_entries, key=attrgetter('path'))
237235

238236
# Open file and print header
239237
f=writer(self.path)

‎gyp/pylib/gyp/MSVSSettings.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
467467
msvs_tool[msvs_setting](msvs_value, msbuild_settings)
468468
exceptValueErrorase:
469469
print('Warning: while converting %s/%s to MSBuild, '
470-
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
470+
'%s'% (msvs_tool_name, msvs_setting, e), file=stderr)
471471
else:
472472
_ValidateExclusionSetting(msvs_setting,
473473
msvs_tool,
@@ -477,7 +477,7 @@ def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr):
477477
stderr)
478478
else:
479479
print('Warning: unrecognized tool %s while converting to '
480-
'MSBuild.'%msvs_tool_name, file=stderr)
480+
'MSBuild.'%msvs_tool_name, file=stderr)
481481
returnmsbuild_settings
482482

483483

@@ -598,6 +598,7 @@ def _ValidateSettings(validators, settings, stderr):
598598
_Same(_compile, 'UseFullPaths', _boolean) # /FC
599599
_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL
600600
_Same(_compile, 'XMLDocumentationFileName', _file_name)
601+
_Same(_compile, 'CompileAsWinRT', _boolean) # /ZW
601602

602603
_Same(_compile, 'AssemblerOutput',
603604
_Enumeration(['NoListing',

‎gyp/pylib/gyp/MSVSSettings_test.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
"""Unit tests for the MSVSSettings.py file."""
88

9-
try:
10-
fromcStringIOimportStringIO
11-
exceptImportError:
12-
fromioimportStringIO
13-
149
importunittest
1510
importgyp.MSVSSettingsasMSVSSettings
1611

12+
try:
13+
fromStringIOimportStringIO# Python 2
14+
exceptImportError:
15+
fromioimportStringIO# Python 3
16+
1717

1818
classTestSequenceFunctions(unittest.TestCase):
1919

‎gyp/pylib/gyp/MSVSUtil.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
'loadable_module': 'dll',
1515
'shared_library': 'dll',
1616
'static_library': 'lib',
17+
'windows_driver': 'sys',
1718
}
1819

1920

@@ -110,7 +111,7 @@ def ShardTargets(target_list, target_dicts):
110111
else:
111112
new_target_dicts[t] =target_dicts[t]
112113
# Shard dependencies.
113-
fortinnew_target_dicts:
114+
fortinsorted(new_target_dicts):
114115
fordeptypein ('dependencies', 'dependencies_original'):
115116
dependencies=copy.copy(new_target_dicts[t].get(deptype, []))
116117
new_dependencies= []

‎gyp/pylib/gyp/MSVSVersion.py‎

Lines changed: 104 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
PY3=bytes!=str
1616

1717

18+
defJoinPath(*args):
19+
returnos.path.normpath(os.path.join(*args))
20+
21+
1822
classVisualStudioVersion(object):
1923
"""Information regarding a version of Visual Studio."""
2024

2125
def__init__(self, short_name, description,
2226
solution_version, project_version, flat_sln, uses_vcxproj,
23-
path, sdk_based, default_toolset=None):
27+
path, sdk_based, default_toolset=None, compatible_sdks=None):
2428
self.short_name=short_name
2529
self.description=description
2630
self.solution_version=solution_version
@@ -30,6 +34,9 @@ def __init__(self, short_name, description,
3034
self.path=path
3135
self.sdk_based=sdk_based
3236
self.default_toolset=default_toolset
37+
compatible_sdks=compatible_sdksor []
38+
compatible_sdks.sort(key=lambdav: float(v.replace('v', '')), reverse=True)
39+
self.compatible_sdks=compatible_sdks
3340

3441
defShortName(self):
3542
returnself.short_name
@@ -70,43 +77,67 @@ def DefaultToolset(self):
7077
of a user override."""
7178
returnself.default_toolset
7279

73-
defSetupScript(self, target_arch):
80+
81+
def_SetupScriptInternal(self, target_arch):
7482
"""Returns a command (with arguments) to be used to set up the
7583
environment."""
76-
# Check if we are running in the SDK command line environment and use
77-
# the setup script from the SDK if so. |target_arch| should be either
78-
# 'x86' or 'x64'.
79-
asserttarget_archin ('x86', 'x64')
80-
sdk_dir=os.environ.get('WindowsSDKDir')
81-
ifself.sdk_basedandsdk_dir:
82-
return [os.path.normpath(os.path.join(sdk_dir, 'Bin/SetEnv.Cmd')),
83-
'/'+target_arch]
84-
else:
85-
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
86-
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
87-
# isn't always.
88-
iftarget_arch=='x86':
89-
ifself.short_name>='2013'andself.short_name[-1] !='e'and (
90-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
91-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
92-
# VS2013 and later, non-Express have a x64-x86 cross that we want
93-
# to prefer.
94-
return [os.path.normpath(
95-
os.path.join(self.path, 'VC/vcvarsall.bat')), 'amd64_x86']
96-
# Otherwise, the standard x86 compiler.
97-
return [os.path.normpath(
98-
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
84+
asserttarget_archin ('x86', 'x64'), "target_arch not supported"
85+
# If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
86+
# depot_tools build tools and should run SetEnv.Cmd to set up the
87+
# environment. The check for WindowsSDKDir alone is not sufficient because
88+
# this is set by running vcvarsall.bat.
89+
sdk_dir=os.environ.get('WindowsSDKDir', '')
90+
setup_path=JoinPath(sdk_dir, 'Bin', 'SetEnv.Cmd')
91+
ifself.sdk_basedandsdk_dirandos.path.exists(setup_path):
92+
return [setup_path, '/'+target_arch]
93+
94+
is_host_arch_x64= (
95+
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
96+
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'
97+
)
98+
99+
# For VS2017 (and newer) it's fairly easy
100+
ifself.short_name>='2017':
101+
script_path=JoinPath(self.path,
102+
'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
103+
104+
# Always use a native executable, cross-compiling if necessary.
105+
host_arch='amd64'ifis_host_arch_x64else'x86'
106+
msvc_target_arch='amd64'iftarget_arch=='x64'else'x86'
107+
arg=host_arch
108+
ifhost_arch!=msvc_target_arch:
109+
arg+='_'+msvc_target_arch
110+
111+
return [script_path, arg]
112+
113+
# We try to find the best version of the env setup batch.
114+
vcvarsall=JoinPath(self.path, 'VC', 'vcvarsall.bat')
115+
iftarget_arch=='x86':
116+
ifself.short_name>='2013'andself.short_name[-1] !='e'and \
117+
is_host_arch_x64:
118+
# VS2013 and later, non-Express have a x64-x86 cross that we want
119+
# to prefer.
120+
return [vcvarsall, 'amd64_x86']
99121
else:
100-
asserttarget_arch=='x64'
101-
arg='x86_amd64'
102-
# Use the 64-on-64 compiler if we're not using an express
103-
# edition and we're running on a 64bit OS.
104-
ifself.short_name[-1] !='e'and (
105-
os.environ.get('PROCESSOR_ARCHITECTURE') =='AMD64'or
106-
os.environ.get('PROCESSOR_ARCHITEW6432') =='AMD64'):
107-
arg='amd64'
108-
return [os.path.normpath(
109-
os.path.join(self.path, 'VC/vcvarsall.bat')), arg]
122+
# Otherwise, the standard x86 compiler. We don't use VC/vcvarsall.bat
123+
# for x86 because vcvarsall calls vcvars32, which it can only find if
124+
# VS??COMNTOOLS is set, which isn't guaranteed.
125+
return [JoinPath(self.path, 'Common7', 'Tools', 'vsvars32.bat')]
126+
eliftarget_arch=='x64':
127+
arg='x86_amd64'
128+
# Use the 64-on-64 compiler if we're not using an express edition and
129+
# we're running on a 64bit OS.
130+
ifself.short_name[-1] !='e'andis_host_arch_x64:
131+
arg='amd64'
132+
return [vcvarsall, arg]
133+
134+
defSetupScript(self, target_arch):
135+
script_data=self._SetupScriptInternal(target_arch)
136+
script_path=script_data[0]
137+
ifnotos.path.exists(script_path):
138+
raiseException('%s is missing - make sure VC++ tools are installed.'%
139+
script_path)
140+
returnscript_data
110141

111142

112143
def_RegistryQueryBase(sysdir, key, value):
@@ -181,11 +212,11 @@ def _RegistryGetValueUsingWinReg(key, value):
181212
ImportError if _winreg is unavailable.
182213
"""
183214
try:
184-
# Python 2
185-
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
215+
# Python 2
216+
from_winregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
186217
exceptImportError:
187-
# Python 3
188-
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
218+
# Python 3
219+
fromwinregimportHKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
189220

190221
try:
191222
root, subkey=key.split('\\', 1)
@@ -236,6 +267,26 @@ def _CreateVersion(name, path, sdk_based=False):
236267
ifpath:
237268
path=os.path.normpath(path)
238269
versions= {
270+
'2019': VisualStudioVersion('2019',
271+
'Visual Studio 2019',
272+
solution_version='12.00',
273+
project_version='16.0',
274+
flat_sln=False,
275+
uses_vcxproj=True,
276+
path=path,
277+
sdk_based=sdk_based,
278+
default_toolset='v142',
279+
compatible_sdks=['v8.1', 'v10.0']),
280+
'2017': VisualStudioVersion('2017',
281+
'Visual Studio 2017',
282+
solution_version='12.00',
283+
project_version='15.0',
284+
flat_sln=False,
285+
uses_vcxproj=True,
286+
path=path,
287+
sdk_based=sdk_based,
288+
default_toolset='v141',
289+
compatible_sdks=['v8.1', 'v10.0']),
239290
'2015': VisualStudioVersion('2015',
240291
'Visual Studio 2015',
241292
solution_version='12.00',
@@ -350,14 +401,15 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
350401
A list of visual studio versions installed in descending order of
351402
usage preference.
352403
Base this on the registry and a quick check if devenv.exe exists.
353-
Only versions 8-10 are considered.
354404
Possibilities are:
355405
2005(e) - Visual Studio 2005 (8)
356406
2008(e) - Visual Studio 2008 (9)
357407
2010(e) - Visual Studio 2010 (10)
358408
2012(e) - Visual Studio 2012 (11)
359409
2013(e) - Visual Studio 2013 (12)
360410
2015 - Visual Studio 2015 (14)
411+
2017 - Visual Studio 2017 (15)
412+
2019 - Visual Studio 2019 (16)
361413
Where (e) is e for express editions of MSVS and blank otherwise.
362414
"""
363415
version_to_year= {
@@ -367,6 +419,8 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
367419
'11.0': '2012',
368420
'12.0': '2013',
369421
'14.0': '2015',
422+
'15.0': '2017',
423+
'16.0': '2019',
370424
}
371425
versions= []
372426
forversioninversions_to_check:
@@ -397,13 +451,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
397451

398452
# The old method above does not work when only SDK is installed.
399453
keys= [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
400-
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
454+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
455+
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
456+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
401457
forindexinrange(len(keys)):
402458
path=_RegistryGetValue(keys[index], version)
403459
ifnotpath:
404460
continue
405461
path=_ConvertToCygpath(path)
406-
ifversion!='14.0': # There is no Express edition for 2015.
462+
ifversion=='15.0':
463+
ifos.path.exists(path):
464+
versions.append(_CreateVersion('2017', path))
465+
elifversion!='14.0': # There is no Express edition for 2015.
407466
versions.append(_CreateVersion(version_to_year[version] +'e',
408467
os.path.join(path, '..'), sdk_based=True))
409468

@@ -422,7 +481,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422481
ifversion=='auto':
423482
version=os.environ.get('GYP_MSVS_VERSION', 'auto')
424483
version_map= {
425-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
484+
'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
426485
'2005': ('8.0',),
427486
'2005e': ('8.0',),
428487
'2008': ('9.0',),
@@ -434,6 +493,8 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
434493
'2013': ('12.0',),
435494
'2013e': ('12.0',),
436495
'2015': ('14.0',),
496+
'2017': ('15.0',),
497+
'2019': ('16.0',),
437498
}
438499
override_path=os.environ.get('GYP_MSVS_OVERRIDE_PATH')
439500
ifoverride_path:

0 commit comments

Comments
 (0)