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__"
32 FTN_LIB = TestSCons.fortran_lib
34 subdir_prog = os.path.join('subdir', 'prog' + _exe)
35 variant_prog = os.path.join('variant', 'prog' + _exe)
37 args = prog + ' ' + subdir_prog + ' ' + variant_prog
39 test = TestSCons.TestSCons()
41 if not test.detect('_FORTRANG', 'g77'):
42 test.skip_test('Could not find a $F77 tool; skipping test.\n')
44 test.subdir('include',
46 ['subdir', 'include'],
52 test.write('SConstruct', """
53 env = Environment(FORTRANPATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
54 LIBS = %s, FOO='include')
55 obj = env.Object(target='foobar/prog', source='subdir/prog.f')
56 env.Program(target='prog', source=obj)
57 SConscript('subdir/SConscript', "env")
59 VariantDir('variant', 'subdir', 0)
60 include = Dir('include')
61 env = Environment(FORTRANPATH=[include, '#foobar', '#subdir'],
63 SConscript('variant/SConscript', "env")
64 """ % (FTN_LIB, FTN_LIB))
66 test.write(['subdir', 'SConscript'],
69 env.Program(target='prog', source='prog.f')
72 test.write(['include', 'foo.f'],
74 PRINT *, 'include/foo.f 1'
78 test.write(['include', 'bar.f'],
80 PRINT *, 'include/bar.f 1'
83 test.write(['subdir', 'prog.f'],
86 PRINT *, 'subdir/prog.f'
94 test.write(['subdir', 'include', 'foo.f'],
96 PRINT *, 'subdir/include/foo.f 1'
100 test.write(['subdir', 'include', 'bar.f'],
102 PRINT *, 'subdir/include/bar.f 1'
105 test.write(['subdir', 'sss.f'],
107 PRINT *, 'subdir/sss.f'
110 test.write(['subdir', 'ttt.f'],
112 PRINT *, 'subdir/ttt.f'
117 test.run(arguments = args)
119 test.run(program = test.workpath(prog),
128 test.run(program = test.workpath(subdir_prog),
131 subdir/include/foo.f 1
132 subdir/include/bar.f 1
137 test.run(program = test.workpath(variant_prog),
146 # Make sure we didn't duplicate the source file in the variant subdirectory.
147 test.must_not_exist(test.workpath('variant', 'prog.f'))
149 test.up_to_date(arguments = args)
153 test.write(['include', 'foo.f'],
155 PRINT *, 'include/foo.f 2'
159 test.run(arguments = args)
161 test.run(program = test.workpath(prog),
170 test.run(program = test.workpath(subdir_prog),
173 subdir/include/foo.f 1
174 subdir/include/bar.f 1
179 test.run(program = test.workpath(variant_prog),
188 # Make sure we didn't duplicate the source file in the variant subdirectory.
189 test.must_not_exist(test.workpath('variant', 'prog.f'))
191 test.up_to_date(arguments = args)
196 test.write(['include', 'bar.f'],
198 PRINT *, 'include/bar.f 2'
201 test.run(arguments = args)
203 test.run(program = test.workpath(prog),
212 test.run(program = test.workpath(subdir_prog),
215 subdir/include/foo.f 1
216 subdir/include/bar.f 1
221 test.run(program = test.workpath(variant_prog),
230 # Make sure we didn't duplicate the source file in the variant subdirectory.
231 test.must_not_exist(test.workpath('variant', 'prog.f'))
233 test.up_to_date(arguments = args)
237 # Change FORTRANPATH and make sure we don't rebuild because of it.
238 test.write('SConstruct', """
239 env = Environment(FORTRANPATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
241 obj = env.Object(target='foobar/prog', source='subdir/prog.f')
242 env.Program(target='prog', source=obj)
243 SConscript('subdir/SConscript', "env")
245 VariantDir('variant', 'subdir', 0)
246 include = Dir('include')
247 env = Environment(FORTRANPATH=['inc2', include, '#foobar', '#subdir'],
249 SConscript('variant/SConscript', "env")
250 """ % (FTN_LIB, FTN_LIB))
252 test.up_to_date(arguments = args)
257 test.write(['inc2', 'foo.f'],
259 PRINT *, 'inc2/foo.f 1'
263 test.run(arguments = args)
265 test.run(program = test.workpath(prog),
274 test.run(program = test.workpath(subdir_prog),
277 subdir/include/foo.f 1
278 subdir/include/bar.f 1
283 test.run(program = test.workpath(variant_prog),
292 test.up_to_date(arguments = args)
296 # Check that a null-string FORTRANPATH doesn't blow up.
297 test.write('SConstruct', """
298 env = Environment(FORTRANPATH = '', LIBS = %s)
299 env.Object('foo', source = 'empty.f')
302 test.write('empty.f', '')
304 test.run(arguments = '.')