5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 Test that we can generate Visual Studio 8.0 project (.vcproj) and
28 solution (.sln) files that look correct.
35 test
= TestSConsMSVS
.TestSConsMSVS()
37 if sys
.platform
!= 'win32':
38 msg
= "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys
.platform
41 vcproj_template
= """\
42 <?xml version="1.0" encoding="Windows-1252"?>
44 \tProjectType="Visual C++"
47 \tProjectGUID="<PROJECT_GUID>"
48 \tRootNamespace="Test"
49 \tKeyword="MakeFileProj">
58 \t\t\tName="Release|Win32"
59 \t\t\tConfigurationType="0"
61 \t\t\tATLMinimizesCRunTimeLibraryUsage="false"
64 \t\t\t\tName="VCNMakeTool"
65 \t\t\t\tBuildCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe""
66 \t\t\t\tReBuildCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe""
67 \t\t\t\tCleanCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct -c "Test.exe""
68 \t\t\t\tOutput="Test.exe"
69 \t\t\t\tPreprocessorDefinitions=""
70 \t\t\t\tIncludeSearchPath=""
71 \t\t\t\tForcedIncludes=""
72 \t\t\t\tAssemblySearchPath=""
73 \t\t\t\tForcedUsingAssemblies=""
74 \t\t\t\tCompileAsManaged=""
83 </VisualStudioProject>
88 SConscript_contents
= """\
89 env=Environment(tools=['msvs'], MSVS_VERSION = '8.0')
93 env.MSVSProject(target = 'Test.vcproj',
94 slnguid = '{SLNGUID}',
96 buildtarget = 'Test.exe',
98 auto_build_solution = 0)
106 'prefix/subdir1/test1.cpp',
107 r
'prefix\subdir1\test2.cpp',
108 'prefix/subdir2/test3.cpp',
111 sln_files
= """\t<Files>
113 \t\t\t\tName="subdir1"
116 \t\t\t\tRelativePath="prefix\\subdir1\\test1.cpp">
119 \t\t\t\tRelativePath="prefix\\subdir1\\test2.cpp">
123 \t\t\t\tName="subdir2"
126 \t\t\t\tRelativePath="prefix\\subdir2\\test3.cpp">
130 \t\t\tRelativePath="<SCONSCRIPT>">
134 test
.write(['work1', 'SConstruct'], SConscript_contents
% locals())
136 test
.run(chdir
='work1', arguments
="Test.vcproj")
138 test
.must_exist(test
.workpath('work1', 'Test.vcproj'))
139 vcproj
= test
.read(['work1', 'Test.vcproj'], 'r')
140 expected_vcprojfile
= vcproj_template
% locals()
141 expect
= test
.msvs_substitute(expected_vcprojfile
, '8.0', 'work1', 'SConstruct')
142 # don't compare the pickled data
143 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
150 'prefix/subdir/somefile.cpp',
153 sln_files
= """\t<Files>
155 \t\t\t\tRelativePath="prefix\\subdir\\somefile.cpp">
158 \t\t\tRelativePath="<SCONSCRIPT>">
162 test
.write(['work2', 'SConstruct'], SConscript_contents
% locals())
164 test
.run(chdir
='work2', arguments
="Test.vcproj")
166 test
.must_exist(test
.workpath('work2', 'Test.vcproj'))
167 vcproj
= test
.read(['work2', 'Test.vcproj'], 'r')
168 expected_vcprojfile
= vcproj_template
% locals()
169 expect
= test
.msvs_substitute(expected_vcprojfile
, '8.0', 'work2', 'SConstruct')
170 # don't compare the pickled data
171 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
179 # indent-tabs-mode:nil
181 # vim: set expandtab tabstop=4 shiftwidth=4: