Merged revisions 3088-3319,3321-3322,3324-3349,3351-3481,3483-3484,3486-3520,3522...
[scons.git] / test / MSVC / hierarchical.py
1 #!/usr/bin/env python\r
2 #\r
3 # __COPYRIGHT__\r
4 #\r
5 # Permission is hereby granted, free of charge, to any person obtaining\r
6 # a copy of this software and associated documentation files (the\r
7 # "Software"), to deal in the Software without restriction, including\r
8 # without limitation the rights to use, copy, modify, merge, publish,\r
9 # distribute, sublicense, and/or sell copies of the Software, and to\r
10 # permit persons to whom the Software is furnished to do so, subject to\r
11 # the following conditions:\r
12 #\r
13 # The above copyright notice and this permission notice shall be included\r
14 # in all copies or substantial portions of the Software.\r
15 #\r
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY\r
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\r
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
23 #\r
24 \r
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"\r
26 \r
27 """\r
28 Verify use of Visual Studio with a hierarchical build.\r
29 """\r
30 \r
31 import sys\r
32 \r
33 import TestSCons\r
34 \r
35 test = TestSCons.TestSCons(match = TestSCons.match_re)\r
36 \r
37 if sys.platform != 'win32':\r
38     msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform\r
39     test.skip_test(msg)\r
40 \r
41 \r
42 \r
43 test.subdir('src', 'build', 'out')\r
44 \r
45 test.write('SConstruct', """\r
46 VariantDir('build', 'src', duplicate=0)\r
47 SConscript('build/SConscript')\r
48 """)\r
49 \r
50 test.write('src/SConscript',"""\r
51 import os\r
52 env = Environment()\r
53 env.Append(CPPPATH=os.environ.get('INCLUDE', ''),\r
54            LIBPATH=os.environ.get('LIB', ''))\r
55 env['PCH'] = 'StdAfx.pch'\r
56 env['PDB'] = '#out/test.pdb'\r
57 env['PCHSTOP'] = 'StdAfx.h'\r
58 env.PCH('StdAfx.cpp')\r
59 env.Program('#out/test.exe', 'test.cpp')\r
60 """)\r
61 \r
62 test.write('src/test.cpp', '''\r
63 #include "StdAfx.h"\r
64 \r
65 int main(void) \r
66\r
67     return 1;\r
68 }\r
69 ''')\r
70 \r
71 test.write('src/StdAfx.h', '''\r
72 #include <windows.h>\r
73 ''')\r
74 \r
75 test.write('src/StdAfx.cpp', '''\r
76 #include "StdAfx.h"\r
77 ''')\r
78 \r
79 test.run(arguments='out', stderr=None)\r
80 \r
81 test.must_exist(test.workpath('out/test.pdb'))\r
82 test.must_exist(test.workpath('build/StdAfx.pch'))\r
83 test.must_exist(test.workpath('build/StdAfx.obj'))\r
84 \r
85 test.run(arguments='-c out')\r
86 \r
87 test.must_not_exist(test.workpath('out/test.pdb'))\r
88 test.must_not_exist(test.workpath('build/StdAfx.pch'))\r
89 test.must_not_exist(test.workpath('build/StdAfx.obj'))\r
90 \r
91 \r
92 \r
93 test.pass_test()\r
94
95 # Local Variables:
96 # tab-width:4
97 # indent-tabs-mode:nil
98 # End:
99 # vim: set expandtab tabstop=4 shiftwidth=4: