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__"
36 test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
38 test.subdir('lib1', 'lib2')
40 prog1 = test.workpath('prog') + _exe
41 prog2 = test.workpath(dll_ + 'shlib') + _dll
43 test.write('SConstruct', """
44 env1 = Environment(LIBS = [ 'foo1' ],
48 f1 = env1.Object('f1', 'f1.c')
50 env1.Program(target = 'prog', source = 'prog.c')
51 env1.Library(target = './lib1/foo1', source = f1)
53 env2 = Environment(LIBS = 'foo2',
55 env2.SharedLibrary(target = 'shlib', source = 'shlib.c', no_import_lib = 1)
56 env2.Library(target = 'foo2', source = f1)
59 test.write('f1.c', r"""
67 test.write('shlib.c', r"""
77 test.write('prog.c', r"""
80 main(int argc, char *argv[])
89 test.run(arguments = '.', stderr=TestSCons.noisy_ar)
91 test.run(program = prog1,
92 stdout = "f1.c\nprog.c\n")
94 oldtime1 = os.path.getmtime(prog1)
95 oldtime2 = os.path.getmtime(prog2)
97 test.run(arguments = '.')
99 test.fail_test(oldtime1 != os.path.getmtime(prog1))
100 test.fail_test(oldtime2 != os.path.getmtime(prog2))
102 test.write('f1.c', r"""
110 test.run(arguments = '.', stderr=TestSCons.noisy_ar)
111 test.run(program = prog1,
112 stdout = "f1.c 1\nprog.c\n")
113 test.fail_test(oldtime2 == os.path.getmtime(prog2))
114 #test.up_to_date(arguments = '.')
115 # Change LIBPATH and make sure we don't rebuild because of it.
116 test.write('SConstruct', """
117 env1 = Environment(LIBS = [ 'foo1' ],
118 LIBPATH = [ './lib1', './lib2' ])
120 f1 = env1.Object('f1', 'f1.c')
122 env1.Program(target = 'prog', source = 'prog.c')
123 env1.Library(target = './lib1/foo1', source = f1)
125 env2 = Environment(LIBS = 'foo2',
126 LIBPATH = Split('. ./lib2'))
127 env2.SharedLibrary(target = 'shlib', source = 'shlib.c', no_import_lib = 1)
128 env2.Library(target = 'foo2', source = f1)
131 test.up_to_date(arguments = '.', stderr=None)
133 test.write('f1.c', r"""
141 test.run(arguments = '.', stderr=TestSCons.noisy_ar)
142 test.run(program = prog1,
143 stdout = "f1.c 2\nprog.c\n")
145 test.up_to_date(arguments = '.')
147 # We need at least one file for some implementations of the Library
148 # builder, notably the SGI one.
149 test.write('empty.c', '')
151 # Check that a null-string LIBPATH doesn't blow up.
152 test.write('SConstruct', """
153 env = Environment(LIBPATH = '')
154 env.Library('foo', source = 'empty.c')
157 test.run(arguments = '.', stderr=TestSCons.noisy_ar)