Skip to content

Commit 89f26af

Browse files
bzozrefack
authored andcommitted
Add support for VS2017 to GYP
Adds support for generating solutions and building with Visual Studio 2017
1 parent 6cffc18 commit 89f26af

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

gyp/pylib/gyp/MSVSVersion.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ def _SetupScriptInternal(self, target_arch):
8686
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
8787
# isn't always.
8888
if target_arch == 'x86':
89+
if self.short_name == '2017':
90+
return [os.path.normpath(
91+
ps.path.join(self.path, 'Common7/Tools/VsDevCmd.bat')), '/no_logo',
92+
'/arch=x86']
8993
if self.short_name >= '2013' and self.short_name[-1] != 'e' and (
9094
os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64' or
9195
os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'):
@@ -98,6 +102,10 @@ def _SetupScriptInternal(self, target_arch):
98102
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
99103
else:
100104
assert target_arch == 'x64'
105+
if self.short_name == '2017':
106+
return [os.path.normpath(
107+
ps.path.join(self.path, 'Common7/Tools/VsDevCmd.bat')), '/no_logo',
108+
'/arch=x64']
101109
arg = 'x86_amd64'
102110
# Use the 64-on-64 compiler if we're not using an express
103111
# edition and we're running on a 64bit OS.
@@ -236,6 +244,15 @@ def _CreateVersion(name, path, sdk_based=False):
236244
if path:
237245
path = os.path.normpath(path)
238246
versions = {
247+
'2017': VisualStudioVersion('2017',
248+
'Visual Studio 2017',
249+
solution_version='12.00',
250+
project_version='14.0',
251+
flat_sln=False,
252+
uses_vcxproj=True,
253+
path=path,
254+
sdk_based=sdk_based,
255+
default_toolset='v141'),
239256
'2015': VisualStudioVersion('2015',
240257
'Visual Studio 2015',
241258
solution_version='12.00',
@@ -356,6 +373,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
356373
2012(e) - Visual Studio 2012 (11)
357374
2013(e) - Visual Studio 2013 (12)
358375
2015 - Visual Studio 2015 (14)
376+
2017 - Visual Studio 2017 (15)
359377
Where (e) is e for express editions of MSVS and blank otherwise.
360378
"""
361379
version_to_year = {
@@ -365,6 +383,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
365383
'11.0': '2012',
366384
'12.0': '2013',
367385
'14.0': '2015',
386+
'15.0': '2017'
368387
}
369388
versions = []
370389
for version in versions_to_check:
@@ -395,13 +414,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
395414

396415
# The old method above does not work when only SDK is installed.
397416
keys = [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7',
398-
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7']
417+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7',
418+
r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7',
419+
r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7']
399420
for index in range(len(keys)):
400421
path = _RegistryGetValue(keys[index], version)
401422
if not path:
402423
continue
403424
path = _ConvertToCygpath(path)
404-
if version != '14.0': # There is no Express edition for 2015.
425+
if version == '15.0':
426+
if os.path.exists(path):
427+
versions.append(_CreateVersion('2017', path))
428+
elif version != '14.0': # There is no Express edition for 2015.
405429
versions.append(_CreateVersion(version_to_year[version] + 'e',
406430
os.path.join(path, '..'), sdk_based=True))
407431

@@ -420,7 +444,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
420444
if version == 'auto':
421445
version = os.environ.get('GYP_MSVS_VERSION', 'auto')
422446
version_map = {
423-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
447+
'auto': ('15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
424448
'2005': ('8.0',),
425449
'2005e': ('8.0',),
426450
'2008': ('9.0',),
@@ -432,6 +456,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
432456
'2013': ('12.0',),
433457
'2013e': ('12.0',),
434458
'2015': ('14.0',),
459+
'2017': ('15.0',),
435460
}
436461
override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH')
437462
if override_path:

gyp/pylib/gyp/generator/msvs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,7 +2682,7 @@ def _GetMSBuildProjectConfigurations(configurations):
26822682
return [group]
26832683

26842684

2685-
def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name):
2685+
def _GetMSBuildGlobalProperties(spec, version, guid, gyp_file_name):
26862686
namespace = os.path.splitext(gyp_file_name)[0]
26872687
properties = [
26882688
['PropertyGroup', {'Label': 'Globals'},
@@ -2730,6 +2730,11 @@ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name):
27302730
_ConfigWindowsTargetPlatformVersion(configuration))
27312731
if platform_name and msvs_windows_sdk_version:
27322732
break
2733+
if msvs_windows_sdk_version == None and version.ShortName() == '2017':
2734+
vs2017_sdk = '10.0.14393.0'
2735+
vs2017_sdk = os.environ.get('vs2017_sdk', vs2017_sdk)
2736+
if vs2017_sdk:
2737+
msvs_windows_sdk_version = vs2017_sdk
27332738

27342739
if platform_name == 'ARM':
27352740
properties[0].append(['WindowsSDKDesktopARMSupport', 'true'])
@@ -3387,7 +3392,8 @@ def _GenerateMSBuildProject(project, options, version, generator_flags):
33873392
}]
33883393

33893394
content += _GetMSBuildProjectConfigurations(configurations)
3390-
content += _GetMSBuildGlobalProperties(spec, project.guid, project_file_name)
3395+
content += _GetMSBuildGlobalProperties(spec, version, project.guid,
3396+
project_file_name)
33913397
content += import_default_section
33923398
content += _GetMSBuildConfigurationDetails(spec, project.build_file)
33933399
if spec.get('msvs_enable_winphone'):

0 commit comments

Comments
 (0)