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 project_guid
= TestSConsMSVS
.PROJECT_GUID
43 vcproj_template
= """\
44 <?xml version="1.0" encoding="Windows-1252"?>
46 \tProjectType="Visual C++"
49 \tProjectGUID="<PROJECT_GUID>"
50 \tRootNamespace="Test"
51 \tKeyword="MakeFileProj">
60 \t\t\tName="Release|Win32"
61 \t\t\tConfigurationType="0"
63 \t\t\tATLMinimizesCRunTimeLibraryUsage="false"
66 \t\t\t\tName="VCNMakeTool"
67 \t\t\t\tBuildCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe""
68 \t\t\t\tReBuildCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe""
69 \t\t\t\tCleanCommandLine="echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct -c "Test.exe""
70 \t\t\t\tOutput="Test.exe"
71 \t\t\t\tPreprocessorDefinitions=""
72 \t\t\t\tIncludeSearchPath=""
73 \t\t\t\tForcedIncludes=""
74 \t\t\t\tAssemblySearchPath=""
75 \t\t\t\tForcedUsingAssemblies=""
76 \t\t\t\tCompileAsManaged=""
85 </VisualStudioProject>
88 SConscript_contents
= """\
89 env=Environment(tools=['msvs'], MSVS_VERSION = '8.0')
93 env.MSVSProject(target = 'Test.vcproj',
94 MSVS_PROJECT_GUID = '%(project_guid)s',
95 slnguid = '{SLNGUID}',
97 buildtarget = 'Test.exe',
99 auto_build_solution = 0)
105 'prefix/subdir1/test1.cpp',
106 r
'prefix\subdir1\test2.cpp',
107 'prefix/subdir2/test3.cpp',
110 sln_files
= """\t<Files>
112 \t\t\t\tName="subdir1"
115 \t\t\t\tRelativePath="prefix\\subdir1\\test1.cpp">
118 \t\t\t\tRelativePath="prefix\\subdir1\\test2.cpp">
122 \t\t\t\tName="subdir2"
125 \t\t\t\tRelativePath="prefix\\subdir2\\test3.cpp">
129 \t\t\tRelativePath="<SCONSCRIPT>">
133 test
.write(['work1', 'SConstruct'], SConscript_contents
% locals())
135 test
.run(chdir
='work1', arguments
="Test.vcproj")
137 test
.must_exist(test
.workpath('work1', 'Test.vcproj'))
138 vcproj
= test
.read(['work1', 'Test.vcproj'], 'r')
139 expected_vcprojfile
= vcproj_template
% locals()
140 expect
= test
.msvs_substitute(expected_vcprojfile
, '8.0', 'work1', 'SConstruct')
141 # don't compare the pickled data
142 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
147 'prefix/subdir/somefile.cpp',
150 sln_files
= """\t<Files>
152 \t\t\t\tRelativePath="prefix\\subdir\\somefile.cpp">
155 \t\t\tRelativePath="<SCONSCRIPT>">
159 test
.write(['work2', 'SConstruct'], SConscript_contents
% locals())
161 test
.run(chdir
='work2', arguments
="Test.vcproj")
163 test
.must_exist(test
.workpath('work2', 'Test.vcproj'))
164 vcproj
= test
.read(['work2', 'Test.vcproj'], 'r')
165 expected_vcprojfile
= vcproj_template
% locals()
166 expect
= test
.msvs_substitute(expected_vcprojfile
, '8.0', 'work2', 'SConstruct')
167 # don't compare the pickled data
168 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
174 # indent-tabs-mode:nil
176 # vim: set expandtab tabstop=4 shiftwidth=4: