5638916ccf16d8178efd088bab9a83edbe69d3ff
[scons.git] / test / MSVS / runfile.py
1
2 #!/usr/bin/env python
3 #
4 # __COPYRIGHT__
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining
7 # a copy of this software and associated documentation files (the
8 # "Software"), to deal in the Software without restriction, including
9 # without limitation the rights to use, copy, modify, merge, publish,
10 # distribute, sublicense, and/or sell copies of the Software, and to
11 # permit persons to whom the Software is furnished to do so, subject to
12 # the following conditions:
13 #
14 # The above copyright notice and this permission notice shall be included
15 # in all copies or substantial portions of the Software.
16 #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
18 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #
25
26 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
27
28 """
29 Test that we can generate Visual Studio 8.0 project (.vcproj) and
30 solution (.sln) files that look correct.
31 """
32
33 import os
34 import os.path
35 import sys
36
37 import TestCmd
38 import TestSCons
39
40 test = TestSCons.TestSCons()
41
42 if sys.platform != 'win32':
43     msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform
44     test.skip_test(msg)
45
46 expected_vcprojfile = """\
47 <?xml version="1.0" encoding="Windows-1252"?>
48 <VisualStudioProject
49 \tProjectType="Visual C++"
50 \tVersion="8.00"
51 \tName="Test"
52 \tProjectGUID="<PROJECT_GUID>"
53 \tSccProjectName=""
54 \tSccLocalPath=""
55 \tRootNamespace="Test"
56 \tKeyword="MakeFileProj">
57 \t<Platforms>
58 \t\t<Platform
59 \t\t\tName="Win32"/>
60 \t</Platforms>
61 \t<ToolFiles>
62 \t</ToolFiles>
63 \t<Configurations>
64 \t\t<Configuration
65 \t\t\tName="Release|Win32"
66 \t\t\tConfigurationType="0"
67 \t\t\tUseOfMFC="0"
68 \t\t\tATLMinimizesCRunTimeLibraryUsage="false"
69 \t\t\t>
70 \t\t\t<Tool
71 \t\t\t\tName="VCNMakeTool"
72 \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 Test.exe"
73 \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 Test.exe"
74 \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 Test.exe"
75 \t\t\t\tOutput="runfile.exe"
76 \t\t\t\tPreprocessorDefinitions=""
77 \t\t\t\tIncludeSearchPath=""
78 \t\t\t\tForcedIncludes=""
79 \t\t\t\tAssemblySearchPath=""
80 \t\t\t\tForcedUsingAssemblies=""
81 \t\t\t\tCompileAsManaged=""
82 \t\t\t/>
83 \t\t</Configuration>
84 \t</Configurations>
85 \t<References>
86 \t</References>
87 \t<Files>
88 \t\t\t<File
89 \t\t\t\tRelativePath="test.cpp">
90 \t\t\t</File>
91 \t\t<File
92 \t\t\tRelativePath="<SCONSCRIPT>">
93 \t\t</File>
94 \t</Files>
95 \t<Globals>
96 \t</Globals>
97 </VisualStudioProject>
98 """
99
100
101
102 SConscript_contents = """\
103 env=Environment(tools=['msvs'], MSVS_VERSION = '8.0')
104
105 env.MSVSProject(target = 'Test.vcproj',
106                 slnguid = '{SLNGUID}',
107                 srcs = ['test.cpp'],
108                 buildtarget = 'Test.exe',
109                 runfile = 'runfile.exe',
110                 variant = 'Release',
111                 auto_build_solution = 0)
112 """
113
114
115
116 test.subdir('work1')
117
118 test.write(['work1', 'SConstruct'], SConscript_contents)
119
120 test.run(chdir='work1', arguments="Test.vcproj")
121
122 test.must_exist(test.workpath('work1', 'Test.vcproj'))
123 vcproj = test.read(['work1', 'Test.vcproj'], 'r')
124 expect = test.msvs_substitute(expected_vcprojfile, '8.0', 'work1', 'SConstruct')
125 # don't compare the pickled data
126 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
127
128
129
130 test.pass_test()