Fix scons-local packaging test breakage in MSVS tests by correcting
[scons.git] / QMTest / TestSConsMSVS.py
1 """
2 TestSConsMSVS.py:  a testing framework for the SCons software construction
3 tool.
4
5 A TestSConsMSVS environment object is created via the usual invocation:
6
7     test = TestSConsMSVS()
8
9 TestSConsMSVS is a subsclass of TestSCons, which is in turn a subclass
10 of TestCommon, which is in turn is a subclass of TestCmd), and hence
11 has available all of the methods and attributes from those classes,
12 as well as any overridden or additional methods or attributes defined
13 in this subclass.
14 """
15
16 # __COPYRIGHT__
17
18 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
19
20 import os
21 import string
22 import sys
23
24 from TestSCons import *
25 from TestSCons import __all__
26
27
28
29 expected_dspfile_6_0 = '''\
30 # Microsoft Developer Studio Project File - Name="Test" - Package Owner=<4>
31 # Microsoft Developer Studio Generated Build File, Format Version 6.00
32 # ** DO NOT EDIT **
33
34 # TARGTYPE "Win32 (x86) External Target" 0x0106
35
36 CFG=Test - Win32 Release
37 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
38 !MESSAGE use the Export Makefile command and run
39 !MESSAGE 
40 !MESSAGE NMAKE /f "Test.mak".
41 !MESSAGE 
42 !MESSAGE You can specify a configuration when running NMAKE
43 !MESSAGE by defining the macro CFG on the command line. For example:
44 !MESSAGE 
45 !MESSAGE NMAKE /f "Test.mak" CFG="Test - Win32 Release"
46 !MESSAGE 
47 !MESSAGE Possible choices for configuration are:
48 !MESSAGE 
49 !MESSAGE "Test - Win32 Release" (based on "Win32 (x86) External Target")
50 !MESSAGE 
51
52 # Begin Project
53 # PROP AllowPerConfigDependencies 0
54 # PROP Scc_ProjName ""
55 # PROP Scc_LocalPath ""
56
57 !IF  "$(CFG)" == "Test - Win32 Release"
58
59 # PROP BASE Use_MFC 0
60 # PROP BASE Use_Debug_Libraries 0
61 # PROP BASE Output_Dir ""
62 # PROP BASE Intermediate_Dir ""
63 # PROP BASE Cmd_Line "echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
64 # PROP BASE Rebuild_Opt "-c && echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
65 # PROP BASE Target_File "Test.exe"
66 # PROP BASE Bsc_Name ""
67 # PROP BASE Target_Dir ""
68 # PROP Use_MFC 0
69 # PROP Use_Debug_Libraries 0
70 # PROP Output_Dir ""
71 # PROP Intermediate_Dir ""
72 # PROP Cmd_Line "echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
73 # PROP Rebuild_Opt "-c && echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
74 # PROP Target_File "Test.exe"
75 # PROP Bsc_Name ""
76 # PROP Target_Dir ""
77
78 !ENDIF
79
80 # Begin Target
81
82 # Name "Test - Win32 Release"
83
84 !IF  "$(CFG)" == "Test - Win32 Release"
85
86 !ENDIF 
87
88 # Begin Group "Header Files"
89
90 # PROP Default_Filter "h;hpp;hxx;hm;inl"
91 # Begin Source File
92
93 SOURCE="sdk.h"
94 # End Source File
95 # End Group
96 # Begin Group "Local Headers"
97
98 # PROP Default_Filter "h;hpp;hxx;hm;inl"
99 # Begin Source File
100
101 SOURCE="test.h"
102 # End Source File
103 # End Group
104 # Begin Group "Other Files"
105
106 # PROP Default_Filter ""
107 # Begin Source File
108
109 SOURCE="readme.txt"
110 # End Source File
111 # End Group
112 # Begin Group "Resource Files"
113
114 # PROP Default_Filter "r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
115 # Begin Source File
116
117 SOURCE="test.rc"
118 # End Source File
119 # End Group
120 # Begin Group "Source Files"
121
122 # PROP Default_Filter "cpp;c;cxx;l;y;def;odl;idl;hpj;bat"
123 # Begin Source File
124
125 SOURCE="test.c"
126 # End Source File
127 # End Group
128 # Begin Source File
129
130 SOURCE="<SCONSCRIPT>"
131 # End Source File
132 # End Target
133 # End Project
134 '''
135
136 expected_dswfile_6_0 = '''\
137 Microsoft Developer Studio Workspace File, Format Version 6.00
138 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
139
140 ###############################################################################
141
142 Project: "Test"="Test.dsp" - Package Owner=<4>
143
144 Package=<5>
145 {{{
146 }}}
147
148 Package=<4>
149 {{{
150 }}}
151
152 ###############################################################################
153
154 Global:
155
156 Package=<5>
157 {{{
158 }}}
159
160 Package=<3>
161 {{{
162 }}}
163
164 ###############################################################################
165 '''
166
167 SConscript_contents_6_0 = """\
168 env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='6.0')
169
170 testsrc = ['test.c']
171 testincs = ['sdk.h']
172 testlocalincs = ['test.h']
173 testresources = ['test.rc']
174 testmisc = ['readme.txt']
175
176 env.MSVSProject(target = 'Test.dsp',
177                 srcs = testsrc,
178                 incs = testincs,
179                 localincs = testlocalincs,
180                 resources = testresources,
181                 misc = testmisc,
182                 buildtarget = 'Test.exe',
183                 variant = 'Release')
184 """
185
186
187
188 expected_slnfile_7_0 = """\
189 Microsoft Visual Studio Solution File, Format Version 7.00
190 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "{E5466E26-0003-F18B-8F8A-BCD76C86388D}"
191 EndProject
192 Global
193 \tGlobalSection(SolutionConfiguration) = preSolution
194 \t\tConfigName.0 = Release
195 \tEndGlobalSection
196 \tGlobalSection(ProjectDependencies) = postSolution
197 \tEndGlobalSection
198 \tGlobalSection(ProjectConfiguration) = postSolution
199 \t\t{E5466E26-0003-F18B-8F8A-BCD76C86388D}.Release.ActiveCfg = Release|Win32
200 \t\t{E5466E26-0003-F18B-8F8A-BCD76C86388D}.Release.Build.0 = Release|Win32
201 \tEndGlobalSection
202 \tGlobalSection(ExtensibilityGlobals) = postSolution
203 \tEndGlobalSection
204 \tGlobalSection(ExtensibilityAddIns) = postSolution
205 \tEndGlobalSection
206 EndGlobal
207 """
208
209 expected_vcprojfile_7_0 = """\
210 <?xml version="1.0" encoding = "Windows-1252"?>
211 <VisualStudioProject
212 \tProjectType="Visual C++"
213 \tVersion="7.00"
214 \tName="Test"
215 \tProjectGUID=""
216 \tSccProjectName=""
217 \tSccLocalPath=""
218 \tKeyword="MakeFileProj">
219 \t<Platforms>
220 \t\t<Platform
221 \t\t\tName="Win32"/>
222 \t</Platforms>
223 \t<Configurations>
224 \t\t<Configuration
225 \t\t\tName="Release|Win32"
226 \t\t\tOutputDirectory=""
227 \t\t\tIntermediateDirectory=""
228 \t\t\tConfigurationType="0"
229 \t\t\tUseOfMFC="0"
230 \t\t\tATLMinimizesCRunTimeLibraryUsage="FALSE">
231 \t\t\t<Tool
232 \t\t\t\tName="VCNMakeTool"
233 \t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
234 \t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
235 \t\t\t\tRebuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
236 \t\t\t\tOutput="Test.exe"/>
237 \t\t</Configuration>
238 \t</Configurations>
239 \t<Files>
240 \t\t<Filter
241 \t\t\tName="Header Files"
242 \t\t\tFilter="h;hpp;hxx;hm;inl">
243 \t\t\t<File
244 \t\t\t\tRelativePath="sdk.h">
245 \t\t\t</File>
246 \t\t</Filter>
247 \t\t<Filter
248 \t\t\tName="Local Headers"
249 \t\t\tFilter="h;hpp;hxx;hm;inl">
250 \t\t\t<File
251 \t\t\t\tRelativePath="test.h">
252 \t\t\t</File>
253 \t\t</Filter>
254 \t\t<Filter
255 \t\t\tName="Other Files"
256 \t\t\tFilter="">
257 \t\t\t<File
258 \t\t\t\tRelativePath="readme.txt">
259 \t\t\t</File>
260 \t\t</Filter>
261 \t\t<Filter
262 \t\t\tName="Resource Files"
263 \t\t\tFilter="r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe">
264 \t\t\t<File
265 \t\t\t\tRelativePath="test.rc">
266 \t\t\t</File>
267 \t\t</Filter>
268 \t\t<Filter
269 \t\t\tName="Source Files"
270 \t\t\tFilter="cpp;c;cxx;l;y;def;odl;idl;hpj;bat">
271 \t\t\t<File
272 \t\t\t\tRelativePath="test1.cpp">
273 \t\t\t</File>
274 \t\t\t<File
275 \t\t\t\tRelativePath="test2.cpp">
276 \t\t\t</File>
277 \t\t</Filter>
278 \t\t<File
279 \t\t\tRelativePath="<SCONSCRIPT>">
280 \t\t</File>
281 \t</Files>
282 \t<Globals>
283 \t</Globals>
284 </VisualStudioProject>
285 """
286
287 SConscript_contents_7_0 = """\
288 env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='7.0')
289
290 testsrc = ['test1.cpp', 'test2.cpp']
291 testincs = ['sdk.h']
292 testlocalincs = ['test.h']
293 testresources = ['test.rc']
294 testmisc = ['readme.txt']
295
296 env.MSVSProject(target = 'Test.vcproj',
297                 slnguid = '{SLNGUID}',
298                 srcs = testsrc,
299                 incs = testincs,
300                 localincs = testlocalincs,
301                 resources = testresources,
302                 misc = testmisc,
303                 buildtarget = 'Test.exe',
304                 variant = 'Release')
305 """
306
307
308
309 expected_slnfile_7_1 = """\
310 Microsoft Visual Studio Solution File, Format Version 8.00
311 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "{E5466E26-0003-F18B-8F8A-BCD76C86388D}"
312 \tProjectSection(ProjectDependencies) = postProject
313 \tEndProjectSection
314 EndProject
315 Global
316 \tGlobalSection(SolutionConfiguration) = preSolution
317 \t\tConfigName.0 = Release
318 \tEndGlobalSection
319 \tGlobalSection(ProjectConfiguration) = postSolution
320 \t\t{E5466E26-0003-F18B-8F8A-BCD76C86388D}.Release.ActiveCfg = Release|Win32
321 \t\t{E5466E26-0003-F18B-8F8A-BCD76C86388D}.Release.Build.0 = Release|Win32
322 \tEndGlobalSection
323 \tGlobalSection(ExtensibilityGlobals) = postSolution
324 \tEndGlobalSection
325 \tGlobalSection(ExtensibilityAddIns) = postSolution
326 \tEndGlobalSection
327 EndGlobal
328 """
329
330 expected_vcprojfile_7_1 = """\
331 <?xml version="1.0" encoding = "Windows-1252"?>
332 <VisualStudioProject
333 \tProjectType="Visual C++"
334 \tVersion="7.10"
335 \tName="Test"
336 \tProjectGUID=""
337 \tSccProjectName=""
338 \tSccLocalPath=""
339 \tKeyword="MakeFileProj">
340 \t<Platforms>
341 \t\t<Platform
342 \t\t\tName="Win32"/>
343 \t</Platforms>
344 \t<Configurations>
345 \t\t<Configuration
346 \t\t\tName="Release|Win32"
347 \t\t\tOutputDirectory=""
348 \t\t\tIntermediateDirectory=""
349 \t\t\tConfigurationType="0"
350 \t\t\tUseOfMFC="0"
351 \t\t\tATLMinimizesCRunTimeLibraryUsage="FALSE">
352 \t\t\t<Tool
353 \t\t\t\tName="VCNMakeTool"
354 \t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
355 \t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
356 \t\t\t\tRebuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
357 \t\t\t\tOutput="Test.exe"/>
358 \t\t</Configuration>
359 \t</Configurations>
360 \t<References>
361 \t</References>
362 \t<Files>
363 \t\t<Filter
364 \t\t\tName="Header Files"
365 \t\t\tFilter="h;hpp;hxx;hm;inl">
366 \t\t\t<File
367 \t\t\t\tRelativePath="sdk.h">
368 \t\t\t</File>
369 \t\t</Filter>
370 \t\t<Filter
371 \t\t\tName="Local Headers"
372 \t\t\tFilter="h;hpp;hxx;hm;inl">
373 \t\t\t<File
374 \t\t\t\tRelativePath="test.h">
375 \t\t\t</File>
376 \t\t</Filter>
377 \t\t<Filter
378 \t\t\tName="Other Files"
379 \t\t\tFilter="">
380 \t\t\t<File
381 \t\t\t\tRelativePath="readme.txt">
382 \t\t\t</File>
383 \t\t</Filter>
384 \t\t<Filter
385 \t\t\tName="Resource Files"
386 \t\t\tFilter="r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe">
387 \t\t\t<File
388 \t\t\t\tRelativePath="test.rc">
389 \t\t\t</File>
390 \t\t</Filter>
391 \t\t<Filter
392 \t\t\tName="Source Files"
393 \t\t\tFilter="cpp;c;cxx;l;y;def;odl;idl;hpj;bat">
394 \t\t\t<File
395 \t\t\t\tRelativePath="test1.cpp">
396 \t\t\t</File>
397 \t\t\t<File
398 \t\t\t\tRelativePath="test2.cpp">
399 \t\t\t</File>
400 \t\t</Filter>
401 \t\t<File
402 \t\t\tRelativePath="<SCONSCRIPT>">
403 \t\t</File>
404 \t</Files>
405 \t<Globals>
406 \t</Globals>
407 </VisualStudioProject>
408 """
409
410 SConscript_contents_7_1 = """\
411 env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='7.1')
412
413 testsrc = ['test1.cpp', 'test2.cpp']
414 testincs = ['sdk.h']
415 testlocalincs = ['test.h']
416 testresources = ['test.rc']
417 testmisc = ['readme.txt']
418
419 env.MSVSProject(target = 'Test.vcproj',
420                 slnguid = '{SLNGUID}',
421                 srcs = testsrc,
422                 incs = testincs,
423                 localincs = testlocalincs,
424                 resources = testresources,
425                 misc = testmisc,
426                 buildtarget = 'Test.exe',
427                 variant = 'Release')
428 """
429
430
431
432 expected_slnfile_8_0 = """\
433 Microsoft Visual Studio Solution File, Format Version 9.00
434 # Visual Studio 2005
435 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "{E5466E26-0003-F18B-8F8A-BCD76C86388D}"
436 EndProject
437 Global
438 \tGlobalSection(SolutionConfigurationPlatforms) = preSolution
439 \t\tRelease|Win32 = Release|Win32
440 \tEndGlobalSection
441 \tGlobalSection(ProjectConfigurationPlatforms) = postSolution
442 \t\t{E5466E26-0003-F18B-8F8A-BCD76C86388D}.Release|Win32.ActiveCfg = Release|Win32
443 \t\t{E5466E26-0003-F18B-8F8A-BCD76C86388D}.Release|Win32.Build.0 = Release|Win32
444 \tEndGlobalSection
445 \tGlobalSection(SolutionProperties) = preSolution
446 \t\tHideSolutionNode = FALSE
447 \tEndGlobalSection
448 EndGlobal
449 """
450
451 expected_vcprojfile_8_0 = """\
452 <?xml version="1.0" encoding="Windows-1252"?>
453 <VisualStudioProject
454 \tProjectType="Visual C++"
455 \tVersion="8.00"
456 \tName="Test"
457 \tProjectGUID="<PROJECT_GUID>"
458 \tSccProjectName=""
459 \tSccLocalPath=""
460 \tRootNamespace="Test"
461 \tKeyword="MakeFileProj">
462 \t<Platforms>
463 \t\t<Platform
464 \t\t\tName="Win32"/>
465 \t</Platforms>
466 \t<ToolFiles>
467 \t</ToolFiles>
468 \t<Configurations>
469 \t\t<Configuration
470 \t\t\tName="Release|Win32"
471 \t\t\tConfigurationType="0"
472 \t\t\tUseOfMFC="0"
473 \t\t\tATLMinimizesCRunTimeLibraryUsage="false"
474 \t\t\t>
475 \t\t\t<Tool
476 \t\t\t\tName="VCNMakeTool"
477 \t\t\t\tBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
478 \t\t\t\tReBuildCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct &quot;Test.exe&quot;"
479 \t\t\t\tCleanCommandLine="echo Starting SCons &amp;&amp; &quot;<PYTHON>&quot; -c &quot;<SCONS_SCRIPT_MAIN_XML>&quot; -C &quot;<WORKPATH>&quot; -f SConstruct -c &quot;Test.exe&quot;"
480 \t\t\t\tOutput="Test.exe"
481 \t\t\t\tPreprocessorDefinitions=""
482 \t\t\t\tIncludeSearchPath=""
483 \t\t\t\tForcedIncludes=""
484 \t\t\t\tAssemblySearchPath=""
485 \t\t\t\tForcedUsingAssemblies=""
486 \t\t\t\tCompileAsManaged=""
487 \t\t\t/>
488 \t\t</Configuration>
489 \t</Configurations>
490 \t<References>
491 \t</References>
492 \t<Files>
493 \t\t<Filter
494 \t\t\tName="Header Files"
495 \t\t\tFilter="h;hpp;hxx;hm;inl">
496 \t\t\t<File
497 \t\t\t\tRelativePath="sdk.h">
498 \t\t\t</File>
499 \t\t</Filter>
500 \t\t<Filter
501 \t\t\tName="Local Headers"
502 \t\t\tFilter="h;hpp;hxx;hm;inl">
503 \t\t\t<File
504 \t\t\t\tRelativePath="test.h">
505 \t\t\t</File>
506 \t\t</Filter>
507 \t\t<Filter
508 \t\t\tName="Other Files"
509 \t\t\tFilter="">
510 \t\t\t<File
511 \t\t\t\tRelativePath="readme.txt">
512 \t\t\t</File>
513 \t\t</Filter>
514 \t\t<Filter
515 \t\t\tName="Resource Files"
516 \t\t\tFilter="r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe">
517 \t\t\t<File
518 \t\t\t\tRelativePath="test.rc">
519 \t\t\t</File>
520 \t\t</Filter>
521 \t\t<Filter
522 \t\t\tName="Source Files"
523 \t\t\tFilter="cpp;c;cxx;l;y;def;odl;idl;hpj;bat">
524 \t\t\t<File
525 \t\t\t\tRelativePath="test1.cpp">
526 \t\t\t</File>
527 \t\t\t<File
528 \t\t\t\tRelativePath="test2.cpp">
529 \t\t\t</File>
530 \t\t</Filter>
531 \t\t<File
532 \t\t\tRelativePath="<SCONSCRIPT>">
533 \t\t</File>
534 \t</Files>
535 \t<Globals>
536 \t</Globals>
537 </VisualStudioProject>
538 """
539
540 SConscript_contents_8_0 = """\
541 env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='8.0')
542
543 testsrc = ['test1.cpp', 'test2.cpp']
544 testincs = ['sdk.h']
545 testlocalincs = ['test.h']
546 testresources = ['test.rc']
547 testmisc = ['readme.txt']
548
549 env.MSVSProject(target = 'Test.vcproj',
550                 slnguid = '{SLNGUID}',
551                 srcs = testsrc,
552                 incs = testincs,
553                 localincs = testlocalincs,
554                 resources = testresources,
555                 misc = testmisc,
556                 buildtarget = 'Test.exe',
557                 variant = 'Release')
558 """
559
560
561
562 class TestSConsMSVS(TestSCons):
563     """Subclass for testing MSVS-specific portions of SCons."""
564
565     def msvs_versions(self):
566         if not hasattr(self, '_msvs_versions'):
567
568             # Determine the SCons version and the versions of the MSVS
569             # environments installed on the test machine.
570             #
571             # We do this by executing SCons with an SConstruct file
572             # (piped on stdin) that spits out Python assignments that
573             # we can just exec().  We construct the SCons.__"version"__
574             # string in the input here so that the SCons build itself
575             # doesn't fill it in when packaging SCons.
576             input = """\
577 import SCons
578 print "self.scons_version =", repr(SCons.__%s__)
579 env = Environment();
580 print "self._msvs_versions =", str(env['MSVS']['VERSIONS'])
581 """ % 'version'
582         
583             self.run(arguments = '-n -q -Q -f -', stdin = input)
584             exec(self.stdout())
585
586         return self._msvs_versions
587
588     def vcproj_sys_path(self, fname):
589         """
590         """
591         orig = 'sys.path = [ join(sys'
592
593         enginepath = repr(os.path.join(self._cwd, '..', 'engine'))
594         replace = 'sys.path = [ %s, join(sys' % enginepath
595
596         contents = self.read(fname)
597         contents = string.replace(contents, orig, replace)
598         self.write(fname, contents)
599
600     def msvs_substitute(self, input, msvs_ver,
601                         subdir=None, sconscript=None,
602                         python=None,
603                         project_guid=None):
604         if not hasattr(self, '_msvs_versions'):
605             self.msvs_versions()
606
607         if subdir:
608             workpath = self.workpath(subdir)
609         else:
610             workpath = self.workpath()
611
612         if sconscript is None:
613             sconscript = self.workpath('SConstruct')
614
615         if python is None:
616             python = sys.executable
617
618         if project_guid is None:
619             project_guid = "{E5466E26-0003-F18B-8F8A-BCD76C86388D}"
620
621         if os.environ.has_key('SCONS_LIB_DIR'):
622             exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % os.environ['SCONS_LIB_DIR']
623         else:
624             exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%s'), join(sys.prefix, 'scons-%s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % (self.scons_version, self.scons_version)
625         exec_script_main_xml = string.replace(exec_script_main, "'", "&apos;")
626
627         result = string.replace(input, r'<WORKPATH>', workpath)
628         result = string.replace(result, r'<PYTHON>', python)
629         result = string.replace(result, r'<SCONSCRIPT>', sconscript)
630         result = string.replace(result, r'<SCONS_SCRIPT_MAIN>', exec_script_main)
631         result = string.replace(result, r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
632         result = string.replace(result, r'<PROJECT_GUID>', project_guid)
633         return result
634
635     def get_msvs_executable(self, version):
636         """Returns a full path to the executable (MSDEV or devenv)
637         for the specified version of Visual Studio.
638         """
639         common_msdev98_bin_msdev_com = ['Common', 'MSDev98', 'Bin', 'MSDEV.COM']
640         common7_ide_devenv_com       = ['Common7', 'IDE', 'devenv.com']
641         common7_ide_vcexpress_exe    = ['Common7', 'IDE', 'VCExpress.exe']
642         sub_paths = {
643             '6.0' : [
644                 common_msdev98_bin_msdev_com,
645             ],
646             '7.0' : [
647                 common7_ide_devenv_com,
648             ],
649             '7.1' : [
650                 common7_ide_devenv_com,
651             ],
652             '8.0' : [
653                 common7_ide_devenv_com,
654                 common7_ide_vcexpress_exe,
655             ],
656         }
657         from SCons.Tool.msvs import get_msvs_install_dirs
658         vs_path = get_msvs_install_dirs(version)['VSINSTALLDIR']
659         for sp in sub_paths[version]:
660             p = apply(os.path.join, [vs_path] + sp)
661             if os.path.exists(p):
662                 return p
663         return apply(os.path.join, [vs_path] + sub_paths[version][0])