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.
35 test
= TestSCons
.TestSCons()
37 test
.subdir('lib1', 'lib2')
39 prog1
= test
.workpath('prog') + _exe
40 prog2
= test
.workpath(dll_
+ 'shlib') + _dll
42 test
.write('SConstruct', """\
43 DefaultEnvironment(tools=[]) # test speedup
44 env1 = Environment(LIBS=['foo1'], LIBPATH=['$FOO'], FOO='./lib1')
46 f1 = env1.SharedObject('f1', 'f1.c')
48 env1.Program(target='prog', source='prog.c')
49 env1.Library(target='./lib1/foo1', source=f1)
51 env2 = Environment(LIBS='foo2', LIBPATH='.')
52 env2.SharedLibrary(target='shlib', source='shlib.c', no_import_lib=1)
53 env2.Library(target='foo2', source=f1)
56 test
.write('f1.c', r
"""
66 test
.write('shlib.c', r
"""
76 test
.write('prog.c', r
"""
81 main(int argc, char *argv[])
90 test
.run(arguments
= '.',
91 stderr
=TestSCons
.noisy_ar
,
92 match
=TestSCons
.match_re_dotall
)
94 test
.run(program
= prog1
,
95 stdout
= "f1.c\nprog.c\n")
97 oldtime1
= os
.path
.getmtime(prog1
)
98 oldtime2
= os
.path
.getmtime(prog2
)
99 test
.sleep() # delay for timestamps
100 test
.run(arguments
='.')
102 test
.fail_test(oldtime1
!= os
.path
.getmtime(prog1
))
103 test
.fail_test(oldtime2
!= os
.path
.getmtime(prog2
))
105 test
.write('f1.c', r
"""
115 test
.run(arguments
='.', stderr
=TestSCons
.noisy_ar
, match
=TestSCons
.match_re_dotall
)
116 test
.run(program
=prog1
, stdout
="f1.c 1\nprog.c\n")
117 test
.fail_test(oldtime2
== os
.path
.getmtime(prog2
))
118 #test.up_to_date(arguments = '.')
119 # Change LIBPATH and make sure we don't rebuild because of it.
120 test
.write('SConstruct', """\
121 DefaultEnvironment(tools=[]) # test speedup
122 env1 = Environment(LIBS=['foo1'], LIBPATH=['./lib1', './lib2'])
124 f1 = env1.SharedObject('f1', 'f1.c')
126 env1.Program(target='prog', source='prog.c')
127 env1.Library(target='./lib1/foo1', source=f1)
129 env2 = Environment(LIBS='foo2', LIBPATH=Split('. ./lib2'))
130 env2.SharedLibrary(target='shlib', source='shlib.c', no_import_lib=1)
131 env2.Library(target='foo2', source=f1)
134 test
.up_to_date(arguments
='.', stderr
=None)
136 test
.write('f1.c', r
"""
146 test
.run(arguments
='.', stderr
=TestSCons
.noisy_ar
, match
=TestSCons
.match_re_dotall
)
147 test
.run(program
=prog1
, stdout
="f1.c 2\nprog.c\n")
149 test
.up_to_date(arguments
='.')
151 # We need at least one file for some implementations of the Library
152 # builder, notably the SGI one.
153 test
.write('empty.c', 'int a=0;\n')
155 # Check that a null-string LIBPATH doesn't blow up.
156 test
.write('SConstruct', """\
157 DefaultEnvironment(tools=[]) # test speedup
158 env = Environment(LIBPATH='')
159 env.Library('foo', source='empty.c')
162 test
.run(arguments
='.', stderr
=TestSCons
.noisy_ar
, match
=TestSCons
.match_re_dotall
)
168 # indent-tabs-mode:nil
170 # vim: set expandtab tabstop=4 shiftwidth=4: