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.
32 subdir_prog
= os
.path
.join('subdir', 'prog' + _exe
)
33 variant_prog
= os
.path
.join('variant', 'prog' + _exe
)
35 args
= prog
+ ' ' + subdir_prog
+ ' ' + variant_prog
37 test
= TestSCons
.TestSCons()
40 if not test
.detect_tool(fc
):
41 # gfortran names all variants the same, try it too
43 if not test
.detect_tool(fc
):
44 test
.skip_test('Could not find a f77 tool; skipping test.\n')
46 test
.subdir('include', 'subdir', ['subdir', 'include'], 'foobar', 'inc2')
48 test
.write('SConstruct', """\
49 DefaultEnvironment(tools=[]) # test speedup
52 FORTRANPATH=['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
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(FORTRAN='%s', FORTRANPATH=[include, '#foobar', '#subdir'])
62 SConscript('variant/SConscript', "env")
65 test
.write(['subdir', 'SConscript'],
68 env.Program(target='prog', source='prog.f')
71 test
.write(['include', 'foo.f'],
73 PRINT *, 'include/foo.f 1'
77 test
.write(['include', 'bar.f'],
79 PRINT *, 'include/bar.f 1'
82 test
.write(['subdir', 'prog.f'],
85 PRINT *, 'subdir/prog.f'
93 test
.write(['subdir', 'include', 'foo.f'],
95 PRINT *, 'subdir/include/foo.f 1'
99 test
.write(['subdir', 'include', 'bar.f'],
101 PRINT *, 'subdir/include/bar.f 1'
104 test
.write(['subdir', 'sss.f'],
106 PRINT *, 'subdir/sss.f'
109 test
.write(['subdir', 'ttt.f'],
111 PRINT *, 'subdir/ttt.f'
116 if sys
.platform
[:5] == 'sunos':
117 # Sun f77 always put some junk in stderr
118 test
.run(arguments
= args
, stderr
= None)
120 test
.run(arguments
= args
)
122 test
.run(program
= test
.workpath(prog
),
131 test
.run(program
= test
.workpath(subdir_prog
),
134 subdir/include/foo.f 1
135 subdir/include/bar.f 1
140 test
.run(program
= test
.workpath(variant_prog
),
149 # Make sure we didn't duplicate the source file in the variant subdirectory.
150 test
.must_not_exist(test
.workpath('variant', 'prog.f'))
152 test
.up_to_date(arguments
= args
)
154 test
.write(['include', 'foo.f'],
156 PRINT *, 'include/foo.f 2'
160 if sys
.platform
[:5] == 'sunos':
161 # Sun f77 always put some junk in stderr
162 test
.run(arguments
= args
, stderr
= None)
164 test
.run(arguments
= args
)
166 test
.run(program
= test
.workpath(prog
),
175 test
.run(program
= test
.workpath(subdir_prog
),
178 subdir/include/foo.f 1
179 subdir/include/bar.f 1
184 test
.run(program
= test
.workpath(variant_prog
),
193 # Make sure we didn't duplicate the source file in the variant subdirectory.
194 test
.must_not_exist(test
.workpath('variant', 'prog.f'))
196 test
.up_to_date(arguments
= args
)
198 test
.write(['include', 'bar.f'],
200 PRINT *, 'include/bar.f 2'
203 if sys
.platform
[:5] == 'sunos':
204 # Sun f77 always put some junk in stderr
205 test
.run(arguments
= args
, stderr
= None)
207 test
.run(arguments
= args
)
210 test
.run(program
= test
.workpath(prog
),
219 test
.run(program
= test
.workpath(subdir_prog
),
222 subdir/include/foo.f 1
223 subdir/include/bar.f 1
228 test
.run(program
= test
.workpath(variant_prog
),
237 # Make sure we didn't duplicate the source file in the variant subdirectory.
238 test
.must_not_exist(test
.workpath('variant', 'prog.f'))
240 test
.up_to_date(arguments
= args
)
244 # Change FORTRANPATH and make sure we don't rebuild because of it.
245 test
.write('SConstruct', """\
246 DefaultEnvironment(tools=[]) # test speedup
249 FORTRANPATH=Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
251 obj = env.Object(target='foobar/prog', source='subdir/prog.f')
252 env.Program(target='prog', source=obj)
253 SConscript('subdir/SConscript', "env")
255 VariantDir('variant', 'subdir', 0)
256 include = Dir('include')
259 FORTRANPATH=['inc2', include, '#foobar', '#subdir'],
261 SConscript('variant/SConscript', "env")
264 test
.up_to_date(arguments
= args
)
266 test
.write(['inc2', 'foo.f'],
268 PRINT *, 'inc2/foo.f 1'
272 if sys
.platform
[:5] == 'sunos':
273 # Sun f77 always put some junk in stderr
274 test
.run(arguments
= args
, stderr
= None)
276 test
.run(arguments
= args
)
279 test
.run(program
= test
.workpath(prog
),
288 test
.run(program
= test
.workpath(subdir_prog
),
291 subdir/include/foo.f 1
292 subdir/include/bar.f 1
297 test
.run(program
= test
.workpath(variant_prog
),
306 test
.up_to_date(arguments
= args
)
308 # Check that a null-string FORTRANPATH doesn't blow up.
309 test
.write('SConstruct', """
310 DefaultEnvironment(tools=[]) # test speedup
311 env = Environment(FORTRANPATH = '')
312 env.Object('foo', source = 'empty.f')
315 test
.write('empty.f', '')
317 if sys
.platform
[:5] == 'sunos':
318 # Sun f77 always put some junk in stderr
319 test
.run(arguments
= '.', stderr
= None)
321 test
.run(arguments
= '.')
327 # indent-tabs-mode:nil
329 # vim: set expandtab tabstop=4 shiftwidth=4: