OLD | NEW |
1 # Copyright (c) 2013 Google Inc. All rights reserved. | 1 # Copyright (c) 2013 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Handle version information related to Visual Stuio.""" | 5 """Handle version information related to Visual Stuio.""" |
6 | 6 |
7 import errno | 7 import errno |
8 import os | 8 import os |
9 import re | 9 import re |
10 import subprocess | 10 import subprocess |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 def _CreateVersion(name, path, sdk_based=False): | 218 def _CreateVersion(name, path, sdk_based=False): |
219 """Sets up MSVS project generation. | 219 """Sets up MSVS project generation. |
220 | 220 |
221 Setup is based off the GYP_MSVS_VERSION environment variable or whatever is | 221 Setup is based off the GYP_MSVS_VERSION environment variable or whatever is |
222 autodetected if GYP_MSVS_VERSION is not explicitly specified. If a version is | 222 autodetected if GYP_MSVS_VERSION is not explicitly specified. If a version is |
223 passed in that doesn't match a value in versions python will throw a error. | 223 passed in that doesn't match a value in versions python will throw a error. |
224 """ | 224 """ |
225 if path: | 225 if path: |
226 path = os.path.normpath(path) | 226 path = os.path.normpath(path) |
227 versions = { | 227 versions = { |
| 228 '2015': VisualStudioVersion('2015', |
| 229 'Visual Studio 2015', |
| 230 solution_version='12.00', |
| 231 project_version='14.0', |
| 232 flat_sln=False, |
| 233 uses_vcxproj=True, |
| 234 path=path, |
| 235 sdk_based=sdk_based, |
| 236 default_toolset='v140'), |
228 '2013': VisualStudioVersion('2013', | 237 '2013': VisualStudioVersion('2013', |
229 'Visual Studio 2013', | 238 'Visual Studio 2013', |
230 solution_version='13.00', | 239 solution_version='13.00', |
231 project_version='12.0', | 240 project_version='12.0', |
232 flat_sln=False, | 241 flat_sln=False, |
233 uses_vcxproj=True, | 242 uses_vcxproj=True, |
234 path=path, | 243 path=path, |
235 sdk_based=sdk_based, | 244 sdk_based=sdk_based, |
236 default_toolset='v120'), | 245 default_toolset='v120'), |
237 '2013e': VisualStudioVersion('2013e', | 246 '2013e': VisualStudioVersion('2013e', |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 Returns: | 336 Returns: |
328 A list of visual studio versions installed in descending order of | 337 A list of visual studio versions installed in descending order of |
329 usage preference. | 338 usage preference. |
330 Base this on the registry and a quick check if devenv.exe exists. | 339 Base this on the registry and a quick check if devenv.exe exists. |
331 Only versions 8-10 are considered. | 340 Only versions 8-10 are considered. |
332 Possibilities are: | 341 Possibilities are: |
333 2005(e) - Visual Studio 2005 (8) | 342 2005(e) - Visual Studio 2005 (8) |
334 2008(e) - Visual Studio 2008 (9) | 343 2008(e) - Visual Studio 2008 (9) |
335 2010(e) - Visual Studio 2010 (10) | 344 2010(e) - Visual Studio 2010 (10) |
336 2012(e) - Visual Studio 2012 (11) | 345 2012(e) - Visual Studio 2012 (11) |
337 2013(e) - Visual Studio 2013 (11) | 346 2013(e) - Visual Studio 2013 (12) |
| 347 2015 - Visual Studio 2015 (14) |
338 Where (e) is e for express editions of MSVS and blank otherwise. | 348 Where (e) is e for express editions of MSVS and blank otherwise. |
339 """ | 349 """ |
340 version_to_year = { | 350 version_to_year = { |
341 '8.0': '2005', | 351 '8.0': '2005', |
342 '9.0': '2008', | 352 '9.0': '2008', |
343 '10.0': '2010', | 353 '10.0': '2010', |
344 '11.0': '2012', | 354 '11.0': '2012', |
345 '12.0': '2013', | 355 '12.0': '2013', |
| 356 '14.0': '2015', |
346 } | 357 } |
347 versions = [] | 358 versions = [] |
348 for version in versions_to_check: | 359 for version in versions_to_check: |
349 # Old method of searching for which VS version is installed | 360 # Old method of searching for which VS version is installed |
350 # We don't use the 2010-encouraged-way because we also want to get the | 361 # We don't use the 2010-encouraged-way because we also want to get the |
351 # path to the binaries, which it doesn't offer. | 362 # path to the binaries, which it doesn't offer. |
352 keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version, | 363 keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version, |
353 r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version, | 364 r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version, |
354 r'HKLM\Software\Microsoft\VCExpress\%s' % version, | 365 r'HKLM\Software\Microsoft\VCExpress\%s' % version, |
355 r'HKLM\Software\Wow6432Node\Microsoft\VCExpress\%s' % version] | 366 r'HKLM\Software\Wow6432Node\Microsoft\VCExpress\%s' % version] |
(...skipping 16 matching lines...) Expand all Loading... |
372 os.path.join(path, '..', '..'))) | 383 os.path.join(path, '..', '..'))) |
373 | 384 |
374 # The old method above does not work when only SDK is installed. | 385 # The old method above does not work when only SDK is installed. |
375 keys = [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7', | 386 keys = [r'HKLM\Software\Microsoft\VisualStudio\SxS\VC7', |
376 r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7'] | 387 r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\SxS\VC7'] |
377 for index in range(len(keys)): | 388 for index in range(len(keys)): |
378 path = _RegistryGetValue(keys[index], version) | 389 path = _RegistryGetValue(keys[index], version) |
379 if not path: | 390 if not path: |
380 continue | 391 continue |
381 path = _ConvertToCygpath(path) | 392 path = _ConvertToCygpath(path) |
382 versions.append(_CreateVersion(version_to_year[version] + 'e', | 393 if version != '14.0': # There is no Express edition for 2015. |
383 os.path.join(path, '..'), sdk_based=True)) | 394 versions.append(_CreateVersion(version_to_year[version] + 'e', |
| 395 os.path.join(path, '..'), sdk_based=True)) |
384 | 396 |
385 return versions | 397 return versions |
386 | 398 |
387 | 399 |
388 def SelectVisualStudioVersion(version='auto', allow_fallback=True): | 400 def SelectVisualStudioVersion(version='auto', allow_fallback=True): |
389 """Select which version of Visual Studio projects to generate. | 401 """Select which version of Visual Studio projects to generate. |
390 | 402 |
391 Arguments: | 403 Arguments: |
392 version: Hook to allow caller to force a particular version (vs auto). | 404 version: Hook to allow caller to force a particular version (vs auto). |
393 Returns: | 405 Returns: |
394 An object representing a visual studio project format version. | 406 An object representing a visual studio project format version. |
395 """ | 407 """ |
396 # In auto mode, check environment variable for override. | 408 # In auto mode, check environment variable for override. |
397 if version == 'auto': | 409 if version == 'auto': |
398 version = os.environ.get('GYP_MSVS_VERSION', 'auto') | 410 version = os.environ.get('GYP_MSVS_VERSION', 'auto') |
399 version_map = { | 411 version_map = { |
400 'auto': ('12.0', '10.0', '9.0', '8.0', '11.0'), | 412 'auto': ('14.0', '12.0', '10.0', '9.0', '8.0', '11.0'), |
401 '2005': ('8.0',), | 413 '2005': ('8.0',), |
402 '2005e': ('8.0',), | 414 '2005e': ('8.0',), |
403 '2008': ('9.0',), | 415 '2008': ('9.0',), |
404 '2008e': ('9.0',), | 416 '2008e': ('9.0',), |
405 '2010': ('10.0',), | 417 '2010': ('10.0',), |
406 '2010e': ('10.0',), | 418 '2010e': ('10.0',), |
407 '2012': ('11.0',), | 419 '2012': ('11.0',), |
408 '2012e': ('11.0',), | 420 '2012e': ('11.0',), |
409 '2013': ('12.0',), | 421 '2013': ('12.0',), |
410 '2013e': ('12.0',), | 422 '2013e': ('12.0',), |
| 423 '2015': ('14.0',), |
411 } | 424 } |
412 override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH') | 425 override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH') |
413 if override_path: | 426 if override_path: |
414 msvs_version = os.environ.get('GYP_MSVS_VERSION') | 427 msvs_version = os.environ.get('GYP_MSVS_VERSION') |
415 if not msvs_version: | 428 if not msvs_version: |
416 raise ValueError('GYP_MSVS_OVERRIDE_PATH requires GYP_MSVS_VERSION to be ' | 429 raise ValueError('GYP_MSVS_OVERRIDE_PATH requires GYP_MSVS_VERSION to be ' |
417 'set to a particular version (e.g. 2010e).') | 430 'set to a particular version (e.g. 2010e).') |
418 return _CreateVersion(msvs_version, override_path, sdk_based=True) | 431 return _CreateVersion(msvs_version, override_path, sdk_based=True) |
419 version = str(version) | 432 version = str(version) |
420 versions = _DetectVisualStudioVersions(version_map[version], 'e' in version) | 433 versions = _DetectVisualStudioVersions(version_map[version], 'e' in version) |
421 if not versions: | 434 if not versions: |
422 if not allow_fallback: | 435 if not allow_fallback: |
423 raise ValueError('Could not locate Visual Studio installation.') | 436 raise ValueError('Could not locate Visual Studio installation.') |
424 if version == 'auto': | 437 if version == 'auto': |
425 # Default to 2005 if we couldn't find anything | 438 # Default to 2005 if we couldn't find anything |
426 return _CreateVersion('2005', None) | 439 return _CreateVersion('2005', None) |
427 else: | 440 else: |
428 return _CreateVersion(version, None) | 441 return _CreateVersion(version, None) |
429 return versions[0] | 442 return versions[0] |
OLD | NEW |