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
+ ' ' + variant_prog
+ ' ' + subdir_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 F77PATH=['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
56 obj = env.Object(target='foobar/prog', source='subdir/prog.f77')
57 env.Program(target='prog', source=obj)
58 SConscript('subdir/SConscript', "env")
60 VariantDir('variant', 'subdir', 0)
61 include = Dir('include')
62 env = Environment(F77='%s', F77PATH=[include, '#foobar', '#subdir'], F77FLAGS='-x f77')
63 SConscript('variant/SConscript', "env")
66 test
.write(['subdir', 'SConscript'],
69 env.Program(target='prog', source='prog.f77')
72 test
.write(['include', 'foo.f77'],
74 PRINT *, 'include/foo.f77 1'
78 test
.write(['include', 'bar.f77'],
80 PRINT *, 'include/bar.f77 1'
83 test
.write(['subdir', 'prog.f77'],
86 PRINT *, 'subdir/prog.f77'
94 test
.write(['subdir', 'include', 'foo.f77'],
96 PRINT *, 'subdir/include/foo.f77 1'
100 test
.write(['subdir', 'include', 'bar.f77'],
102 PRINT *, 'subdir/include/bar.f77 1'
105 test
.write(['subdir', 'sss.f77'],
107 PRINT *, 'subdir/sss.f77'
110 test
.write(['subdir', 'ttt.f77'],
112 PRINT *, 'subdir/ttt.f77'
115 test
.run(arguments
= args
)
117 test
.run(program
= test
.workpath(prog
),
126 test
.run(program
= test
.workpath(subdir_prog
),
129 subdir/include/foo.f77 1
130 subdir/include/bar.f77 1
135 test
.run(program
= test
.workpath(variant_prog
),
144 # Make sure we didn't duplicate the source file in the variant subdirectory.
145 test
.must_not_exist(test
.workpath('variant', 'prog.f77'))
147 test
.up_to_date(arguments
= args
)
149 test
.write(['include', 'foo.f77'],
151 PRINT *, 'include/foo.f77 2'
155 test
.run(arguments
= args
)
157 test
.run(program
= test
.workpath(prog
),
166 test
.run(program
= test
.workpath(subdir_prog
),
169 subdir/include/foo.f77 1
170 subdir/include/bar.f77 1
175 test
.run(program
= test
.workpath(variant_prog
),
184 # Make sure we didn't duplicate the source file in the variant subdirectory.
185 test
.must_not_exist(test
.workpath('variant', 'prog.f77'))
187 test
.up_to_date(arguments
= args
)
189 test
.write(['include', 'bar.f77'],
191 PRINT *, 'include/bar.f77 2'
194 test
.run(arguments
= args
)
196 test
.run(program
= test
.workpath(prog
),
205 test
.run(program
= test
.workpath(subdir_prog
),
208 subdir/include/foo.f77 1
209 subdir/include/bar.f77 1
214 test
.run(program
= test
.workpath(variant_prog
),
223 # Make sure we didn't duplicate the source file in the variant subdirectory.
224 test
.must_not_exist(test
.workpath('variant', 'prog.f77'))
226 test
.up_to_date(arguments
= args
)
228 # Change F77PATH and make sure we don't rebuild because of it.
229 test
.write('SConstruct', """\
230 DefaultEnvironment(tools=[]) # test speedup
233 F77PATH=Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
236 obj = env.Object(target='foobar/prog', source='subdir/prog.f77')
237 env.Program(target='prog', source=obj)
238 SConscript('subdir/SConscript', "env")
240 VariantDir('variant', 'subdir', 0)
241 include = Dir('include')
243 F77='%s', F77PATH=['inc2', include, '#foobar', '#subdir'], F77FLAGS='-x f77'
245 SConscript('variant/SConscript', "env")
248 test
.up_to_date(arguments
= args
)
251 test
.write(['inc2', 'foo.f77'],
253 PRINT *, 'inc2/foo.f77 1'
257 test
.run(arguments
= args
)
259 test
.run(program
= test
.workpath(prog
),
268 test
.run(program
= test
.workpath(subdir_prog
),
271 subdir/include/foo.f77 1
272 subdir/include/bar.f77 1
277 test
.run(program
= test
.workpath(variant_prog
),
286 test
.up_to_date(arguments
= args
)
288 # Check that a null-string F77PATH doesn't blow up.
289 test
.write('SConstruct', """\
290 DefaultEnvironment(tools=[]) # test speedup
291 env = Environment(tools=['%s'], F77PATH='', F77FLAGS='-x f77')
292 env.Object('foo', source='empty.f77')
295 test
.write('empty.f77', '')
296 test
.run(arguments
= '.')
302 # indent-tabs-mode:nil
304 # vim: set expandtab tabstop=4 shiftwidth=4: