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.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Test that we can generate Visual Studio 6 project (.dsp) and solution
29 (.dsw) files that look correct.
38 test = TestSCons.TestSCons()
40 if sys.platform != 'win32':
41 msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform
46 expected_dspfile = '''\
47 # Microsoft Developer Studio Project File - Name="Test" - Package Owner=<4>
48 # Microsoft Developer Studio Generated Build File, Format Version 6.00
51 # TARGTYPE "Win32 (x86) External Target" 0x0106
53 CFG=Test - Win32 Release
54 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
55 !MESSAGE use the Export Makefile command and run
57 !MESSAGE NMAKE /f "Test.mak".
59 !MESSAGE You can specify a configuration when running NMAKE
60 !MESSAGE by defining the macro CFG on the command line. For example:
62 !MESSAGE NMAKE /f "Test.mak" CFG="Test - Win32 Release"
64 !MESSAGE Possible choices for configuration are:
66 !MESSAGE "Test - Win32 Release" (based on "Win32 (x86) External Target")
70 # PROP AllowPerConfigDependencies 0
71 # PROP Scc_ProjName ""
72 # PROP Scc_LocalPath ""
74 !IF "$(CFG)" == "Test - Win32 Release"
77 # PROP BASE Use_Debug_Libraries 0
78 # PROP BASE Output_Dir ""
79 # PROP BASE Intermediate_Dir ""
80 # PROP BASE Cmd_Line "echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
81 # PROP BASE Rebuild_Opt "-c && echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
82 # PROP BASE Target_File "Test.exe"
83 # PROP BASE Bsc_Name ""
84 # PROP BASE Target_Dir ""
86 # PROP Use_Debug_Libraries 0
88 # PROP Intermediate_Dir ""
89 # PROP Cmd_Line "echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
90 # PROP Rebuild_Opt "-c && echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN>" -C "<WORKPATH>" -f SConstruct "Test.exe""
91 # PROP Target_File "Test.exe"
99 # Name "Test - Win32 Release"
101 !IF "$(CFG)" == "Test - Win32 Release"
105 # Begin Group "Header Files"
107 # PROP Default_Filter "h;hpp;hxx;hm;inl"
113 # Begin Group "Local Headers"
115 # PROP Default_Filter "h;hpp;hxx;hm;inl"
121 # Begin Group "Other Files"
123 # PROP Default_Filter ""
129 # Begin Group "Resource Files"
131 # PROP Default_Filter "r;rc;ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
137 # Begin Group "Source Files"
139 # PROP Default_Filter "cpp;c;cxx;l;y;def;odl;idl;hpj;bat"
147 SOURCE="<SCONSCRIPT>"
153 expected_dswfile = '''\
154 Microsoft Developer Studio Workspace File, Format Version 6.00
155 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
157 ###############################################################################
159 Project: "Test"="Test.dsp" - Package Owner=<4>
169 ###############################################################################
181 ###############################################################################
186 SConscript_contents = """\
187 env=Environment(tools=['msvs'], MSVS_VERSION = '6.0')
191 testlocalincs = ['test.h']
192 testresources = ['test.rc']
193 testmisc = ['readme.txt']
195 env.MSVSProject(target = 'Test.dsp',
198 localincs = testlocalincs,
199 resources = testresources,
201 buildtarget = 'Test.exe',
209 test.write(['work1', 'SConstruct'], SConscript_contents)
211 test.run(chdir='work1', arguments="Test.dsp")
213 test.must_exist(test.workpath('work1', 'Test.dsp'))
214 dsp = test.read(['work1', 'Test.dsp'], 'r')
215 expect = test.msvs_substitute(expected_dspfile, '6.0', 'work1', 'SConstruct')
216 # don't compare the pickled data
217 assert dsp[:len(expect)] == expect, test.diff_substr(expect, dsp)
219 test.must_exist(test.workpath('work1', 'Test.dsw'))
220 dsw = test.read(['work1', 'Test.dsw'], 'r')
221 expect = test.msvs_substitute(expected_dswfile, '6.0', 'work1', 'SConstruct')
222 assert dsw == expect, test.diff_substr(expect, dsw)
224 test.run(chdir='work1', arguments='-c .')
226 test.must_not_exist(test.workpath('work1', 'Test.dsp'))
227 test.must_not_exist(test.workpath('work1', 'Test.dsw'))
229 test.run(chdir='work1', arguments='Test.dsp')
231 test.must_exist(test.workpath('work1', 'Test.dsp'))
232 test.must_exist(test.workpath('work1', 'Test.dsw'))
234 test.run(chdir='work1', arguments='-c Test.dsw')
236 test.must_not_exist(test.workpath('work1', 'Test.dsp'))
237 test.must_not_exist(test.workpath('work1', 'Test.dsw'))
241 test.subdir('work2', ['work2', 'src'])
243 test.write(['work2', 'SConstruct'], """\
244 SConscript('src/SConscript', build_dir='build')
247 test.write(['work2', 'src', 'SConscript'], SConscript_contents)
249 test.run(chdir='work2', arguments=".")
251 dsp = test.read(['work2', 'src', 'Test.dsp'], 'r')
252 expect = test.msvs_substitute(expected_dspfile, '6.0', 'work2', 'SConstruct')
253 # don't compare the pickled data
254 assert dsp[:len(expect)] == expect, test.diff_substr(expect, dsp)
256 test.must_exist(test.workpath('work2', 'src', 'Test.dsw'))
257 dsw = test.read(['work2', 'src', 'Test.dsw'], 'r')
258 expect = test.msvs_substitute(expected_dswfile, '6.0',
259 os.path.join('work2', 'src'))
260 assert dsw == expect, test.diff_substr(expect, dsw)
262 test.must_match(['work2', 'build', 'Test.dsp'], """\
263 This is just a placeholder file.
264 The real project file is here:
266 """ % test.workpath('work2', 'src', 'Test.dsp'),
269 test.must_match(['work2', 'build', 'Test.dsw'], """\
270 This is just a placeholder file.
271 The real workspace file is here:
273 """ % test.workpath('work2', 'src', 'Test.dsw'),
280 test.write(['work3', 'SConstruct'], """\
281 env=Environment(tools=['msvs'], MSVS_VERSION = '6.0')
285 testlocalincs = ['test.h']
286 testresources = ['test.rc']
287 testmisc = ['readme.txt']
289 p = env.MSVSProject(target = 'Test.dsp',
292 localincs = testlocalincs,
293 resources = testresources,
295 buildtarget = 'Test.exe',
297 auto_build_solution = 0)
299 env.MSVSSolution(target = 'Test.dsw',
300 slnguid = '{SLNGUID}',
305 test.run(chdir='work3', arguments=".")
307 test.must_exist(test.workpath('work3', 'Test.dsp'))
308 dsp = test.read(['work3', 'Test.dsp'], 'r')
309 expect = test.msvs_substitute(expected_dspfile, '6.0', 'work3', 'SConstruct')
310 # don't compare the pickled data
311 assert dsp[:len(expect)] == expect, test.diff_substr(expect, dsp)
313 test.must_exist(test.workpath('work3', 'Test.dsw'))
314 dsw = test.read(['work3', 'Test.dsw'], 'r')
315 expect = test.msvs_substitute(expected_dswfile, '6.0', 'work3', 'SConstruct')
316 assert dsw == expect, test.diff_substr(expect, dsw)
318 test.run(chdir='work3', arguments='-c .')
320 test.must_not_exist(test.workpath('work3', 'Test.dsp'))
321 test.must_not_exist(test.workpath('work3', 'Test.dsw'))
323 test.run(chdir='work3', arguments='.')
325 test.must_exist(test.workpath('work3', 'Test.dsp'))
326 test.must_exist(test.workpath('work3', 'Test.dsw'))
328 test.run(chdir='work3', arguments='-c Test.dsw')
330 test.must_exist(test.workpath('work3', 'Test.dsp'))
331 test.must_not_exist(test.workpath('work3', 'Test.dsw'))
333 test.run(chdir='work3', arguments='-c Test.dsp')
335 test.must_not_exist(test.workpath('work3', 'Test.dsp'))