Remove the obsolete msvs_exists() unit test.
[scons.git] / src / engine / SCons / Tool / msvsTests.py
1 #
2 # __COPYRIGHT__
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #
23
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
25
26 import os
27 import string
28 import sys
29 import TestCmd
30 import unittest
31 import copy
32
33 from SCons.Tool.msvs import *
34 import SCons.Util
35 import SCons.Warnings
36
37 from SCons.Tool.MSCommon.common import debug
38
39 from SCons.Tool.MSCommon import get_default_version, \
40                                 query_versions
41
42 regdata_6a = string.split(r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio]
43 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0]
44 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\ServicePacks]
45 "sp3"=""
46 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup]
47 "VsCommonDir"="C:\Program Files\Microsoft Visual Studio\Common"
48 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Developer Network Library - Visual Studio 6.0a]
49 "ProductDir"="C:\Program Files\Microsoft Visual Studio\MSDN98\98VSa\1033"
50 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++]
51 "ProductDir"="C:\Program Files\Microsoft Visual Studio\VC98"
52 ''','\n')
53
54 regdata_6b = string.split(r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio]
55 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0]
56 "InstallDir"="C:\VS6\Common\IDE\IDE98"
57 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\ServicePacks]
58 "sp5"=""
59 "latest"=dword:00000005
60 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup]
61 "VsCommonDir"="C:\VS6\Common"
62 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Basic]
63 "ProductDir"="C:\VS6\VB98"
64 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++]
65 "ProductDir"="C:\VS6\VC98"
66 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Studio]
67 "ProductDir"="C:\VS6"
68 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft VSEE Client]
69 "ProductDir"="C:\VS6\Common\Tools"
70 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Visual Studio 98]
71 ''','\n')
72
73 regdata_7 = string.split(r'''
74 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0]
75 "InstallDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
76 "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\"
77 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts]
78 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\CrystalReports]
79 @="#15007"
80 "Package"="{F05E92C6-8346-11D3-B4AD-00A0C9B04E7B}"
81 "ProductDetails"="#15009"
82 "LogoID"="0"
83 "PID"="#15008"
84 "UseInterface"=dword:00000001
85 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\Visual Basic.NET]
86 @=""
87 "DefaultProductAttribute"="VB"
88 "Package"="{164B10B9-B200-11D0-8C61-00A0C91E29D5}"
89 "UseInterface"=dword:00000001
90 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\Visual C#]
91 @=""
92 "Package"="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}"
93 "UseInterface"=dword:00000001
94 "DefaultProductAttribute"="C#"
95 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\VisualC++]
96 "UseInterface"=dword:00000001
97 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
98 "DefaultProductAttribute"="VC"
99 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup]
100 "Dbghelp_path"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
101 "dw_dir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
102 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\MSDN]
103 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Msdn\1033\"
104 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\Servicing\SKU]
105 "Visual Studio .NET Professional - English"="{D0610409-7D65-11D5-A54F-0090278A1BB8}"
106 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VB]
107 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Vb7\"
108 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VC]
109 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Vc7\"
110 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VC#]
111 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\VC#\"
112 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\Visual Studio .NET Professional - English]
113 "InstallSuccess"=dword:00000001
114 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS]
115 "EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
116 "EnvironmentPath"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe"
117 "VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe"
118 "MSMDir"="C:\Program Files\Common Files\Merge Modules\"
119 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\"
120 "VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\"
121 "VS7CommonDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\"
122 "VSUpdateDir"="C:\Program Files\Microsoft Visual Studio .NET\Setup\VSUpdate\"
123 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS\BuildNumber]
124 "1033"="7.0.9466"
125 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS\Pro]
126 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\"
127 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC]
128 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO]
129 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
130 @="{A54AAE91-30C2-11D3-87BF-A04A4CC10000}"
131 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]
132 "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"
133 "Library Dirs"="$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)PlatformSDK\lib\prerelease;$(VCInstallDir)PlatformSDK\lib;$(FrameworkSDKDir)lib"
134 "Include Dirs"="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(VCInstallDir)PlatformSDK\include\prerelease;$(VCInstallDir)PlatformSDK\include;$(FrameworkSDKDir)include"
135 "Source Dirs"="$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src"
136 "Reference Dirs"=""
137 ''','\n')
138
139 regdata_7_1 = string.split(r'''
140 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1]
141 @=""
142 "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\"
143 "ThisVersionSolutionCLSID"="{246C57AE-40DD-4d6b-9E8D-B0F5757BB2A8}"
144 "ThisVersionDTECLSID"="{8CD2DD97-4EC1-4bc4-9359-89A3EEDD57A6}"
145 "InstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
146 "CLR Version"="v1.1.4322"
147 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts]
148 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Smart Device Extensions]
149 "UseInterface"=dword:00000001
150 "VS7InstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
151 "VBDeviceInstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VB7\"
152 "CSharpDeviceInstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
153 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual Basic.NET]
154 "UseInterface"=dword:00000001
155 "Package"="{164B10B9-B200-11D0-8C61-00A0C91E29D5}"
156 "DefaultProductAttribute"="VB"
157 @=""
158 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual C#]
159 "DefaultProductAttribute"="C#"
160 "UseInterface"=dword:00000001
161 "Package"="{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}"
162 @=""
163 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual JSharp]
164 @=""
165 "Package"="{E6FDF8B0-F3D1-11D4-8576-0002A516ECE8}"
166 "UseInterface"=dword:00000001
167 "DefaultProductAttribute"="Visual JSharp"
168 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\VisualC++]
169 "UseInterface"=dword:00000001
170 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
171 "DefaultProductAttribute"="VC"
172 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup]
173 "Dbghelp_path"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
174 "dw_dir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
175 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\CSDPROJ]
176 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
177 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\JSHPROJ]
178 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VJ#\"
179 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing]
180 "CurrentSULevel"=dword:00000000
181 "CurrentSPLevel"=dword:00000000
182 "Server Path"=""
183 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing\Package]
184 "FxSDK"=""
185 "VB"=""
186 "VC"=""
187 "VCS"=""
188 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing\SKU]
189 "Visual Studio .NET Professional 2003 - English"="{20610409-CA18-41A6-9E21-A93AE82EE7C5}"
190 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VB]
191 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\"
192 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VBDPROJ]
193 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\"
194 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VC]
195 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\"
196 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VC#]
197 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
198 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Visual Studio .NET Professional 2003 - English]
199 "InstallSuccess"=dword:00000001
200 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS]
201 "EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
202 "EnvironmentPath"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
203 "VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
204 "MSMDir"="C:\Program Files\Common Files\Merge Modules\"
205 "VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\"
206 "VS7CommonDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\"
207 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
208 "VSUpdateDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Setup\VSUpdate\"
209 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS\BuildNumber]
210 "1033"="7.1.3088"
211 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS\Pro]
212 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
213 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC]
214 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO]
215 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
216 @="{759354D0-6B42-4705-AFFB-56E34D2BC3D4}"
217 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]
218 "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"
219 "Library Dirs"="$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)PlatformSDK\lib\prerelease;$(VCInstallDir)PlatformSDK\lib;$(FrameworkSDKDir)lib"
220 "Include Dirs"="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(VCInstallDir)PlatformSDK\include\prerelease;$(VCInstallDir)PlatformSDK\include;$(FrameworkSDKDir)include"
221 "Source Dirs"="$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src"
222 "Reference Dirs"="$(FrameWorkDir)$(FrameWorkVersion)"
223 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
224 "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
225 "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc"
226 "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
227 "VCMIDLTool"="*.idl;*.odl"
228 "VCCustomBuildTool"="*.bat"
229 "VCResourceCompilerTool"="*.rc"
230 "VCPreBuildEventTool"="*.bat"
231 "VCPreLinkEventTool"="*.bat"
232 "VCPostBuildEventTool"="*.bat"
233 "VCBscMakeTool"="*.sbr"
234 "VCNMakeTool"=""
235 "VCWebServiceProxyGeneratorTool"="*.discomap"
236 "VCWebDeploymentTool"=""
237 "VCALinkTool"="*.resources"
238 "VCManagedResourceCompilerTool"="*.resx"
239 "VCXMLDataGeneratorTool"="*.xsd"
240 "VCManagedWrapperGeneratorTool"=""
241 "VCAuxiliaryManagedWrapperGeneratorTool"=""
242 "VCPrimaryInteropTool"=""
243 ''','\n')
244
245 regdata_8exp = string.split(r'''
246 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0]
247 "CLR Version"="v2.0.50727"
248 "ApplicationID"="VCExpress"
249 "SecurityAppID"="{741726F6-1EAE-4680-86A6-6085E8872CF8}"
250 "InstallDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
251 "EnablePreloadCLR"=dword:00000001
252 "RestoreAppPath"=dword:00000001
253 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\InstalledProducts]
254 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\InstalledProducts\Microsoft Visual C++]
255 "UseInterface"=dword:00000001
256 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
257 "DefaultProductAttribute"="VC"
258 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup]
259 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup\VC]
260 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\VC\"
261 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup\VS]
262 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
263 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC]
264 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO]
265 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
266 @="{72f11281-2429-11d7-8bf6-00b0d03daa06}"
267 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
268 "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
269 "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc;*.licenses"
270 "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
271 "VCMIDLTool"="*.idl;*.odl"
272 "VCCustomBuildTool"="*.bat"
273 "VCResourceCompilerTool"="*.rc"
274 "VCPreBuildEventTool"="*.bat"
275 "VCPreLinkEventTool"="*.bat"
276 "VCPostBuildEventTool"="*.bat"
277 "VCBscMakeTool"="*.sbr"
278 "VCFxCopTool"="*.dll;*.exe"
279 "VCNMakeTool"=""
280 "VCWebServiceProxyGeneratorTool"="*.discomap"
281 "VCWebDeploymentTool"=""
282 "VCALinkTool"="*.resources"
283 "VCManagedResourceCompilerTool"="*.resx"
284 "VCXMLDataGeneratorTool"="*.xsd"
285 "VCManifestTool"="*.manifest"
286 "VCXDCMakeTool"="*.xdc"
287 ''','\n')
288
289 regdata_80 = string.split(r'''
290 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0]
291 "CLR Version"="v2.0.50727"
292 "ApplicationID"="VisualStudio"
293 "ThisVersionDTECLSID"="{BA018599-1DB3-44f9-83B4-461454C84BF8}"
294 "ThisVersionSolutionCLSID"="{1B2EEDD6-C203-4d04-BD59-78906E3E8AAB}"
295 "SecurityAppID"="{DF99D4F5-9F04-4CEF-9D39-095821B49C77}"
296 "InstallDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
297 "EnablePreloadCLR"=dword:00000001
298 "RestoreAppPath"=dword:00000001
299 "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\"
300 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\InstalledProducts]
301 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\InstalledProducts\Microsoft Visual C++]
302 "UseInterface"=dword:00000001
303 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
304 "DefaultProductAttribute"="VC"
305 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup]
306 "Dbghelp_path"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
307 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\EF]
308 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\EnterpriseFrameworks\"
309 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\Microsoft Visual Studio 2005 Professional Edition - ENU]
310 "SrcPath"="d:\vs\"
311 "InstallSuccess"=dword:00000001
312 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VC]
313 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\VC\"
314 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS]
315 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
316 "VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
317 "EnvironmentPath"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
318 "EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
319 "VS7CommonDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\"
320 "VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\"
321 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS\BuildNumber]
322 "1033"="8.0.50727.42"
323 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS\Pro]
324 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
325 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC]
326 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO]
327 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
328 @="{72f11281-2429-11d7-8bf6-00b0d03daa06}"
329 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
330 "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
331 "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc;*.licenses"
332 "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
333 "VCMIDLTool"="*.idl;*.odl"
334 "VCCustomBuildTool"="*.bat"
335 "VCResourceCompilerTool"="*.rc"
336 "VCPreBuildEventTool"="*.bat"
337 "VCPreLinkEventTool"="*.bat"
338 "VCPostBuildEventTool"="*.bat"
339 "VCBscMakeTool"="*.sbr"
340 "VCFxCopTool"="*.dll;*.exe"
341 "VCNMakeTool"=""
342 "VCWebServiceProxyGeneratorTool"="*.discomap"
343 "VCWebDeploymentTool"=""
344 "VCALinkTool"="*.resources"
345 "VCManagedResourceCompilerTool"="*.resx"
346 "VCXMLDataGeneratorTool"="*.xsd"
347 "VCManifestTool"="*.manifest"
348 "VCXDCMakeTool"="*.xdc"
349 ''','\n')
350
351 regdata_cv = string.split(r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
352 "ProgramFilesDir"="C:\Program Files"
353 "CommonFilesDir"="C:\Program Files\Common Files"
354 "MediaPath"="C:\WINDOWS\Media"
355 ''','\n')
356
357
358 regdata_none = []
359
360 class DummyEnv:
361     def __init__(self, dict=None):
362         if dict:
363             self.dict = dict
364         else:
365             self.dict = {}
366
367     def Dictionary(self, key = None):
368         if not key:
369             return self.dict
370         return self.dict[key]
371
372     def __setitem__(self,key,value):
373         self.dict[key] = value
374
375     def __getitem__(self,key):
376         return self.dict[key]
377
378     def has_key(self,name):
379         return self.dict.has_key(name)
380
381 class RegKey:
382     """key class for storing an 'open' registry key"""
383     def __init__(self,key):
384         self.key = key
385
386 # Warning: this is NOT case-insensitive, unlike the Windows registry.
387 # So e.g. HKLM\Software is NOT the same key as HKLM\SOFTWARE.
388 class RegNode:
389     """node in the dummy registry"""
390     def __init__(self,name):
391         self.valdict = {}
392         self.keydict = {}
393         self.keyarray = []
394         self.valarray = []
395         self.name = name
396
397     def value(self,val):
398         if self.valdict.has_key(val):
399             return (self.valdict[val],1)
400         else:
401             raise SCons.Util.RegError
402
403     def addValue(self,name,val):
404         self.valdict[name] = val
405         self.valarray.append(name)
406
407     def valindex(self,index):
408         rv = None
409         try:
410             rv = (self.valarray[index],self.valdict[self.valarray[index]],1)
411         except KeyError:
412             raise SCons.Util.RegError
413         return rv
414
415     def key(self,key,sep = '\\'):
416         if key.find(sep) != -1:
417             keyname, subkeys = key.split(sep,1)
418         else:
419             keyname = key
420             subkeys = ""
421         try:
422             # recurse, and return the lowest level key node
423             if subkeys:
424                 return self.keydict[keyname].key(subkeys)
425             else:
426                 return self.keydict[keyname]
427         except KeyError:
428             raise SCons.Util.RegError
429
430     def addKey(self,name,sep = '\\'):
431         if string.find(name, sep) != -1:
432             keyname, subkeys = string.split(name, sep, 1)
433         else:
434             keyname = name
435             subkeys = ""
436
437         if not self.keydict.has_key(keyname):
438             self.keydict[keyname] = RegNode(keyname)
439             self.keyarray.append(keyname)
440
441         # recurse, and return the lowest level key node
442         if subkeys:
443             return self.keydict[keyname].addKey(subkeys)
444         else:
445             return self.keydict[keyname]
446
447     def keyindex(self,index):
448         return self.keydict[self.keyarray[index]]
449
450     def __str__(self):
451         return self._doStr()
452
453     def _doStr(self, indent = ''):
454         rv = ""
455         for value in self.valarray:
456             rv = rv + '%s"%s" = "%s"\n' % (indent, value, self.valdict[value])
457         for key in self.keyarray:
458             rv = rv + "%s%s: {\n"%(indent, key)
459             rv = rv + self.keydict[key]._doStr(indent + '  ')
460             rv = rv + indent + '}\n'
461         return rv
462
463 class DummyRegistry:
464     """registry class for storing fake registry attributes"""
465     def __init__(self,data):
466         """parse input data into the fake registry"""
467         self.root = RegNode('REGISTRY')
468         self.root.addKey('HKEY_LOCAL_MACHINE')
469         self.root.addKey('HKEY_CURRENT_USER')
470         self.root.addKey('HKEY_USERS')
471         self.root.addKey('HKEY_CLASSES_ROOT')
472
473         self.parse(data)
474
475     def parse(self, data):
476         parent = self.root
477         keymatch = re.compile('^\[(.*)\]$')
478         valmatch = re.compile('^(?:"(.*)"|[@])="(.*)"$')
479         for line in data:
480             m1 = keymatch.match(line)
481             if m1:
482                 # add a key, set it to current parent
483                 parent = self.root.addKey(m1.group(1))
484             else:
485                 m2 = valmatch.match(line)
486                 if m2:
487                     parent.addValue(m2.group(1),m2.group(2))
488
489     def OpenKeyEx(self,root,key):
490         if root == SCons.Util.HKEY_CLASSES_ROOT:
491             mykey = 'HKEY_CLASSES_ROOT\\' + key
492         if root == SCons.Util.HKEY_USERS:
493             mykey = 'HKEY_USERS\\' + key
494         if root == SCons.Util.HKEY_CURRENT_USER:
495             mykey = 'HKEY_CURRENT_USER\\' + key
496         if root == SCons.Util.HKEY_LOCAL_MACHINE:
497             mykey = 'HKEY_LOCAL_MACHINE\\' + key
498         debug("Open Key:%s"%mykey)
499         return self.root.key(mykey)
500
501 def DummyOpenKeyEx(root, key):
502     return registry.OpenKeyEx(root,key)
503
504 def DummyEnumKey(key, index):
505     rv = None
506     try:
507         rv = key.keyarray[index]
508     except IndexError:
509         raise SCons.Util.RegError
510 #    print "Enum Key",key.name,"[",index,"] =>",rv
511     return rv
512
513 def DummyEnumValue(key, index):
514     rv = key.valindex(index)
515 #    print "Enum Value",key.name,"[",index,"] =>",rv
516     return rv
517
518 def DummyQueryValue(key, value):
519     rv = key.value(value)
520 #    print "Query Value",key.name+"\\"+value,"=>",rv
521     return rv
522
523 def DummyExists(path):
524     return 1
525
526 class msvsTestCase(unittest.TestCase):
527     """This test case is run several times with different defaults.
528     See its subclasses below."""
529     def setUp(self):
530         debug("THIS TYPE :%s"%self)
531         global registry
532         registry = self.registry
533         from SCons.Tool.MSCommon.vs import reset_installed_visual_studios
534         reset_installed_visual_studios()
535
536     def test_get_default_version(self):
537         """Test retrieval of the default visual studio version"""
538         
539         debug("Testing for default version %s"%self.default_version)
540         env = DummyEnv()
541         v1 = get_default_version(env)
542         assert env['MSVS_VERSION'] == self.default_version, \
543                ("env['MSVS_VERSION'] != self.default_version",self.default_version, env['MSVS_VERSION'])
544         assert env['MSVS']['VERSION'] == self.default_version, \
545                ("env['MSVS']['VERSION'] != self.default_version",self.default_version, env['MSVS']['VERSION'])
546         assert v1 == self.default_version, (self.default_version, v1)
547
548         env = DummyEnv({'MSVS_VERSION':'7.0'})
549         v2 = get_default_version(env)
550         assert env['MSVS_VERSION'] == '7.0', env['MSVS_VERSION']
551         assert env['MSVS']['VERSION'] == '7.0', env['MSVS']['VERSION']
552         assert v2 == '7.0', v2
553
554         env = DummyEnv()
555         v3 = get_default_version(env)
556         if v3 == '7.1':
557             override = '7.0'
558         else:
559             override = '7.1'
560         env['MSVS_VERSION'] = override
561         v3 = get_default_version(env)
562         assert env['MSVS_VERSION'] == override, env['MSVS_VERSION']
563         assert env['MSVS']['VERSION'] == override, env['MSVS']['VERSION']
564         assert v3 == override, v3
565
566     def _TODO_test_merge_default_version(self):
567         """Test the merge_default_version() function"""
568         pass
569
570     def test_query_versions(self):
571         """Test retrieval of the list of visual studio versions"""
572         v1 = query_versions()
573         assert not v1 or str(v1[0]) == self.highest_version, \
574                (v1, self.highest_version)
575         assert len(v1) == self.number_of_versions, v1
576
577 class msvs6aTestCase(msvsTestCase):
578     """Test MSVS 6 Registry"""
579     registry = DummyRegistry(regdata_6a + regdata_cv)
580     default_version = '6.0'
581     highest_version = '6.0'
582     number_of_versions = 1
583     install_locs = {
584         '6.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio\\VC98', 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin'},
585         '7.0' : {},
586         '7.1' : {},
587         '8.0' : {},
588         '8.0Exp' : {},
589     }
590     default_install_loc = install_locs['6.0']
591
592 class msvs6bTestCase(msvsTestCase):
593     """Test Other MSVS 6 Registry"""
594     registry = DummyRegistry(regdata_6b + regdata_cv)
595     default_version = '6.0'
596     highest_version = '6.0'
597     number_of_versions = 1
598     install_locs = {
599         '6.0' : {'VSINSTALLDIR': 'C:\\VS6\\VC98', 'VCINSTALLDIR': 'C:\\VS6\\VC98\\Bin'},
600         '7.0' : {},
601         '7.1' : {},
602         '8.0' : {},
603         '8.0Exp' : {},
604     }
605     default_install_loc = install_locs['6.0']
606
607 class msvs6and7TestCase(msvsTestCase):
608     """Test MSVS 6 & 7 Registry"""
609     registry = DummyRegistry(regdata_6b + regdata_7 + regdata_cv)
610     default_version = '7.0'
611     highest_version = '7.0'
612     number_of_versions = 2
613     install_locs = {
614         '6.0' : {'VSINSTALLDIR': 'C:\\VS6\\VC98',
615                  'VCINSTALLDIR': 'C:\\VS6\\VC98\\Bin'},
616         '7.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7',
617                  'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7\\Tools'},
618         '7.1' : {},
619         '8.0' : {},
620         '8.0Exp' : {},
621     }
622     default_install_loc = install_locs['7.0']
623
624 class msvs7TestCase(msvsTestCase):
625     """Test MSVS 7 Registry"""
626     registry = DummyRegistry(regdata_7 + regdata_cv)
627     default_version = '7.0'
628     highest_version = '7.0'
629     number_of_versions = 1
630     install_locs = {
631         '6.0' : {},
632         '7.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7',
633                  'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7\\Tools'},
634         '7.1' : {},
635         '8.0' : {},
636         '8.0Exp' : {},
637     }
638     default_install_loc = install_locs['7.0']
639
640 class msvs71TestCase(msvsTestCase):
641     """Test MSVS 7.1 Registry"""
642     registry = DummyRegistry(regdata_7_1 + regdata_cv)
643     default_version = '7.1'
644     highest_version = '7.1'
645     number_of_versions = 1
646     install_locs = {
647         '6.0' : {},
648         '7.0' : {},
649         '7.1' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7',
650                  'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\Tools'},
651         '8.0' : {},
652         '8.0Exp' : {},
653     }
654     default_install_loc = install_locs['7.1']
655
656 class msvs8ExpTestCase(msvsTestCase): # XXX: only one still not working
657     """Test MSVS 8 Express Registry"""
658     registry = DummyRegistry(regdata_8exp + regdata_cv)
659     default_version = '8.0Exp'
660     highest_version = '8.0Exp'
661     number_of_versions = 1
662     install_locs = {
663         '6.0' : {},
664         '7.0' : {},
665         '7.1' : {},
666         '8.0' : {},
667         '8.0Exp' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8',
668                     'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8\\VC'},
669     }
670     default_install_loc = install_locs['8.0Exp']
671
672 class msvs80TestCase(msvsTestCase):
673     """Test MSVS 8 Registry"""
674     registry = DummyRegistry(regdata_80 + regdata_cv)
675     default_version = '8.0'
676     highest_version = '8.0'
677     number_of_versions = 1
678     install_locs = {
679         '6.0' : {},
680         '7.0' : {},
681         '7.1' : {},
682         '8.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8',
683                  'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8\\VC'},
684         '8.0Exp' : {},
685     }
686     default_install_loc = install_locs['8.0']
687
688 class msvsEmptyTestCase(msvsTestCase):
689     """Test Empty Registry"""
690     registry = DummyRegistry(regdata_none)
691     default_version = '9.0'
692     highest_version = None
693     number_of_versions = 0
694     install_locs = {
695         '6.0' : {},
696         '7.0' : {},
697         '7.1' : {},
698         '8.0' : {},
699         '8.0Exp' : {},
700     }
701     default_install_loc = install_locs['8.0Exp']
702
703 if __name__ == "__main__":
704
705     # only makes sense to test this on win32
706     if sys.platform != 'win32':
707         sys.stdout.write("NO RESULT for msvsTests.py:  '%s' is not win32\n" % sys.platform)
708         sys.exit(0)
709
710     SCons.Util.RegOpenKeyEx    = DummyOpenKeyEx
711     SCons.Util.RegEnumKey      = DummyEnumKey
712     SCons.Util.RegEnumValue    = DummyEnumValue
713     SCons.Util.RegQueryValueEx = DummyQueryValue
714     
715     os.path.exists = DummyExists # make sure all files exist :-)
716     os.path.isfile = DummyExists # make sure all files are files :-)
717     os.path.isdir  = DummyExists # make sure all dirs are dirs :-)
718
719     exit_val = 0
720
721     test_classes = [
722         msvs6aTestCase,
723         msvs6bTestCase,
724         msvs6and7TestCase,
725         msvs7TestCase,
726         msvs71TestCase,
727         msvs8ExpTestCase,
728         msvs80TestCase,
729         msvsEmptyTestCase,
730     ]
731
732     for test_class in test_classes:
733         print "TEST: ", test_class.__doc__
734         back_osenv = copy.deepcopy(os.environ)
735         try:
736             # XXX: overriding the os.environ is bad, but doing it
737             # correctly is too complicated for now. Those tests should
738             # be fixed
739             for k in ['VS71COMNTOOLS',
740                       'VS80COMNTOOLS',
741                       'VS90COMNTOOLS']:
742                 if os.environ.has_key(k):
743                     del os.environ[k]
744
745             suite = unittest.makeSuite(test_class, 'test_')
746             if not unittest.TextTestRunner().run(suite).wasSuccessful():
747                 exit_val = 1
748         finally:
749             os.env = back_osenv
750
751     sys.exit(exit_val)
752
753 # Local Variables:
754 # tab-width:4
755 # indent-tabs-mode:nil
756 # End:
757 # vim: set expandtab tabstop=4 shiftwidth=4: