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__"
28 Validate that $FORTRANMODDIR values get expanded correctly on Fortran
29 command lines relative to the appropriate subdirectory.
36 _python_
= TestSCons
._python
_
38 test
= TestSCons
.TestSCons()
44 test
.write('myfortran.py', r
"""
48 comment = ('#' + sys.argv[1]).encode()
50 opts, args = getopt.getopt(sys.argv[2:], 'cM:o:')
52 if opt == '-o': out = arg
53 elif opt == '-M': modsubdir = arg
55 with open(out, 'wb') as ofp, open(args[0], 'rb') as ifp:
56 for l in ifp.readlines():
57 if l[:7] == b'module ':
58 module = modsubdir + os.sep + l[7:-1].decode() + '.mod'
59 with open(module, 'wb') as f:
60 f.write(('myfortran.py wrote %s\n' % module).encode())
61 if l[:length] != comment:
66 test
.write('myar.py', """\
68 with open(sys.argv[1], 'wb') as ofp:
69 for s in sys.argv[2:]:
70 with open(s, 'rb') as ifp:
75 test
.write('SConstruct', """\
76 env = Environment(FORTRANMODDIRPREFIX = '-M',
77 FORTRANMODDIR = 'modules',
78 FORTRAN = r'%(_python_)s myfortran.py fortran',
80 ARCOM = r'%(_python_)s $AR $TARGET $SOURCES',
83 objs = SConscript('subdir/SConscript')
84 env.Library('bidule', objs)
87 test
.write(['subdir', 'SConscript'], """\
90 env['FORTRANMODDIR'] = 'build'
91 sources = ['src/modfile.f']
92 objs = env.Object(sources)
96 test
.write(['subdir', 'src', 'modfile.f'], """\
106 test
.run(arguments
= '.')
108 somemodule
= os
.path
.join('subdir', 'build', 'somemodule.mod')
110 expect
= "myfortran.py wrote %s\n" % somemodule
112 test
.must_match(['subdir', 'build', 'somemodule.mod'], expect
)
118 # indent-tabs-mode:nil
120 # vim: set expandtab tabstop=4 shiftwidth=4: