[ci skip] update generated files
[scons.git] / test / Win32 / msvc_mingw_env.py
blobf278cfaf9ae069e7cab77829b1a21d5459b80544
1 #!/usr/bin/env python
3 # MIT License
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.
26 """
27 This tests the MinGW with MSVC tool.
28 """
30 import sys
32 import TestSCons
34 test = TestSCons.TestSCons()
36 # MinGW is Windows only:
37 if sys.platform != 'win32':
38 msg = "Skipping mingw test on non-Windows platform '%s'\n" % sys.platform
39 test.skip_test(msg)
41 test.skip_if_not_msvc()
43 # control test: check for nologo and cl in env
44 test.write('SConstruct',"""
45 DefaultEnvironment(tools=[])
46 env = Environment(tools=['default'])
47 print('CCFLAGS=' + str(env['CCFLAGS']).strip())
48 print('CC=' + str(env['CC']).strip())
49 """)
50 test.run(arguments='-Q -s')
51 if 'CCFLAGS=/nologo' not in test.stdout() or 'CC=cl' not in test.stdout():
52 test.fail_test()
54 # make sure windows msvc doesnt add bad mingw flags
55 # and that gcc is selected
56 test.write('SConstruct',"""
57 DefaultEnvironment(tools=[])
58 env = Environment(tools=['default', 'mingw'])
59 print('CCFLAGS="' + str(env['CCFLAGS']).strip() + '"')
60 print('CC=' + str(env['CC']).strip())
61 """)
62 test.run(arguments='-Q -s')
63 if('CCFLAGS=""' not in test.stdout()
64 or 'CC=gcc' not in test.stdout()):
65 test.fail_test()
67 # msvc should overwrite the flags and use cl
68 test.write('SConstruct',"""
69 DefaultEnvironment(tools=[])
70 env = Environment(tools=['mingw', 'default'])
71 print('CCFLAGS=' + str(env['CCFLAGS']).strip())
72 print('CC=' + str(env['CC']).strip())
73 """)
74 test.run(arguments='-Q -s')
75 if 'CCFLAGS=/nologo' not in test.stdout() or 'CC=cl' not in test.stdout():
76 test.fail_test()
78 # test that CCFLAGS are preserved
79 test.write('SConstruct',"""
80 DefaultEnvironment(tools=[])
81 env = Environment(tools=['mingw'], CCFLAGS='-myflag')
82 print(env['CCFLAGS'])
83 """)
84 test.run(arguments='-Q -s')
85 if '-myflag' not in test.stdout():
86 test.fail_test()
88 # test that it handles a list
89 test.write('SConstruct',"""
90 DefaultEnvironment(tools=[])
91 env = Environment(tools=['mingw'], CCFLAGS=['-myflag', '-myflag2'])
92 print(str(env['CCFLAGS']))
93 """)
94 test.run(arguments='-Q -s')
95 if "['-myflag', '-myflag2']" not in test.stdout():
96 test.fail_test()
98 test.pass_test()
100 # Local Variables:
101 # tab-width:4
102 # indent-tabs-mode:nil
103 # End:
104 # vim: set expandtab tabstop=4 shiftwidth=4: