[ci skip] update generated files
[scons.git] / test / MSVS / vs-scc-legacy-files.py
blob9943d3d7ced546f95fda0a4056831707d7cea750
1 #!/usr/bin/env python
3 # __COPYRIGHT__
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__"
27 """
28 Test that we can generate Visual Studio 10.0 or later project (.vcxproj) and
29 solution (.sln) files that contain SCC information and look correct.
30 """
32 import TestSConsMSVS
34 test = None
36 for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions():
37 test = TestSConsMSVS.TestSConsMSVS()
38 host_arch = test.get_vs_host_arch()
40 # Make the test infrastructure think we have this version of MSVS installed.
41 test._msvs_versions = [vc_version]
43 dirs = ['inc1', 'inc2']
44 major, minor = test.parse_vc_version(vc_version)
45 project_file = 'Test.vcproj' if major <= 9 else 'Test.vcxproj'
46 filters_file = project_file + '.filters'
47 filters_file_expected = major >= 10
48 expected_slnfile = test.get_expected_sln_file_contents(vc_version, project_file)
49 expected_vcprojfile = test.get_expected_proj_file_contents(vc_version, dirs, project_file)
51 SConscript_contents = """\
52 env=Environment(tools=['msvs'],
53 MSVS_VERSION='{vc_version}',
54 CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
55 CPPPATH=['inc1', 'inc2'],
56 MSVS_SCC_LOCAL_PATH=r'C:\\MyMsVsProjects',
57 MSVS_SCC_PROJECT_NAME='Perforce Project',
58 HOST_ARCH='{host_arch}')
60 testsrc = ['test1.cpp', 'test2.cpp']
61 testincs = [r'sdk_dir\\sdk.h']
62 testlocalincs = ['test.h']
63 testresources = ['test.rc']
64 testmisc = ['readme.txt']
66 env.MSVSProject(target = '{project_file}',
67 MSVS_PROJECT_GUID='{project_guid}',
68 srcs = testsrc,
69 incs = testincs,
70 localincs = testlocalincs,
71 resources = testresources,
72 misc = testmisc,
73 buildtarget = 'Test.exe',
74 variant = 'Release')
75 """.format(
76 vc_version=vc_version, project_file=project_file,
77 host_arch=host_arch, project_guid=TestSConsMSVS.PROJECT_GUID,
80 if major < 10:
81 # VC8 and VC9 used key-value pair format.
82 expected_vcproj_sccinfo = """\
83 \tSccProjectName="Perforce Project"
84 \tSccLocalPath="C:\\MyMsVsProjects"
85 """
86 else:
87 # VC10 and later use XML format.
88 expected_vcproj_sccinfo = """\
89 \t\t<SccProjectName>Perforce Project</SccProjectName>
90 \t\t<SccLocalPath>C:\\MyMsVsProjects</SccLocalPath>
91 """
93 test.write('SConstruct', SConscript_contents)
95 test.run(arguments=project_file)
97 test.must_exist(test.workpath(project_file))
98 vcproj = test.read(project_file, 'r')
99 expect = test.msvs_substitute(expected_vcprojfile, vc_version, None, 'SConstruct',
100 vcproj_sccinfo=expected_vcproj_sccinfo)
101 # don't compare the pickled data
102 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
104 test.must_exist(test.workpath('Test.sln'))
105 sln = test.read('Test.sln', 'r')
106 expect = test.msvs_substitute(expected_slnfile, vc_version, None, 'SConstruct')
107 # don't compare the pickled data
108 assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
110 if test:
111 test.pass_test()
113 # Local Variables:
114 # tab-width:4
115 # indent-tabs-mode:nil
116 # End:
117 # vim: set expandtab tabstop=4 shiftwidth=4: