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__"
30 test = TestSCons.TestSCons()
33 _python_ = TestSCons._python_
35 test.write('SConstruct', """
36 env = Environment(CCFLAGS='-DFOO', LIBS=['a'])
37 def build(target, source, env):
38 print "env['CC'] =", env['CC']
39 print "env['CCFLAGS'] =", env['CCFLAGS']
40 print "env['LIBS'] =", env['LIBS']
41 builder = Builder(action=build, CC='buildcc', LIBS='buildlibs')
42 env['BUILDERS']['Build'] = builder
44 foo = env.Build('foo.out', 'foo.in',
46 CCFLAGS='$CCFLAGS -DBAR',
47 LIBS = env['LIBS']+['b'])
48 bar = env.Build('bar.out', 'bar.in')
52 test.write('foo.in', "foo.in\n")
53 test.write('bar.in', "bar.in\n")
55 test.run(arguments = "-Q", stdout = """\
56 build(["foo.out"], ["foo.in"])
58 env['CCFLAGS'] = -DFOO -DBAR
59 env['LIBS'] = ['a', 'b']
60 build(["bar.out"], ["bar.in"])
62 env['CCFLAGS'] = -DFOO
63 env['LIBS'] = buildlibs
68 test.write('SConstruct', """
70 env.Program('hello', 'hello.c',
71 CC=r'%(_python_)s mycc.py',
72 LINK=r'%(_python_)s mylink.py',
74 PROGSUFFIX='.not_exe')
77 test.write('hello.c',"this ain't no c file!\n")
79 test.write('mycc.py',"""
80 open('hello.not_obj', 'wt').write('this is no object file!')
83 test.write('mylink.py',"""
84 open('hello.not_exe', 'wt').write('this is not a program!')
87 test.run(arguments='hello.not_exe')
89 assert test.read('hello.not_obj') == 'this is no object file!'
90 assert test.read('hello.not_exe') == 'this is not a program!'
92 test.up_to_date(arguments='hello.not_exe')
96 test.write('SConstruct', """\
98 env.Program('goodbye', 'goodbye.c',
99 CC=r'%(_python_)s mycc.py',
100 LINK=r'%(_python_)s mylink.py',
101 OBJSUFFIX='.not_obj',
102 PROGSUFFIX='.not_exe',
107 test.write('goodbye.c',"this ain't no c file!\n")
109 test.write('mycc.py',"""
110 open('goodbye.not_obj', 'wt').write('this is no object file!')
113 test.write('mylink.py',"""
114 open('goodbye.not_exe', 'wt').write('this is not a program!')
117 test.run(arguments='goodbye.not_exe', stderr=None)
118 test.fail_test(not test.match_re(test.stderr(), r"""
119 scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\?
120 """ + TestSCons.file_expr + r"""
121 scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\?
122 """ + TestSCons.file_expr))
124 assert test.read('goodbye.not_obj') == 'this is no object file!'
125 assert test.read('goodbye.not_exe') == 'this is not a program!'
133 # indent-tabs-mode:nil
135 # vim: set expandtab tabstop=4 shiftwidth=4: