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.
27 Verify that use of the Scanner that evaluates CPP lines works as expected.
32 test
= TestSCons
.TestSCons()
34 m
= 'Scanner evaluation of CPP lines not yet supported; skipping test.\n'
37 f1_exe
= 'f1' + TestSCons
._exe
38 f2_exe
= 'f2' + TestSCons
._exe
39 f3_exe
= 'f3' + TestSCons
._exe
40 f4_exe
= 'f4' + TestSCons
._exe
42 test
.write('SConstruct', """\
43 env = Environment(CPPPATH=['.'])
45 f1 = env.Object('f1', 'fff.c', CPPDEFINES=['F1'])
46 f2 = env.Object('f2', 'fff.c', CPPDEFINES=[('F2', 1)])
47 f3 = env.Object('f3', 'fff.c', CPPDEFINES={'F3': None})
48 f4 = env.Object('f4', 'fff.c', CPPDEFINES={'F4': 1})
50 env.Program('f1', ['prog.c', f1])
51 env.Program('f2', ['prog.c', f2])
52 env.Program('f3', ['prog.c', f3])
53 env.Program('f4', ['prog.c', f4])
56 test
.write('f1.h', """
60 test
.write('f2.h', """
64 test
.write('f3.h', """
68 test
.write('f4.h', """
72 test
.write('fff.c', """
94 test
.write('prog.c', r
"""
98 extern char *foo(void);
101 main(int argc, char *argv[])
104 printf("prog.c: %s\n", foo());
111 test
.run(arguments
= '.')
112 test
.run(program
= test
.workpath('f1'), stdout
= "prog.c: F1\n")
113 test
.run(program
= test
.workpath('f2'), stdout
= "prog.c: F2\n")
114 test
.run(program
= test
.workpath('f3'), stdout
= "prog.c: F3\n")
115 test
.run(program
= test
.workpath('f4'), stdout
= "prog.c: F4\n")
117 test
.write('f1.h', """
118 #define STRING "F1 again"
121 test
.up_to_date(arguments
= '%(f2_exe)s %(f3_exe)s %(f4_exe)s' % locals())
122 test
.not_up_to_date(arguments
= '.')
124 test
.run(program
= test
.workpath('f1'), stdout
= "prog.c: F1 again\n")
125 test
.run(program
= test
.workpath('f2'), stdout
= "prog.c: F2\n")
126 test
.run(program
= test
.workpath('f3'), stdout
= "prog.c: F3\n")
127 test
.run(program
= test
.workpath('f4'), stdout
= "prog.c: F4\n")
129 test
.write('f2.h', """
130 #define STRING "F2 again"
133 test
.up_to_date(arguments
= '%(f1_exe)s %(f3_exe)s %(f4_exe)s' % locals())
134 test
.not_up_to_date(arguments
= '.')
136 test
.run(program
= test
.workpath('f1'), stdout
= "prog.c: F1 again\n")
137 test
.run(program
= test
.workpath('f2'), stdout
= "prog.c: F2 again\n")
138 test
.run(program
= test
.workpath('f3'), stdout
= "prog.c: F3\n")
139 test
.run(program
= test
.workpath('f4'), stdout
= "prog.c: F4\n")
141 test
.write('f3.h', """
142 #define STRING "F3 again"
145 test
.up_to_date(arguments
= '%(f1_exe)s %(f2_exe)s %(f4_exe)s' % locals())
146 test
.not_up_to_date(arguments
= '.')
148 test
.run(program
= test
.workpath('f1'), stdout
= "prog.c: F1 again\n")
149 test
.run(program
= test
.workpath('f2'), stdout
= "prog.c: F2 again\n")
150 test
.run(program
= test
.workpath('f3'), stdout
= "prog.c: F3 again\n")
151 test
.run(program
= test
.workpath('f4'), stdout
= "prog.c: F4\n")
153 test
.write('f4.h', """
154 #define STRING "F4 again"
157 test
.up_to_date(arguments
= '%(f1_exe)s %(f2_exe)s %(f3_exe)s' % locals())
158 test
.not_up_to_date(arguments
= '.')
160 test
.run(program
= test
.workpath('f1'), stdout
= "prog.c: F1 again\n")
161 test
.run(program
= test
.workpath('f2'), stdout
= "prog.c: F2 again\n")
162 test
.run(program
= test
.workpath('f3'), stdout
= "prog.c: F3 again\n")
163 test
.run(program
= test
.workpath('f4'), stdout
= "prog.c: F4 again\n")
169 # indent-tabs-mode:nil
171 # vim: set expandtab tabstop=4 shiftwidth=4: