renamed SCons.Tool.ninja -> SCons.Tool.ninja_tool and added alias in tool loading...
[scons.git] / SCons / Tool / msvsTests.py
blobdd423d4bd95d37ef1cb9c596f3af4a89aaf9cf36
1 # MIT License
3 # Copyright The SCons Foundation
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 import os
25 import sys
26 import unittest
27 import copy
29 import TestCmd
30 import TestUnit
32 from SCons.Tool.msvs import *
33 from SCons.Tool.MSCommon.vs import SupportedVSList
34 import SCons.Node.FS
35 import SCons.Util
36 import SCons.Warnings
38 from SCons.Tool.MSCommon.common import debug
40 from SCons.Tool.MSCommon import get_default_version, \
41 query_versions
42 from SCons.Tool.msvs import _GenerateV6DSP, _GenerateV7DSP, _GenerateV10DSP
44 regdata_6a = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio]
45 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0]
46 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\ServicePacks]
47 "sp3"=""
48 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup]
49 "VsCommonDir"="C:\Program Files\Microsoft Visual Studio\Common"
50 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Developer Network Library - Visual Studio 6.0a]
51 "ProductDir"="C:\Program Files\Microsoft Visual Studio\MSDN98\98VSa\1033"
52 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++]
53 "ProductDir"="C:\Program Files\Microsoft Visual Studio\VC98"
54 '''.split('\n')
56 regdata_6b = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio]
57 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0]
58 "InstallDir"="C:\VS6\Common\IDE\IDE98"
59 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\ServicePacks]
60 "sp5"=""
61 "latest"=dword:00000005
62 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup]
63 "VsCommonDir"="C:\VS6\Common"
64 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Basic]
65 "ProductDir"="C:\VS6\VB98"
66 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++]
67 "ProductDir"="C:\VS6\VC98"
68 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Studio]
69 "ProductDir"="C:\VS6"
70 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft VSEE Client]
71 "ProductDir"="C:\VS6\Common\Tools"
72 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Visual Studio 98]
73 '''.split('\n')
75 regdata_7 = r'''
76 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0]
77 "InstallDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
78 "Source Directories"="C:\Program Files\Microsoft Visual Studio .NET\Vc7\crt\;C:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\src\mfc\;C:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\src\atl\"
79 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts]
80 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\CrystalReports]
81 @="#15007"
82 "Package"="{F05E92C6-8346-11D3-B4AD-00A0C9B04E7B}"
83 "ProductDetails"="#15009"
84 "LogoID"="0"
85 "PID"="#15008"
86 "UseInterface"=dword:00000001
87 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\Visual Basic.NET]
88 @=""
89 "DefaultProductAttribute"="VB"
90 "Package"="{164B10B9-B200-11D0-8C61-00A0C91E29D5}"
91 "UseInterface"=dword:00000001
92 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\Visual C#]
93 @=""
94 "Package"="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}"
95 "UseInterface"=dword:00000001
96 "DefaultProductAttribute"="C#"
97 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\VisualC++]
98 "UseInterface"=dword:00000001
99 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
100 "DefaultProductAttribute"="VC"
101 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup]
102 "Dbghelp_path"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
103 "dw_dir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
104 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\MSDN]
105 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Msdn\1033\"
106 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\Servicing\SKU]
107 "Visual Studio .NET Professional - English"="{D0610409-7D65-11D5-A54F-0090278A1BB8}"
108 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VB]
109 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Vb7\"
110 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VC]
111 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Vc7\"
112 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VC#]
113 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\VC#\"
114 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\Visual Studio .NET Professional - English]
115 "InstallSuccess"=dword:00000001
116 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS]
117 "EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
118 "EnvironmentPath"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe"
119 "VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe"
120 "MSMDir"="C:\Program Files\Common Files\Merge Modules\"
121 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\"
122 "VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\"
123 "VS7CommonDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\"
124 "VSUpdateDir"="C:\Program Files\Microsoft Visual Studio .NET\Setup\VSUpdate\"
125 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS\BuildNumber]
126 "1033"="7.0.9466"
127 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS\Pro]
128 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\"
129 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC]
130 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO]
131 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
132 @="{A54AAE91-30C2-11D3-87BF-A04A4CC10000}"
133 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]
134 "Path Dirs"="$(VCInstallDir)bin;$(VSInstallDir)Common7\Tools\bin\prerelease;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;C:\Program Files\HTML Help Workshop\;$(FrameworkSDKDir)bin;$(FrameworkDir)$(FrameworkVersion);C:\perl\bin;C:\cygwin\bin;c:\cygwin\usr\bin;C:\bin;C:\program files\perforce;C:\cygwin\usr\local\bin\i686-pc-cygwin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem"
135 "Library Dirs"="$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)PlatformSDK\lib\prerelease;$(VCInstallDir)PlatformSDK\lib;$(FrameworkSDKDir)lib"
136 "Include Dirs"="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(VCInstallDir)PlatformSDK\include\prerelease;$(VCInstallDir)PlatformSDK\include;$(FrameworkSDKDir)include"
137 "Source Dirs"="$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src"
138 "Reference Dirs"=""
139 '''.split('\n')
141 regdata_7_1 = r'''
142 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1]
143 @=""
144 "Source Directories"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\crt\src\;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\src\mfc\;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\src\atl\"
145 "ThisVersionSolutionCLSID"="{246C57AE-40DD-4d6b-9E8D-B0F5757BB2A8}"
146 "ThisVersionDTECLSID"="{8CD2DD97-4EC1-4bc4-9359-89A3EEDD57A6}"
147 "InstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
148 "CLR Version"="v1.1.4322"
149 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts]
150 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Smart Device Extensions]
151 "UseInterface"=dword:00000001
152 "VS7InstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
153 "VBDeviceInstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VB7\"
154 "CSharpDeviceInstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
155 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual Basic.NET]
156 "UseInterface"=dword:00000001
157 "Package"="{164B10B9-B200-11D0-8C61-00A0C91E29D5}"
158 "DefaultProductAttribute"="VB"
159 @=""
160 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual C#]
161 "DefaultProductAttribute"="C#"
162 "UseInterface"=dword:00000001
163 "Package"="{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}"
164 @=""
165 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual JSharp]
166 @=""
167 "Package"="{E6FDF8B0-F3D1-11D4-8576-0002A516ECE8}"
168 "UseInterface"=dword:00000001
169 "DefaultProductAttribute"="Visual JSharp"
170 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\VisualC++]
171 "UseInterface"=dword:00000001
172 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
173 "DefaultProductAttribute"="VC"
174 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup]
175 "Dbghelp_path"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
176 "dw_dir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
177 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\CSDPROJ]
178 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
179 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\JSHPROJ]
180 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VJ#\"
181 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing]
182 "CurrentSULevel"=dword:00000000
183 "CurrentSPLevel"=dword:00000000
184 "Server Path"=""
185 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing\Package]
186 "FxSDK"=""
187 "VB"=""
188 "VC"=""
189 "VCS"=""
190 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing\SKU]
191 "Visual Studio .NET Professional 2003 - English"="{20610409-CA18-41A6-9E21-A93AE82EE7C5}"
192 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VB]
193 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\"
194 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VBDPROJ]
195 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\"
196 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VC]
197 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\"
198 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VC#]
199 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
200 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Visual Studio .NET Professional 2003 - English]
201 "InstallSuccess"=dword:00000001
202 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS]
203 "EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
204 "EnvironmentPath"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
205 "VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
206 "MSMDir"="C:\Program Files\Common Files\Merge Modules\"
207 "VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\"
208 "VS7CommonDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\"
209 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
210 "VSUpdateDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Setup\VSUpdate\"
211 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS\BuildNumber]
212 "1033"="7.1.3088"
213 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS\Pro]
214 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
215 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC]
216 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO]
217 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
218 @="{759354D0-6B42-4705-AFFB-56E34D2BC3D4}"
219 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]
220 "Path Dirs"="$(VCInstallDir)bin;$(VSInstallDir)Common7\Tools\bin\prerelease;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;C:\Program Files\HTML Help Workshop\;$(FrameworkSDKDir)bin;$(FrameworkDir)$(FrameworkVersion);C:\Perl\bin\;c:\bin;c:\cygwin\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Avid;C:\Program Files\backburner 2\;C:\Program Files\cvsnt;C:\Program Files\Subversion\bin;C:\Program Files\Common Files\Adobe\AGL;C:\Program Files\HTMLDoc"
221 "Library Dirs"="$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)PlatformSDK\lib\prerelease;$(VCInstallDir)PlatformSDK\lib;$(FrameworkSDKDir)lib"
222 "Include Dirs"="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(VCInstallDir)PlatformSDK\include\prerelease;$(VCInstallDir)PlatformSDK\include;$(FrameworkSDKDir)include"
223 "Source Dirs"="$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src"
224 "Reference Dirs"="$(FrameWorkDir)$(FrameWorkVersion)"
225 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
226 "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
227 "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc"
228 "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
229 "VCMIDLTool"="*.idl;*.odl"
230 "VCCustomBuildTool"="*.bat"
231 "VCResourceCompilerTool"="*.rc"
232 "VCPreBuildEventTool"="*.bat"
233 "VCPreLinkEventTool"="*.bat"
234 "VCPostBuildEventTool"="*.bat"
235 "VCBscMakeTool"="*.sbr"
236 "VCNMakeTool"=""
237 "VCWebServiceProxyGeneratorTool"="*.discomap"
238 "VCWebDeploymentTool"=""
239 "VCALinkTool"="*.resources"
240 "VCManagedResourceCompilerTool"="*.resx"
241 "VCXMLDataGeneratorTool"="*.xsd"
242 "VCManagedWrapperGeneratorTool"=""
243 "VCAuxiliaryManagedWrapperGeneratorTool"=""
244 "VCPrimaryInteropTool"=""
245 '''.split('\n')
247 regdata_8exp = r'''
248 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0]
249 "CLR Version"="v2.0.50727"
250 "ApplicationID"="VCExpress"
251 "SecurityAppID"="{741726F6-1EAE-4680-86A6-6085E8872CF8}"
252 "InstallDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
253 "EnablePreloadCLR"=dword:00000001
254 "RestoreAppPath"=dword:00000001
255 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\InstalledProducts]
256 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\InstalledProducts\Microsoft Visual C++]
257 "UseInterface"=dword:00000001
258 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
259 "DefaultProductAttribute"="VC"
260 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup]
261 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup\VC]
262 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\VC\"
263 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup\VS]
264 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
265 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC]
266 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO]
267 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
268 @="{72f11281-2429-11d7-8bf6-00b0d03daa06}"
269 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
270 "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
271 "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc;*.licenses"
272 "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
273 "VCMIDLTool"="*.idl;*.odl"
274 "VCCustomBuildTool"="*.bat"
275 "VCResourceCompilerTool"="*.rc"
276 "VCPreBuildEventTool"="*.bat"
277 "VCPreLinkEventTool"="*.bat"
278 "VCPostBuildEventTool"="*.bat"
279 "VCBscMakeTool"="*.sbr"
280 "VCFxCopTool"="*.dll;*.exe"
281 "VCNMakeTool"=""
282 "VCWebServiceProxyGeneratorTool"="*.discomap"
283 "VCWebDeploymentTool"=""
284 "VCALinkTool"="*.resources"
285 "VCManagedResourceCompilerTool"="*.resx"
286 "VCXMLDataGeneratorTool"="*.xsd"
287 "VCManifestTool"="*.manifest"
288 "VCXDCMakeTool"="*.xdc"
289 '''.split('\n')
291 regdata_80 = r'''
292 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0]
293 "CLR Version"="v2.0.50727"
294 "ApplicationID"="VisualStudio"
295 "ThisVersionDTECLSID"="{BA018599-1DB3-44f9-83B4-461454C84BF8}"
296 "ThisVersionSolutionCLSID"="{1B2EEDD6-C203-4d04-BD59-78906E3E8AAB}"
297 "SecurityAppID"="{DF99D4F5-9F04-4CEF-9D39-095821B49C77}"
298 "InstallDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
299 "EnablePreloadCLR"=dword:00000001
300 "RestoreAppPath"=dword:00000001
301 "Source Directories"="C:\Program Files\Microsoft Visual Studio 8\VC\crt\src\;C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\mfc\;C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\atl\;C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\"
302 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\InstalledProducts]
303 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\InstalledProducts\Microsoft Visual C++]
304 "UseInterface"=dword:00000001
305 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
306 "DefaultProductAttribute"="VC"
307 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup]
308 "Dbghelp_path"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
309 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\EF]
310 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\EnterpriseFrameworks\"
311 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\Microsoft Visual Studio 2005 Professional Edition - ENU]
312 "SrcPath"="d:\vs\"
313 "InstallSuccess"=dword:00000001
314 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VC]
315 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\VC\"
316 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS]
317 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
318 "VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
319 "EnvironmentPath"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
320 "EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
321 "VS7CommonDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\"
322 "VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\"
323 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS\BuildNumber]
324 "1033"="8.0.50727.42"
325 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS\Pro]
326 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
327 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC]
328 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO]
329 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
330 @="{72f11281-2429-11d7-8bf6-00b0d03daa06}"
331 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
332 "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
333 "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc;*.licenses"
334 "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
335 "VCMIDLTool"="*.idl;*.odl"
336 "VCCustomBuildTool"="*.bat"
337 "VCResourceCompilerTool"="*.rc"
338 "VCPreBuildEventTool"="*.bat"
339 "VCPreLinkEventTool"="*.bat"
340 "VCPostBuildEventTool"="*.bat"
341 "VCBscMakeTool"="*.sbr"
342 "VCFxCopTool"="*.dll;*.exe"
343 "VCNMakeTool"=""
344 "VCWebServiceProxyGeneratorTool"="*.discomap"
345 "VCWebDeploymentTool"=""
346 "VCALinkTool"="*.resources"
347 "VCManagedResourceCompilerTool"="*.resx"
348 "VCXMLDataGeneratorTool"="*.xsd"
349 "VCManifestTool"="*.manifest"
350 "VCXDCMakeTool"="*.xdc"
351 '''.split('\n')
353 regdata_140 = r'''
354 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS]
355 "MSMDir"="C:\\Program Files (x86)\\Common Files\\Merge Modules\\"
356 "ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
357 "VS7EnvironmentLocation"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
358 "EnvironmentPath"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
359 "EnvironmentDirectory"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\"
360 "VS7CommonDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\"
361 "VS7CommonBinDir"=""
362 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\BuildNumber]
363 "1033"="14.0"
364 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Community]
365 "ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
366 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSLS_MSI]
367 "Version"="14.0.25527"
368 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSPS_MSI]
369 "Version"="14.0.25527"
370 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Pro]
371 "ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
372 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\professional]
373 "IsInstallInProgress"="0"
374 "CurrentOperation"="install"
375 "SetupFeedUri"="http://go.microsoft.com/fwlink/?LinkID=659004&clcid=0x409"
376 "SetupFeedLocalCache"="C:\\ProgramData\\Microsoft\\VisualStudioSecondaryInstaller\\14.0\\LastUsedFeed\\{68432bbb-c9a5-4a7b-bab3-ae5a49b28303}\\Feed.xml"
377 "InstallResult"="0"
378 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller]
379 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AppInsightsTools]
380 "Version"="7.0.20620.1"
381 '''.split('\n')
383 regdata_cv = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
384 "ProgramFilesDir"="C:\Program Files"
385 "CommonFilesDir"="C:\Program Files\Common Files"
386 "MediaPath"="C:\WINDOWS\Media"
387 '''.split('\n')
390 regdata_none = []
392 class DummyEnv:
393 def __init__(self, dict=None) -> None:
394 self.fs = SCons.Node.FS.FS()
395 if dict:
396 self.dict = dict
397 else:
398 self.dict = {}
400 def Dictionary(self, key = None):
401 if not key:
402 return self.dict
403 return self.dict[key]
405 def __setitem__(self, key, value) -> None:
406 self.dict[key] = value
408 def __getitem__(self, key):
409 return self.dict[key]
411 def __contains__(self, key) -> bool:
412 return key in self.dict
414 def get(self, name, value=None):
415 if name in self.dict:
416 return self.dict[name]
417 else:
418 return value
420 def Dir(self, name):
421 return self.fs.Dir(name)
423 def File(self, name):
424 return self.fs.File(name)
426 def subst(self, key):
427 if key[0] == '$':
428 key = key[1:]
429 return self[key]
432 class RegKey:
433 """key class for storing an 'open' registry key"""
434 def __init__(self,key) -> None:
435 self.key = key
437 # Warning: this is NOT case-insensitive, unlike the Windows registry.
438 # So e.g. HKLM\Software is NOT the same key as HKLM\SOFTWARE.
439 class RegNode:
440 """node in the dummy registry"""
441 def __init__(self,name) -> None:
442 self.valdict = {}
443 self.keydict = {}
444 self.keyarray = []
445 self.valarray = []
446 self.name = name
448 def value(self,val):
449 if val in self.valdict:
450 return (self.valdict[val],1)
451 else:
452 raise SCons.Util.RegError
454 def addValue(self,name,val) -> None:
455 self.valdict[name] = val
456 self.valarray.append(name)
458 def valindex(self,index):
459 rv = None
460 try:
461 rv = (self.valarray[index],self.valdict[self.valarray[index]],1)
462 except KeyError:
463 raise SCons.Util.RegError
464 return rv
466 def key(self,key,sep: str = '\\'):
467 if key.find(sep) != -1:
468 keyname, subkeys = key.split(sep,1)
469 else:
470 keyname = key
471 subkeys = ""
472 try:
473 # recurse, and return the lowest level key node
474 if subkeys:
475 return self.keydict[keyname].key(subkeys)
476 else:
477 return self.keydict[keyname]
478 except KeyError:
479 raise SCons.Util.RegError
481 def addKey(self,name,sep: str = '\\'):
482 if name.find(sep) != -1:
483 keyname, subkeys = name.split(sep, 1)
484 else:
485 keyname = name
486 subkeys = ""
488 if keyname not in self.keydict:
489 self.keydict[keyname] = RegNode(keyname)
490 self.keyarray.append(keyname)
492 # recurse, and return the lowest level key node
493 if subkeys:
494 return self.keydict[keyname].addKey(subkeys)
495 else:
496 return self.keydict[keyname]
498 def keyindex(self,index):
499 return self.keydict[self.keyarray[index]]
501 def __str__(self) -> str:
502 return self._doStr()
504 def _doStr(self, indent: str = ''):
505 rv = ""
506 for value in self.valarray:
507 rv = rv + '%s"%s" = "%s"\n' % (indent, value, self.valdict[value])
508 for key in self.keyarray:
509 rv = rv + "%s%s: {\n"%(indent, key)
510 rv = rv + self.keydict[key]._doStr(indent + ' ')
511 rv = rv + indent + '}\n'
512 return rv
514 class DummyRegistry:
515 """registry class for storing fake registry attributes"""
516 def __init__(self,data) -> None:
517 """parse input data into the fake registry"""
518 self.root = RegNode('REGISTRY')
519 self.root.addKey('HKEY_LOCAL_MACHINE')
520 self.root.addKey('HKEY_CURRENT_USER')
521 self.root.addKey('HKEY_USERS')
522 self.root.addKey('HKEY_CLASSES_ROOT')
524 self.parse(data)
526 def parse(self, data) -> None:
527 parents = [None, None]
528 parents[0] = self.root
529 keymatch = re.compile(r'^\[(.*)\]$')
530 valmatch = re.compile(r'^(?:"(.*)"|[@])="(.*)"$')
531 for line in data:
532 m1 = keymatch.match(line)
533 if m1:
534 # add a key, set it to current parent.
535 # Also create subkey for Wow6432Node of HKLM\Software;
536 # that's where it looks on a 64-bit machine (tests will fail w/o this)
537 parents[0] = self.root.addKey(m1.group(1))
538 if 'HKEY_LOCAL_MACHINE\\Software' in m1.group(1):
539 p1 = m1.group(1).replace('HKEY_LOCAL_MACHINE\\Software', 'HKEY_LOCAL_MACHINE\\Software\\Wow6432Node')
540 parents[1] = self.root.addKey(p1)
541 else:
542 parents[1] = None
543 else:
544 m2 = valmatch.match(line)
545 if m2:
546 for p in parents:
547 if p:
548 p.addValue(m2.group(1),m2.group(2))
550 def OpenKeyEx(self,root,key):
551 if root == SCons.Util.HKEY_CLASSES_ROOT:
552 mykey = 'HKEY_CLASSES_ROOT\\' + key
553 if root == SCons.Util.HKEY_USERS:
554 mykey = 'HKEY_USERS\\' + key
555 if root == SCons.Util.HKEY_CURRENT_USER:
556 mykey = 'HKEY_CURRENT_USER\\' + key
557 if root == SCons.Util.HKEY_LOCAL_MACHINE:
558 mykey = 'HKEY_LOCAL_MACHINE\\' + key
559 debug("Open Key:%s"%mykey)
560 return self.root.key(mykey)
562 def DummyOpenKeyEx(root, key):
563 return registry.OpenKeyEx(root,key)
565 def DummyEnumKey(key, index):
566 rv = None
567 try:
568 rv = key.keyarray[index]
569 except IndexError:
570 raise SCons.Util.RegError
571 # DEBUG
572 # print "Enum Key",key.name,"[",index,"] =>",rv
573 return rv
575 def DummyEnumValue(key, index):
576 rv = key.valindex(index)
577 # DEBUG
578 # print "Enum Value",key.name,"[",index,"] =>",rv
579 return rv
581 def DummyQueryValue(key, value):
582 rv = key.value(value)
583 # DEBUG
584 # print "Query Value",key.name+"\\"+value,"=>",rv
585 return rv
587 def DummyExists(path) -> bool:
588 return True
590 def DummyVsWhere(msvc_version, vswhere_exe):
591 # not testing versions with vswhere, so return none
592 return None
594 class msvsTestCase(unittest.TestCase):
595 """This test case is run several times with different defaults.
596 See its subclasses below."""
597 def setUp(self) -> None:
598 debug("THIS TYPE :%s"%self)
599 global registry
600 registry = self.registry
601 from SCons.Tool.MSCommon.vs import reset_installed_visual_studios
602 reset_installed_visual_studios()
604 self.test = TestCmd.TestCmd(workdir='')
605 # FS doesn't like the cwd to be something other than its root.
606 os.chdir(self.test.workpath(""))
607 self.fs = SCons.Node.FS.FS()
609 def test_get_default_version(self) -> None:
610 """Test retrieval of the default visual studio version"""
612 debug("Testing for default version %s"%self.default_version)
613 env = DummyEnv()
614 v1 = get_default_version(env)
615 if v1:
616 assert env['MSVS_VERSION'] == self.default_version, \
617 ("env['MSVS_VERSION'] != self.default_version",
618 env['MSVS_VERSION'],self.default_version)
619 assert env['MSVS']['VERSION'] == self.default_version, \
620 ("env['MSVS']['VERSION'] != self.default_version",
621 env['MSVS']['VERSION'], self.default_version)
622 assert v1 == self.default_version, (self.default_version, v1)
624 env = DummyEnv({'MSVS_VERSION':'7.0'})
625 v2 = get_default_version(env)
626 assert env['MSVS_VERSION'] == '7.0', env['MSVS_VERSION']
627 assert env['MSVS']['VERSION'] == '7.0', env['MSVS']['VERSION']
628 assert v2 == '7.0', v2
630 env = DummyEnv()
631 v3 = get_default_version(env)
632 if v3 == '7.1':
633 override = '7.0'
634 else:
635 override = '7.1'
636 env['MSVS_VERSION'] = override
637 v3 = get_default_version(env)
638 assert env['MSVS_VERSION'] == override, env['MSVS_VERSION']
639 assert env['MSVS']['VERSION'] == override, env['MSVS']['VERSION']
640 assert v3 == override, v3
642 def _TODO_test_merge_default_version(self) -> None:
643 """Test the merge_default_version() function"""
644 pass
646 def test_query_versions(self, env=None) -> None:
647 """Test retrieval of the list of visual studio versions"""
648 v1 = query_versions(env)
649 assert not v1 or str(v1[0]) == self.highest_version, \
650 (v1, self.highest_version)
651 assert len(v1) == self.number_of_versions, v1
653 def test_config_generation(self) -> None:
654 """Test _DSPGenerator.__init__(...)"""
655 if not self.highest_version :
656 return
658 # Initialize 'static' variables
659 version_num, suite = msvs_parse_version(self.highest_version)
660 if version_num >= 10.0:
661 function_test = _GenerateV10DSP
662 suffix = '.vcxproj'
663 elif version_num >= 7.0:
664 function_test = _GenerateV7DSP
665 suffix = '.dsp'
666 else:
667 function_test = _GenerateV6DSP
668 suffix = '.dsp'
670 # Avoid any race conditions between the test cases when we test
671 # actually writing the files.
672 dspfile = 'test%s%s' % (hash(self), suffix)
674 str_function_test = str(function_test.__init__)
675 source = 'test.cpp'
677 # Create the cmdargs test list
678 list_variant = ['Debug|Win32','Release|Win32',
679 'Debug|x64', 'Release|x64']
680 list_cmdargs = ['debug=True target_arch=32',
681 'debug=False target_arch=32',
682 'debug=True target_arch=x64',
683 'debug=False target_arch=x64']
684 list_cppdefines = [['_A', '_B', 'C'], ['_B', '_C_'], ['D'], []]
685 list_cpppaths = [[r'C:\test1'], [r'C:\test1;C:\test2'],
686 [self.fs.Dir('subdir')], []]
687 list_cppflags = [['/std:c++17', '/Zc:__cplusplus'],
688 ['/std:c++14', '/Zc:__cplusplus'],
689 ['/std:c++11', '/Zc:__cplusplus'], []]
691 def TestParamsFromList(test_variant, test_list):
693 Generates test data based on the parameters passed in.
695 Returns tuple list:
696 1. Parameter.
697 2. Dictionary of expected result per variant.
699 def normalizeParam(param):
701 Converts the raw data based into the AddConfig function of
702 msvs.py to the expected result.
704 Expects the following behavior:
705 1. A value of None will be converted to an empty list.
706 2. A File or Directory object will be converted to an
707 absolute path (because those objects can't be pickled).
708 3. Otherwise, the parameter will be used.
710 if param is None:
711 return []
712 elif isinstance(param, list):
713 return [normalizeParam(p) for p in param]
714 elif hasattr(param, 'abspath'):
715 return param.abspath
716 else:
717 return param
719 return [
720 (None, dict.fromkeys(test_variant, '')),
721 ('', dict.fromkeys(test_variant, '')),
722 (test_list[0], dict.fromkeys(test_variant, normalizeParam(test_list[0]))),
723 (test_list, dict(list(zip(test_variant, [normalizeParam(x) for x in test_list]))))
726 tests_cmdargs = TestParamsFromList(list_variant, list_cmdargs)
727 tests_cppdefines = TestParamsFromList(list_variant, list_cppdefines)
728 tests_cpppaths = TestParamsFromList(list_variant, list_cpppaths)
729 tests_cppflags = TestParamsFromList(list_variant, list_cppflags)
731 # Run the test for each test case
732 for param_cmdargs, expected_cmdargs in tests_cmdargs:
733 for param_cppdefines, expected_cppdefines in tests_cppdefines:
734 for param_cpppaths, expected_cpppaths in tests_cpppaths:
735 for param_cppflags, expected_cppflags in tests_cppflags:
736 # DEBUG:
737 # print(
738 # 'Testing %s. with :\n variant = %s \n cmdargs = "%s" \n cppdefines = "%s" \n cpppaths = "%s" \n cppflags = "%s"'
739 # % (
740 # str_function_test,
741 # list_variant,
742 # param_cmdargs,
743 # param_cppdefines,
744 # param_cpppaths,
745 # param_cppflags,
748 param_configs = []
749 expected_configs = {}
750 for platform in ['Win32', 'x64']:
751 for variant in ['Debug', 'Release']:
752 variant_platform = '%s|%s' % (variant, platform)
753 runfile = '%s\\%s\\test.exe' % (platform, variant)
754 buildtarget = '%s\\%s\\test.exe' % (platform, variant)
755 outdir = '%s\\%s' % (platform, variant)
757 # Create parameter list for this variant_platform
758 param_configs.append([variant_platform, runfile, buildtarget, outdir])
760 # Create expected dictionary result for this variant_platform
761 expected_configs[variant_platform] = {
762 'variant': variant,
763 'platform': platform,
764 'runfile': runfile,
765 'buildtarget': buildtarget,
766 'outdir': outdir,
767 'cmdargs': expected_cmdargs[variant_platform],
768 'cppdefines': expected_cppdefines[variant_platform],
769 'cpppaths': expected_cpppaths[variant_platform],
770 'cppflags': expected_cppflags[variant_platform],
773 # Create parameter environment with final parameter dictionary
774 param_dict = dict(list(zip(('variant', 'runfile', 'buildtarget', 'outdir'),
775 [list(l) for l in zip(*param_configs)])))
776 param_dict['cmdargs'] = param_cmdargs
777 param_dict['cppdefines'] = param_cppdefines
778 param_dict['cpppaths'] = param_cpppaths
779 param_dict['cppflags'] = param_cppflags
781 # Hack to be able to run the test with a 'DummyEnv'
782 class _DummyEnv(DummyEnv):
783 def subst(self, string, *args, **kwargs):
784 return string
786 env = _DummyEnv(param_dict)
787 env['MSVSSCONSCRIPT'] = ''
788 env['MSVS_VERSION'] = self.highest_version
789 env['MSVSBUILDTARGET'] = 'target'
791 # Call function to test
792 genDSP = function_test(dspfile, source, env)
794 # Check expected result
795 self.assertListEqual(list(genDSP.configs.keys()), list(expected_configs.keys()))
796 for key, v in genDSP.configs.items():
797 self.assertDictEqual(v.__dict__, expected_configs[key])
799 genDSP.Build()
801 # Delete the resulting file so we don't leave anything behind.
802 for file in [dspfile, dspfile + '.filters']:
803 path = os.path.realpath(file)
804 try:
805 os.remove(path)
806 except OSError:
807 pass
809 class msvs6aTestCase(msvsTestCase):
810 """Test MSVS 6 Registry"""
811 registry = DummyRegistry(regdata_6a + regdata_cv)
812 default_version = '6.0'
813 highest_version = '6.0'
814 number_of_versions = 1
815 install_locs = {
816 '6.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio\\VC98', 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin'},
817 '7.0' : {},
818 '7.1' : {},
819 '8.0' : {},
820 '8.0Exp' : {},
822 default_install_loc = install_locs['6.0']
824 class msvs6bTestCase(msvsTestCase):
825 """Test Other MSVS 6 Registry"""
826 registry = DummyRegistry(regdata_6b + regdata_cv)
827 default_version = '6.0'
828 highest_version = '6.0'
829 number_of_versions = 1
830 install_locs = {
831 '6.0' : {'VSINSTALLDIR': 'C:\\VS6\\VC98', 'VCINSTALLDIR': 'C:\\VS6\\VC98\\Bin'},
832 '7.0' : {},
833 '7.1' : {},
834 '8.0' : {},
835 '8.0Exp' : {},
837 default_install_loc = install_locs['6.0']
839 class msvs6and7TestCase(msvsTestCase):
840 """Test MSVS 6 & 7 Registry"""
841 registry = DummyRegistry(regdata_6b + regdata_7 + regdata_cv)
842 default_version = '7.0'
843 highest_version = '7.0'
844 number_of_versions = 2
845 install_locs = {
846 '6.0' : {'VSINSTALLDIR': 'C:\\VS6\\VC98',
847 'VCINSTALLDIR': 'C:\\VS6\\VC98\\Bin'},
848 '7.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7',
849 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7\\Tools'},
850 '7.1' : {},
851 '8.0' : {},
852 '8.0Exp' : {},
854 default_install_loc = install_locs['7.0']
856 class msvs7TestCase(msvsTestCase):
857 """Test MSVS 7 Registry"""
858 registry = DummyRegistry(regdata_7 + regdata_cv)
859 default_version = '7.0'
860 highest_version = '7.0'
861 number_of_versions = 1
862 install_locs = {
863 '6.0' : {},
864 '7.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7',
865 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7\\Tools'},
866 '7.1' : {},
867 '8.0' : {},
868 '8.0Exp' : {},
870 default_install_loc = install_locs['7.0']
872 class msvs71TestCase(msvsTestCase):
873 """Test MSVS 7.1 Registry"""
874 registry = DummyRegistry(regdata_7_1 + regdata_cv)
875 default_version = '7.1'
876 highest_version = '7.1'
877 number_of_versions = 1
878 install_locs = {
879 '6.0' : {},
880 '7.0' : {},
881 '7.1' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7',
882 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\Tools'},
883 '8.0' : {},
884 '8.0Exp' : {},
886 default_install_loc = install_locs['7.1']
888 class msvs8ExpTestCase(msvsTestCase): # XXX: only one still not working
889 """Test MSVS 8 Express Registry"""
890 registry = DummyRegistry(regdata_8exp + regdata_cv)
891 default_version = '8.0'
892 highest_version = '8.0'
893 number_of_versions = 2
894 install_locs = {
895 '6.0' : {},
896 '7.0' : {},
897 '7.1' : {},
898 '8.0' : {},
899 '8.0Exp' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8',
900 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8\\VC'},
902 default_install_loc = install_locs['8.0Exp']
904 class msvs80TestCase(msvsTestCase):
905 """Test MSVS 8 Registry"""
906 registry = DummyRegistry(regdata_80 + regdata_cv)
907 default_version = '8.0'
908 highest_version = '8.0'
909 number_of_versions = 1
910 install_locs = {
911 '6.0' : {},
912 '7.0' : {},
913 '7.1' : {},
914 '8.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8',
915 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8\\VC'},
916 '8.0Exp' : {},
918 default_install_loc = install_locs['8.0']
920 class msvs140TestCase(msvsTestCase):
921 """Test MSVS 140 Registry"""
922 registry = DummyRegistry(regdata_140 + regdata_cv)
923 default_version = '14.0'
924 highest_version = '14.0'
925 number_of_versions = 2
926 install_locs = {
927 '14.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0',
928 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC'},
930 default_install_loc = install_locs['14.0']
932 class msvsEmptyTestCase(msvsTestCase):
933 """Test Empty Registry"""
934 registry = DummyRegistry(regdata_none)
935 default_version = SupportedVSList[0].version
936 highest_version = None
937 number_of_versions = 0
938 install_locs = {
939 '6.0' : {},
940 '7.0' : {},
941 '7.1' : {},
942 '8.0' : {},
943 '8.0Exp' : {},
945 default_install_loc = install_locs['8.0Exp']
947 if __name__ == "__main__":
949 # only makes sense to test this on win32
950 if sys.platform != 'win32':
951 sys.stdout.write("NO RESULT for msvsTests.py: '%s' is not win32\n" % sys.platform)
952 sys.exit(0)
954 SCons.Util.RegOpenKeyEx = DummyOpenKeyEx
955 SCons.Util.RegEnumKey = DummyEnumKey
956 SCons.Util.RegEnumValue = DummyEnumValue
957 SCons.Util.RegQueryValueEx = DummyQueryValue
958 SCons.Tool.MSCommon.vc._find_vc_pdir_vswhere = DummyVsWhere
960 os.path.exists = DummyExists # make sure all files exist :-)
961 os.path.isfile = DummyExists # make sure all files are files :-)
962 os.path.isdir = DummyExists # make sure all dirs are dirs :-)
964 exit_val = 0
966 test_classes = [
967 msvs6aTestCase,
968 msvs6bTestCase,
969 msvs6and7TestCase,
970 msvs7TestCase,
971 msvs71TestCase,
972 msvs8ExpTestCase,
973 msvs80TestCase,
974 msvs140TestCase,
975 msvsEmptyTestCase,
978 for test_class in test_classes:
979 # DEBUG
980 # print("TEST: ", test_class.__doc__)
981 back_osenv = copy.deepcopy(os.environ)
982 try:
983 # XXX: overriding the os.environ is bad, but doing it
984 # correctly is too complicated for now. Those tests should
985 # be fixed
986 for k in ['VS71COMNTOOLS',
987 'VS80COMNTOOLS',
988 'VS90COMNTOOLS']:
989 if k in os.environ:
990 del os.environ[k]
992 loader = unittest.TestLoader()
993 loader.testMethodPrefix = 'test_'
994 suite = loader.loadTestsFromTestCase(test_class)
995 if not TestUnit.cli.get_runner()().run(suite).wasSuccessful():
996 exit_val = 1
997 finally:
998 os.env = back_osenv
1000 sys.exit(exit_val)
1002 # Local Variables:
1003 # tab-width:4
1004 # indent-tabs-mode:nil
1005 # End:
1006 # vim: set expandtab tabstop=4 shiftwidth=4: