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__"
31 test = TestSCons.TestSCons()
34 _python_ = TestSCons._python_
36 test.write('SConstruct', """
37 env = Environment(CCFLAGS='-DFOO', LIBS=['a'])
38 def build(target, source, env):
39 print "env['CC'] =", env['CC']
40 print "env['CCFLAGS'] =", env['CCFLAGS']
41 print "env['LIBS'] =", env['LIBS']
42 builder = Builder(action=build, CC='buildcc', LIBS='buildlibs')
43 env['BUILDERS']['Build'] = builder
45 foo = env.Build('foo.out', 'foo.in',
47 CCFLAGS='$CCFLAGS -DBAR',
48 LIBS = env['LIBS']+['b'])
49 bar = env.Build('bar.out', 'bar.in')
53 test.write('foo.in', "foo.in\n")
54 test.write('bar.in', "bar.in\n")
56 test.run(arguments = "-Q", stdout = """\
57 build(["foo.out"], ["foo.in"])
59 env['CCFLAGS'] = -DFOO -DBAR
60 env['LIBS'] = ['a', 'b']
61 build(["bar.out"], ["bar.in"])
63 env['CCFLAGS'] = -DFOO
64 env['LIBS'] = buildlibs
69 test.write('SConstruct', """
71 env.Program('hello', 'hello.c',
72 CC=r'%(_python_)s mycc.py',
73 LINK=r'%(_python_)s mylink.py',
75 PROGSUFFIX='.not_exe')
78 test.write('hello.c',"this ain't no c file!\n")
80 test.write('mycc.py',"""
81 open('hello.not_obj', 'wt').write('this is no object file!')
84 test.write('mylink.py',"""
85 open('hello.not_exe', 'wt').write('this is not a program!')
88 test.run(arguments='hello.not_exe')
90 assert test.read('hello.not_obj') == 'this is no object file!'
91 assert test.read('hello.not_exe') == 'this is not a program!'
93 test.up_to_date(arguments='hello.not_exe')
97 test.write('SConstruct', """\
99 env.Program('goodbye', 'goodbye.c',
100 CC=r'%(_python_)s mycc.py',
101 LINK=r'%(_python_)s mylink.py',
102 OBJSUFFIX='.not_obj',
103 PROGSUFFIX='.not_exe',
108 test.write('goodbye.c',"this ain't no c file!\n")
110 test.write('mycc.py',"""
111 open('goodbye.not_obj', 'wt').write('this is no object file!')
114 test.write('mylink.py',"""
115 open('goodbye.not_exe', 'wt').write('this is not a program!')
118 test.run(arguments='goodbye.not_exe', stderr=None)
119 test.fail_test(not test.match_re(test.stderr(), r"""
120 scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\?
121 """ + TestSCons.file_expr + r"""
122 scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\?
123 """ + TestSCons.file_expr))
125 assert test.read('goodbye.not_obj') == 'this is no object file!'
126 assert test.read('goodbye.not_exe') == 'this is not a program!'