@@ -18,7 +18,7 @@ class VisualStudioVersion(object):
18
18
19
19
def __init__ (self , short_name , description ,
20
20
solution_version , project_version , flat_sln , uses_vcxproj ,
21
- path , sdk_based , default_toolset = None ):
21
+ path , sdk_based , default_toolset = None , compatible_sdks = None ):
22
22
self .short_name = short_name
23
23
self .description = description
24
24
self .solution_version = solution_version
@@ -28,6 +28,9 @@ def __init__(self, short_name, description,
28
28
self .path = path
29
29
self .sdk_based = sdk_based
30
30
self .default_toolset = default_toolset
31
+ compatible_sdks = compatible_sdks or []
32
+ compatible_sdks .sort (key = lambda v : float (v .replace ('v' , '' )), reverse = True )
33
+ self .compatible_sdks = compatible_sdks
31
34
32
35
def ShortName (self ):
33
36
return self .short_name
@@ -68,17 +71,19 @@ def DefaultToolset(self):
68
71
of a user override."""
69
72
return self .default_toolset
70
73
71
- def SetupScript (self , target_arch ):
74
+ def _SetupScriptInternal (self , target_arch ):
72
75
"""Returns a command (with arguments) to be used to set up the
73
76
environment."""
74
- # Check if we are running in the SDK command line environment and use
75
- # the setup script from the SDK if so. |target_arch| should be either
76
- # 'x86' or 'x64'.
77
+ # If WindowsSDKDir is set and SetEnv.Cmd exists then we are using the
78
+ # depot_tools build tools and should run SetEnv.Cmd to set up the
79
+ # environment. The check for WindowsSDKDir alone is not sufficient because
80
+ # this is set by running vcvarsall.bat.
77
81
assert target_arch in ('x86' , 'x64' )
78
82
sdk_dir = os .environ .get ('WindowsSDKDir' )
79
- if self .sdk_based and sdk_dir :
80
- return [os .path .normpath (os .path .join (sdk_dir , 'Bin/SetEnv.Cmd' )),
81
- '/' + target_arch ]
83
+ if sdk_dir :
84
+ setup_path = os .path .normpath (os .path .join (sdk_dir , 'Bin/SetEnv.Cmd' ))
85
+ if self .sdk_based and sdk_dir and os .path .exists (setup_path ):
86
+ return [setup_path , '/' + target_arch ]
82
87
else :
83
88
# We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
84
89
# vcvars32, which it can only find if VS??COMNTOOLS is set, which it
@@ -106,6 +111,14 @@ def SetupScript(self, target_arch):
106
111
return [os .path .normpath (
107
112
os .path .join (self .path , 'VC/vcvarsall.bat' )), arg ]
108
113
114
+ def SetupScript (self , target_arch ):
115
+ script_data = self ._SetupScriptInternal (target_arch )
116
+ script_path = script_data [0 ]
117
+ if not os .path .exists (script_path ):
118
+ raise Exception ('%s is missing - make sure VC++ tools are installed.' %
119
+ script_path )
120
+ return script_data
121
+
109
122
110
123
def _RegistryQueryBase (sysdir , key , value ):
111
124
"""Use reg.exe to read a particular key.
@@ -226,6 +239,16 @@ def _CreateVersion(name, path, sdk_based=False):
226
239
if path :
227
240
path = os .path .normpath (path )
228
241
versions = {
242
+ '2017' : VisualStudioVersion ('2017' ,
243
+ 'Visual Studio 2017' ,
244
+ solution_version = '12.00' ,
245
+ project_version = '15.0' ,
246
+ flat_sln = False ,
247
+ uses_vcxproj = True ,
248
+ path = path ,
249
+ sdk_based = sdk_based ,
250
+ default_toolset = 'v141' ,
251
+ compatible_sdks = ['v8.1' , 'v10.0' ]),
229
252
'2015' : VisualStudioVersion ('2015' ,
230
253
'Visual Studio 2015' ,
231
254
solution_version = '12.00' ,
@@ -338,14 +361,14 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
338
361
A list of visual studio versions installed in descending order of
339
362
usage preference.
340
363
Base this on the registry and a quick check if devenv.exe exists.
341
- Only versions 8-10 are considered.
342
364
Possibilities are:
343
365
2005(e) - Visual Studio 2005 (8)
344
366
2008(e) - Visual Studio 2008 (9)
345
367
2010(e) - Visual Studio 2010 (10)
346
368
2012(e) - Visual Studio 2012 (11)
347
369
2013(e) - Visual Studio 2013 (12)
348
370
2015 - Visual Studio 2015 (14)
371
+ 2017 - Visual Studio 2017 (15)
349
372
Where (e) is e for express editions of MSVS and blank otherwise.
350
373
"""
351
374
version_to_year = {
@@ -355,6 +378,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
355
378
'11.0' : '2012' ,
356
379
'12.0' : '2013' ,
357
380
'14.0' : '2015' ,
381
+ '15.0' : '2017'
358
382
}
359
383
versions = []
360
384
for version in versions_to_check :
@@ -385,13 +409,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
385
409
386
410
# The old method above does not work when only SDK is installed.
387
411
keys = [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7' ,
388
- r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7' ]
412
+ r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7' ,
413
+ r'HKLM\Software\Microsoft\VisualStudio\SxS\VS7' ,
414
+ r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' ]
389
415
for index in range (len (keys )):
390
416
path = _RegistryGetValue (keys [index ], version )
391
417
if not path :
392
418
continue
393
419
path = _ConvertToCygpath (path )
394
- if version != '14.0' : # There is no Express edition for 2015.
420
+ if version == '15.0' :
421
+ if os .path .exists (path ):
422
+ versions .append (_CreateVersion ('2017' , path ))
423
+ elif version != '14.0' : # There is no Express edition for 2015.
395
424
versions .append (_CreateVersion (version_to_year [version ] + 'e' ,
396
425
os .path .join (path , '..' ), sdk_based = True ))
397
426
@@ -410,7 +439,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
410
439
if version == 'auto' :
411
440
version = os .environ .get ('GYP_MSVS_VERSION' , 'auto' )
412
441
version_map = {
413
- 'auto' : ('14.0' , '12.0' , '10.0' , '9.0' , '8.0' , '11.0' ),
442
+ 'auto' : ('15.0' , ' 14.0' , '12.0' , '10.0' , '9.0' , '8.0' , '11.0' ),
414
443
'2005' : ('8.0' ,),
415
444
'2005e' : ('8.0' ,),
416
445
'2008' : ('9.0' ,),
@@ -422,6 +451,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422
451
'2013' : ('12.0' ,),
423
452
'2013e' : ('12.0' ,),
424
453
'2015' : ('14.0' ,),
454
+ '2017' : ('15.0' ,),
425
455
}
426
456
override_path = os .environ .get ('GYP_MSVS_OVERRIDE_PATH' )
427
457
if override_path :
0 commit comments