Merge pull request #4674 from bdbaddog/fix_2281_Aliases_ignore_pre_post_add_actions
[scons.git] / test / CPPFLAGS.py
blobebae2df9f15ac505316eed479db297d724167664
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 import sys
28 import TestSCons
30 _python_ = TestSCons._python_
32 test = TestSCons.TestSCons()
34 # Writing this to accommodate both our in-line tool chain and the
35 # MSVC command lines is too hard, and will be completely unnecessary
36 # some day when we separate our tests. Punt for now.
37 if sys.platform == 'win32':
38 test.skip_test('Skipping on win32.\n')
40 test.file_fixture('mylink.py')
41 test.file_fixture('mygcc.py')
43 test.write('SConstruct', """
44 env = Environment(
45 CPPFLAGS='-x',
46 LINK=r'%(_python_)s mylink.py',
47 LINKFLAGS=[],
48 CC=r'%(_python_)s mygcc.py cc',
49 CXX=r'%(_python_)s mygcc.py c++',
50 CXXFLAGS=[],
51 FORTRAN=r'%(_python_)s mygcc.py g77',
52 OBJSUFFIX='.obj',
53 PROGSUFFIX='.exe',
55 env.Program(target='foo', source=Split('test1.c test2.cpp test3.F'))
56 """ % locals())
58 test.write('test1.c', r"""test1.c
59 #cc
60 #link
61 """)
63 test.write('test2.cpp', r"""test2.cpp
64 #c++
65 #link
66 """)
68 test.write('test3.F', r"""test3.F
69 #g77
70 #link
71 """)
73 test.run(arguments = '.', stderr=None)
75 test.must_match('test1.obj', "test1.c\n#link\n")
76 test.must_match('test2.obj', "test2.cpp\n#link\n")
77 test.must_match('test3.obj', "test3.F\n#link\n")
78 test.must_match('foo.exe', "test1.c\ntest2.cpp\ntest3.F\n")
79 if TestSCons.case_sensitive_suffixes('.F', '.f'):
80 test.must_match('mygcc.out', "cc\nc++\ng77\n")
81 else:
82 test.must_match('mygcc.out', "cc\nc++\n")
84 test.write('SConstruct', """
85 env = Environment(
86 CPPFLAGS='-x',
87 SHLINK=r'%(_python_)s mylink.py',
88 SHLINKFLAGS=[],
89 CC=r'%(_python_)s mygcc.py cc',
90 CXX=r'%(_python_)s mygcc.py c++',
91 CXXFLAGS=[],
92 FORTRAN=r'%(_python_)s mygcc.py g77',
93 OBJSUFFIX='.obj',
94 SHOBJPREFIX='',
95 SHOBJSUFFIX='.shobj',
96 PROGSUFFIX='.exe',
98 env.SharedLibrary(target=File('foo.bar'), source=Split('test1.c test2.cpp test3.F'))
99 """ % locals())
101 test.write('test1.c', r"""test1.c
103 #link
104 """)
106 test.write('test2.cpp', r"""test2.cpp
107 #c++
108 #link
109 """)
111 test.write('test3.F', r"""test3.F
112 #g77
113 #link
114 """)
116 test.unlink('mygcc.out')
117 test.unlink('test1.obj')
118 test.unlink('test2.obj')
119 test.unlink('test3.obj')
121 test.run(arguments = '.', stderr = None)
123 test.must_match('test1.shobj', "test1.c\n#link\n")
124 test.must_match('test2.shobj', "test2.cpp\n#link\n")
125 test.must_match('test3.shobj', "test3.F\n#link\n")
126 test.must_match('foo.bar', "test1.c\ntest2.cpp\ntest3.F\n")
127 if TestSCons.case_sensitive_suffixes('.F', '.f'):
128 test.must_match('mygcc.out', "cc\nc++\ng77\n")
129 else:
130 test.must_match('mygcc.out', "cc\nc++\n")
132 test.pass_test()
134 # Local Variables:
135 # tab-width:4
136 # indent-tabs-mode:nil
137 # End:
138 # vim: set expandtab tabstop=4 shiftwidth=4: