@@ -18,7 +18,7 @@ class VisualStudioVersion(object):
1818
1919 def __init__ (self , short_name , description ,
2020 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 ):
2222 self .short_name = short_name
2323 self .description = description
2424 self .solution_version = solution_version
@@ -28,6 +28,9 @@ def __init__(self, short_name, description,
2828 self .path = path
2929 self .sdk_based = sdk_based
3030 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
3134
3235 def ShortName (self ):
3336 return self .short_name
@@ -68,17 +71,19 @@ def DefaultToolset(self):
6871 of a user override."""
6972 return self .default_toolset
7073
71- def SetupScript (self , target_arch ):
74+ def _SetupScriptInternal (self , target_arch ):
7275 """Returns a command (with arguments) to be used to set up the
7376 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.
7781 assert target_arch in ('x86' , 'x64' )
7882 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 ]
8287 else :
8388 # We don't use VC/vcvarsall.bat for x86 because vcvarsall calls
8489 # vcvars32, which it can only find if VS??COMNTOOLS is set, which it
@@ -106,6 +111,14 @@ def SetupScript(self, target_arch):
106111 return [os .path .normpath (
107112 os .path .join (self .path , 'VC/vcvarsall.bat' )), arg ]
108113
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+
109122
110123def _RegistryQueryBase (sysdir , key , value ):
111124 """Use reg.exe to read a particular key.
@@ -226,6 +239,16 @@ def _CreateVersion(name, path, sdk_based=False):
226239 if path :
227240 path = os .path .normpath (path )
228241 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' ]),
229252 '2015' : VisualStudioVersion ('2015' ,
230253 'Visual Studio 2015' ,
231254 solution_version = '12.00' ,
@@ -338,14 +361,14 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
338361 A list of visual studio versions installed in descending order of
339362 usage preference.
340363 Base this on the registry and a quick check if devenv.exe exists.
341- Only versions 8-10 are considered.
342364 Possibilities are:
343365 2005(e) - Visual Studio 2005 (8)
344366 2008(e) - Visual Studio 2008 (9)
345367 2010(e) - Visual Studio 2010 (10)
346368 2012(e) - Visual Studio 2012 (11)
347369 2013(e) - Visual Studio 2013 (12)
348370 2015 - Visual Studio 2015 (14)
371+ 2017 - Visual Studio 2017 (15)
349372 Where (e) is e for express editions of MSVS and blank otherwise.
350373 """
351374 version_to_year = {
@@ -355,6 +378,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
355378 '11.0' : '2012' ,
356379 '12.0' : '2013' ,
357380 '14.0' : '2015' ,
381+ '15.0' : '2017'
358382 }
359383 versions = []
360384 for version in versions_to_check :
@@ -385,13 +409,18 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
385409
386410 # The old method above does not work when only SDK is installed.
387411 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' ]
389415 for index in range (len (keys )):
390416 path = _RegistryGetValue (keys [index ], version )
391417 if not path :
392418 continue
393419 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.
395424 versions .append (_CreateVersion (version_to_year [version ] + 'e' ,
396425 os .path .join (path , '..' ), sdk_based = True ))
397426
@@ -410,7 +439,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
410439 if version == 'auto' :
411440 version = os .environ .get ('GYP_MSVS_VERSION' , 'auto' )
412441 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' ),
414443 '2005' : ('8.0' ,),
415444 '2005e' : ('8.0' ,),
416445 '2008' : ('9.0' ,),
@@ -422,6 +451,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
422451 '2013' : ('12.0' ,),
423452 '2013e' : ('12.0' ,),
424453 '2015' : ('14.0' ,),
454+ '2017' : ('15.0' ,),
425455 }
426456 override_path = os .environ .get ('GYP_MSVS_OVERRIDE_PATH' )
427457 if override_path :
0 commit comments