| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2009 Google Inc. All rights reserved. | 3 # Copyright (c) 2009 Google Inc. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Handle version information related to Visual Stuio.""" | 7 """Handle version information related to Visual Stuio.""" |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 A list of visual studio versions installed in descending order of | 87 A list of visual studio versions installed in descending order of |
| 88 usage preference. | 88 usage preference. |
| 89 Base this on the registry and a quick check if devenv.exe exists. | 89 Base this on the registry and a quick check if devenv.exe exists. |
| 90 Only versions 8-9 are considered. | 90 Only versions 8-9 are considered. |
| 91 Possibilities are: | 91 Possibilities are: |
| 92 2005 - Visual Studio 2005 (8) | 92 2005 - Visual Studio 2005 (8) |
| 93 2008 - Visual Studio 2008 (9) | 93 2008 - Visual Studio 2008 (9) |
| 94 """ | 94 """ |
| 95 version_to_year = { '8.0': '2005', '9.0': '2008' } | 95 version_to_year = { '8.0': '2005', '9.0': '2008' } |
| 96 versions = [] | 96 versions = [] |
| 97 for version in ['8.0', '9.0']: | 97 for version in ['9.0', '8.0']: |
| 98 # Get the install dir for this version. | 98 # Get the install dir for this version. |
| 99 key = r'HKLM\Software\Microsoft\VisualStudio\%s' % version | 99 key = r'HKLM\Software\Microsoft\VisualStudio\%s' % version |
| 100 path = _RegistryGetValue(key, 'InstallDir') | 100 path = _RegistryGetValue(key, 'InstallDir') |
| 101 if not path: | 101 if not path: |
| 102 continue | 102 continue |
| 103 # Check if there's anything actually there. | 103 # Check if there's anything actually there. |
| 104 if not os.path.exists(os.path.join(path, 'devenv.exe')): | 104 if not os.path.exists(os.path.join(path, 'devenv.exe')): |
| 105 continue | 105 continue |
| 106 # Add this one. | 106 # Add this one. |
| 107 versions.append(_CreateVersion(version_to_year[version])) | 107 versions.append(_CreateVersion(version_to_year[version])) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 121 version = os.environ.get('GYP_MSVS_VERSION', 'auto') | 121 version = os.environ.get('GYP_MSVS_VERSION', 'auto') |
| 122 # In auto mode, pick the most preferred version present. | 122 # In auto mode, pick the most preferred version present. |
| 123 if version == 'auto': | 123 if version == 'auto': |
| 124 versions = _DetectVisualStudioVersions() | 124 versions = _DetectVisualStudioVersions() |
| 125 if not versions: | 125 if not versions: |
| 126 # Default to 2005. | 126 # Default to 2005. |
| 127 return _CreateVersion('2005') | 127 return _CreateVersion('2005') |
| 128 return versions[0] | 128 return versions[0] |
| 129 # Convert version string into a version object. | 129 # Convert version string into a version object. |
| 130 return _CreateVersion(version) | 130 return _CreateVersion(version) |
| OLD | NEW |