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