Skip to content

Commit d7c7538

Browse files
bzozjoaocgreis
authored andcommitted
build,tools: add support for VS2017 to gyp
Add support for creating VS2017 projects to gyp.
1 parent 8243ca0 commit d7c7538

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

tools/gyp/pylib/gyp/MSVSVersion.py

+32-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ def SetupScript(self, target_arch):
8484
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
8585
# isn't always.
8686
if target_arch == 'x86':
87+
if self.short_name == '2017':
88+
return [os.path.normpath(
89+
os.path.join(self.path, 'Common7/Tools/VsDevCmd.bat')), '/no_logo',
90+
'/arch=x86']
8791
if self.short_name >= '2013' and self.short_name[-1] != 'e' and (
8892
os.environ.get('PROCESSOR_ARCHITECTURE') == 'AMD64' or
8993
os.environ.get('PROCESSOR_ARCHITEW6432') == 'AMD64'):
@@ -96,6 +100,10 @@ def SetupScript(self, target_arch):
96100
os.path.join(self.path, 'Common7/Tools/vsvars32.bat'))]
97101
else:
98102
assert target_arch == 'x64'
103+
if self.short_name == '2017':
104+
return [os.path.normpath(
105+
os.path.join(self.path, 'Common7/Tools/VsDevCmd.bat')), '/no_logo',
106+
'/arch=x64']
99107
arg = 'x86_amd64'
100108
# Use the 64-on-64 compiler if we're not using an express
101109
# edition and we're running on a 64bit OS.
@@ -226,6 +234,15 @@ def _CreateVersion(name, path, sdk_based=False):
226234
if path:
227235
path = os.path.normpath(path)
228236
versions = {
237+
'2017': VisualStudioVersion('2017',
238+
'Visual Studio 2017',
239+
solution_version='12.00',
240+
project_version='14.0',
241+
flat_sln=False,
242+
uses_vcxproj=True,
243+
path=path,
244+
sdk_based=sdk_based,
245+
default_toolset='v141'),
229246
'2015': VisualStudioVersion('2015',
230247
'Visual Studio 2015',
231248
solution_version='12.00',
@@ -346,6 +363,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
346363
2012(e) - Visual Studio 2012 (11)
347364
2013(e) - Visual Studio 2013 (12)
348365
2015 - Visual Studio 2015 (14)
366+
2017 - Visual Studio 2017 (15)
349367
Where (e) is e for express editions of MSVS and blank otherwise.
350368
"""
351369
version_to_year = {
@@ -355,6 +373,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
355373
'11.0': '2012',
356374
'12.0': '2013',
357375
'14.0': '2015',
376+
'15.0': '2017',
358377
}
359378
versions = []
360379
for version in versions_to_check:
@@ -395,6 +414,17 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
395414
versions.append(_CreateVersion(version_to_year[version] + 'e',
396415
os.path.join(path, '..'), sdk_based=True))
397416

417+
if version == '15.0':
418+
# The VC++ 2017 install location needs to be located using COM instead of
419+
# the registry. For details see:
420+
# https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
421+
# For now we use a hardcoded default with an environment variable
422+
# override.
423+
path = r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional'
424+
path = os.environ.get('vs2017_install', path)
425+
if os.path.exists(path):
426+
versions.append(_CreateVersion('2017', path))
427+
398428
return versions
399429

400430

@@ -410,7 +440,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
410440
if version == 'auto':
411441
version = os.environ.get('GYP_MSVS_VERSION', 'auto')
412442
version_map = {
413-
'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
443+
'auto': ('15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
414444
'2005': ('8.0',),
415445
'2005e': ('8.0',),
416446
'2008': ('9.0',),
@@ -422,6 +452,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422452
'2013': ('12.0',),
423453
'2013e': ('12.0',),
424454
'2015': ('14.0',),
455+
'2017': ('15.0',),
425456
}
426457
override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH')
427458
if override_path:

tools/gyp/pylib/gyp/generator/msvs.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -2622,7 +2622,7 @@ def _GetMSBuildProjectConfigurations(configurations):
26222622
return [group]
26232623

26242624

2625-
def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name):
2625+
def _GetMSBuildGlobalProperties(spec, version, guid, gyp_file_name):
26262626
namespace = os.path.splitext(gyp_file_name)[0]
26272627
properties = [
26282628
['PropertyGroup', {'Label': 'Globals'},
@@ -2662,6 +2662,15 @@ def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name):
26622662
else:
26632663
properties[0].append(['ApplicationType', 'Windows Store'])
26642664

2665+
msvs_windows_sdk_version = None
2666+
if msvs_windows_sdk_version == None and version.ShortName() == '2017':
2667+
vs2017_sdk = '10.0.14393.0'
2668+
vs2017_sdk = os.environ.get('vs2017_sdk', vs2017_sdk)
2669+
if vs2017_sdk:
2670+
msvs_windows_sdk_version = vs2017_sdk
2671+
if msvs_windows_sdk_version:
2672+
properties[0].append(['WindowsTargetPlatformVersion',
2673+
str(msvs_windows_sdk_version)])
26652674
return properties
26662675

26672676
def _GetMSBuildConfigurationDetails(spec, build_file):
@@ -3295,7 +3304,8 @@ def _GenerateMSBuildProject(project, options, version, generator_flags):
32953304
}]
32963305

32973306
content += _GetMSBuildProjectConfigurations(configurations)
3298-
content += _GetMSBuildGlobalProperties(spec, project.guid, project_file_name)
3307+
content += _GetMSBuildGlobalProperties(spec, version, project.guid,
3308+
project_file_name)
32993309
content += import_default_section
33003310
content += _GetMSBuildConfigurationDetails(spec, project.build_file)
33013311
if spec.get('msvs_enable_winphone'):

0 commit comments

Comments
 (0)