__all__.extend([ 'TestCommon',
'exe_suffix',
'obj_suffix',
+ 'shobj_prefix',
'shobj_suffix',
'lib_prefix',
'lib_suffix',
exe_suffix = '.exe'
obj_suffix = '.obj'
shobj_suffix = '.obj'
+ shobj_prefix = ''
lib_prefix = ''
lib_suffix = '.lib'
dll_prefix = ''
exe_suffix = '.exe'
obj_suffix = '.o'
shobj_suffix = '.os'
+ shobj_prefix = ''
lib_prefix = 'lib'
lib_suffix = '.a'
dll_prefix = ''
exe_suffix = ''
obj_suffix = '.o'
shobj_suffix = '.o'
+ shobj_prefix = ''
lib_prefix = 'lib'
lib_suffix = '.a'
dll_prefix = 'lib'
exe_suffix = ''
obj_suffix = '.o'
shobj_suffix = '.os'
+ shobj_prefix = ''
+ lib_prefix = 'lib'
+ lib_suffix = '.a'
+ dll_prefix = 'lib'
+ dll_suffix = '.dylib'
+elif string.find(sys.platform, 'sunos') != -1:
+ exe_suffix = ''
+ obj_suffix = '.o'
+ shobj_suffix = '.os'
+ shobj_prefix = 'so_'
lib_prefix = 'lib'
lib_suffix = '.a'
dll_prefix = 'lib'
exe_suffix = ''
obj_suffix = '.o'
shobj_suffix = '.os'
+ shobj_prefix = ''
lib_prefix = 'lib'
lib_suffix = '.a'
dll_prefix = 'lib'
copyright_years = '2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008'
-SConsVersion = '0.98.0'
+# In the checked-in source, the value of SConsVersion in the following
+# line must remain "__ VERSION __" (without the spaces) so the built
+# version in build/QMTest/TestSCons.py contains the actual version
+# string of the packages that have been built.
+SConsVersion = '__VERSION__'
if SConsVersion == '__' + 'VERSION' + '__':
SConsVersion = default_version
'_exe',
'_obj',
'_shobj',
+ 'shobj_',
'lib_',
'_lib',
'dll_',
_exe = exe_suffix
_obj = obj_suffix
_shobj = shobj_suffix
+shobj_ = shobj_prefix
_lib = lib_suffix
lib_ = lib_prefix
_dll = dll_suffix
sunar
sunc++
suncc
+sunf77
+sunf90
+sunf95
sunlink
swig
tar
- Fix the ability to use LoadableModule() under MinGW.
+ From David Cournapeau:
+
+ - Various missing Fortran-related construction variables have been added.
+
+ - SCons now uses the program specified in the $FORTRAN construction
+ variable to link Fortran object files.
+
+ - Fortran compilers on Linux (Intel, g77 and gfortran) now add the -fPIC
+ option by default when compilling shared objects.
+
+ - New 'sunf77', 'sunf90' and 'sunf95' Tool modules have been added to
+ support Sun Fortran compilers. On Solaris, the Sun Fortran compilers
+ are used in preference to other compilers by default.
+
+ - Fortran support now uses gfortran in preference to g77.
+
+ - Fortran file suffixes are now configurable through the
+ $F77FILESUFFIXES, $F90FILESUFFIXES, $F95FILESUFFIXES and
+ $FORTRANFILESUFFIXES variables.
+
From Steven Knight:
- Make the -d, -e, -w and --no-print-directory options "Ignored for
will not cause any compilation problems, but the change to the
command line may cause SCons to rebuild object files.
+ -- FORTRAN NOW COMPILES .f FILES WITH gfortran BY DEFAULT
+
+ The Fortran Tool modules have had a major overhaul with the intent
+ of making them work as-is for most configurations. In general,
+ most configurations that use default settings should not see
+ any noticeable difference.
+
+ One configuration that has changed is if you have both a gfortran
+ and g77 compiler installed. In this case, previous versions of
+ SCons would, by default, use g77 by default to compile files with
+ a .f suffix, while SCons 0.98.1 will use the gfortran compiler
+ by default. The old behavior may be preserved by explicitly
+ initializing construction environments with the 'g77' Tool module:
+
+ env = Environment(tools = ['g77', 'default'])
+
+ The above code is backwards compatible to older versions of SCons.
+
+ If you notice any other changes in the behavior of default
+ Fortran support, please let us know so we can document them in
+ these release notes for other users.
+
Please note the following important changes since release 0.97.0d20071212:
-- SUPPORT FOR PYTHON VERSIONS BEFORE 2.2 IS NOW DEPRECATED
SCons/Tool/f95.py
SCons/Tool/filesystem.py
SCons/Tool/fortran.py
+SCons/Tool/FortranCommon.py
SCons/Tool/g++.py
SCons/Tool/g77.py
SCons/Tool/gas.py
SCons/Tool/sunar.py
SCons/Tool/sunc++.py
SCons/Tool/suncc.py
+SCons/Tool/sunf77.py
+SCons/Tool/sunf90.py
+SCons/Tool/sunf95.py
SCons/Tool/sunlink.py
SCons/Tool/swig.py
SCons/Tool/tar.py
--- /dev/null
+"""SCons.Tool.FortranCommon
+
+Stuff for processing Fortran, common to all fortran dialects.
+
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import re
+import string
+import os.path
+
+import SCons.Action
+import SCons.Defaults
+import SCons.Scanner.Fortran
+import SCons.Tool
+import SCons.Util
+
+def isfortran(env, source):
+ """Return 1 if any of code in source has fortran files in it, 0
+ otherwise."""
+ try:
+ fsuffixes = env['FORTRANSUFFIXES']
+ except KeyError:
+ # If no FORTRANSUFFIXES, no fortran tool, so there is no need to look
+ # for fortran sources.
+ return 0
+
+ if not source:
+ # Source might be None for unusual cases like SConf.
+ return 0
+ for s in source:
+ if s.sources:
+ ext = os.path.splitext(str(s.sources[0]))[1]
+ if ext in fsuffixes:
+ return 1
+ return 0
+
+def _fortranEmitter(target, source, env):
+ node = source[0].rfile()
+ if not node.exists() and not node.is_derived():
+ print "Could not locate " + str(node.name)
+ return ([], [])
+ mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
+ cre = re.compile(mod_regex,re.M)
+ # Retrieve all USE'd module names
+ modules = cre.findall(node.get_contents())
+ # Remove unique items from the list
+ modules = SCons.Util.unique(modules)
+ # Convert module name to a .mod filename
+ suffix = env.subst('$FORTRANMODSUFFIX', target=target, source=source)
+ moddir = env.subst('$FORTRANMODDIR', target=target, source=source)
+ modules = map(lambda x, s=suffix: string.lower(x) + s, modules)
+ for m in modules:
+ target.append(env.fs.File(m, moddir))
+ return (target, source)
+
+def FortranEmitter(target, source, env):
+ target, source = _fortranEmitter(target, source, env)
+ return SCons.Defaults.StaticObjectEmitter(target, source, env)
+
+def ShFortranEmitter(target, source, env):
+ target, source = _fortranEmitter(target, source, env)
+ return SCons.Defaults.SharedObjectEmitter(target, source, env)
+
+def ComputeFortranSuffixes(suffixes, ppsuffixes):
+ """suffixes are fortran source files, and ppsuffixes the ones to be
+ pre-processed. Both should be sequences, not strings."""
+ assert len(suffixes) > 0
+ s = suffixes[0]
+ sup = string.upper(s)
+ if SCons.Util.case_sensitive_suffixes(s, sup):
+ for i in suffixes:
+ ppsuffixes.append(string.upper(i))
+ else:
+ for i in suffixes:
+ suffixes.append(string.upper(i))
+
+def CreateDialectActions(dialect):
+ """Create dialect specific actions."""
+ CompAction = SCons.Action.Action('$%sCOM ' % dialect, '$%sCOMSTR' % dialect)
+ CompPPAction = SCons.Action.Action('$%sPPCOM ' % dialect, '$%sPPCOMSTR' % dialect)
+ ShCompAction = SCons.Action.Action('$SH%sCOM ' % dialect, '$SH%sCOMSTR' % dialect)
+ ShCompPPAction = SCons.Action.Action('$SH%sPPCOM ' % dialect, '$SH%sPPCOMSTR' % dialect)
+
+ return CompAction, CompPPAction, ShCompAction, ShCompPPAction
+
+def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module = 0):
+ """Add dialect specific construction variables."""
+ ComputeFortranSuffixes(suffixes, ppsuffixes)
+
+ fscan = SCons.Scanner.Fortran.FortranScan("%sPATH" % dialect)
+
+ for suffix in suffixes + ppsuffixes:
+ SCons.Tool.SourceFileScanner.add_scanner(suffix, fscan)
+
+ env.AppendUnique(FORTRANSUFFIXES = suffixes + ppsuffixes)
+
+ compaction, compppaction, shcompaction, shcompppaction = \
+ CreateDialectActions(dialect)
+
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in suffixes:
+ static_obj.add_action(suffix, compaction)
+ shared_obj.add_action(suffix, shcompaction)
+ static_obj.add_emitter(suffix, FortranEmitter)
+ shared_obj.add_emitter(suffix, ShFortranEmitter)
+
+ for suffix in ppsuffixes:
+ static_obj.add_action(suffix, compppaction)
+ shared_obj.add_action(suffix, shcompppaction)
+ static_obj.add_emitter(suffix, FortranEmitter)
+ shared_obj.add_emitter(suffix, ShFortranEmitter)
+
+ if not env.has_key('%sFLAGS' % dialect):
+ env['%sFLAGS' % dialect] = SCons.Util.CLVar('')
+
+ if not env.has_key('SH%sFLAGS' % dialect):
+ env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS' % dialect)
+
+ # If a tool does not define fortran prefix/suffix for include path, use C ones
+ if not env.has_key('INC%sPREFIX' % dialect):
+ env['INC%sPREFIX' % dialect] = '$INCPREFIX'
+
+ if not env.has_key('INC%sSUFFIX' % dialect):
+ env['INC%sSUFFIX' % dialect] = '$INCSUFFIX'
+
+ env['_%sINCFLAGS' % dialect] = '$( ${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)' % (dialect, dialect, dialect)
+
+ if support_module == 1:
+ env['%sCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)
+ env['%sPPCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)
+ env['SH%sCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)
+ env['SH%sPPCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $_FORTRANMODFLAG $SOURCES' % (dialect, dialect, dialect)
+ else:
+ env['%sCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect)
+ env['%sPPCOM' % dialect] = '$%s -o $TARGET -c $%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect)
+ env['SH%sCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect)
+ env['SH%sPPCOM' % dialect] = '$SH%s -o $TARGET -c $SH%sFLAGS $CPPFLAGS $_CPPDEFFLAGS $_%sINCFLAGS $SOURCES' % (dialect, dialect, dialect)
+
+def add_fortran_to_env(env):
+ """Add Builders and construction variables for Fortran to an Environment."""
+ try:
+ FortranSuffixes = env['FORTRANFILESUFFIXES']
+ except KeyError:
+ FortranSuffixes = ['.f', '.for', '.ftn']
+
+ #print "Adding %s to fortran suffixes" % FortranSuffixes
+ try:
+ FortranPPSuffixes = env['FORTRANPPFILESUFFIXES']
+ except KeyError:
+ FortranPPSuffixes = ['.fpp', '.FPP']
+
+ DialectAddToEnv(env, "FORTRAN", FortranSuffixes,
+ FortranPPSuffixes, support_module = 1)
+
+ env['FORTRANMODPREFIX'] = '' # like $LIBPREFIX
+ env['FORTRANMODSUFFIX'] = '.mod' # like $LIBSUFFIX
+
+ env['FORTRANMODDIR'] = '' # where the compiler should place .mod files
+ env['FORTRANMODDIRPREFIX'] = '' # some prefix to $FORTRANMODDIR - similar to $INCPREFIX
+ env['FORTRANMODDIRSUFFIX'] = '' # some suffix to $FORTRANMODDIR - similar to $INCSUFFIX
+ env['_FORTRANMODFLAG'] = '$( ${_concat(FORTRANMODDIRPREFIX, FORTRANMODDIR, FORTRANMODDIRSUFFIX, __env__, RDirs)} $)'
+
+def add_f77_to_env(env):
+ """Add Builders and construction variables for f77 to an Environment."""
+ try:
+ F77Suffixes = env['F77FILESUFFIXES']
+ except KeyError:
+ F77Suffixes = ['.f77']
+
+ #print "Adding %s to f77 suffixes" % F77Suffixes
+ try:
+ F77PPSuffixes = env['F77PPFILESUFFIXES']
+ except KeyError:
+ F77PPSuffixes = []
+
+ DialectAddToEnv(env, "F77", F77Suffixes, F77PPSuffixes)
+
+def add_f90_to_env(env):
+ """Add Builders and construction variables for f90 to an Environment."""
+ try:
+ F90Suffixes = env['F90FILESUFFIXES']
+ except KeyError:
+ F90Suffixes = ['.f90']
+
+ #print "Adding %s to f90 suffixes" % F90Suffixes
+ try:
+ F90PPSuffixes = env['F90PPFILESUFFIXES']
+ except KeyError:
+ F90PPSuffixes = []
+
+ DialectAddToEnv(env, "F90", F90Suffixes, F90PPSuffixes,
+ support_module = 1)
+
+def add_f95_to_env(env):
+ """Add Builders and construction variables for f95 to an Environment."""
+ try:
+ F95Suffixes = env['F95FILESUFFIXES']
+ except KeyError:
+ F95Suffixes = ['.f95']
+
+ #print "Adding %s to f95 suffixes" % F95Suffixes
+ try:
+ F95PPSuffixes = env['F95PPFILESUFFIXES']
+ except KeyError:
+ F95PPSuffixes = []
+
+ DialectAddToEnv(env, "F95", F95Suffixes, F95PPSuffixes,
+ support_module = 1)
+
+def add_all_to_env(env):
+ """Add builders and construction variables for all supported fortran
+ dialects."""
+ add_fortran_to_env(env)
+ add_f77_to_env(env)
+ add_f90_to_env(env)
+ add_f95_to_env(env)
c_compilers = ['msvc', 'mingw', 'gcc', 'intelc', 'icl', 'icc', 'cc', 'bcc32' ]
cxx_compilers = ['msvc', 'intelc', 'icc', 'g++', 'c++', 'bcc32' ]
assemblers = ['masm', 'nasm', 'gas', '386asm' ]
- fortran_compilers = ['g77', 'ifl', 'cvf', 'f95', 'f90', 'fortran']
+ fortran_compilers = ['gfortran', 'g77', 'ifl', 'cvf', 'f95', 'f90', 'fortran']
ars = ['mslib', 'ar', 'tlib']
elif str(platform) == 'os2':
"prefer IBM tools on OS/2"
c_compilers = ['suncc', 'gcc', 'cc']
cxx_compilers = ['sunc++', 'g++', 'c++']
assemblers = ['as', 'gas']
- fortran_compilers = ['f95', 'f90', 'f77', 'g77', 'fortran']
+ fortran_compilers = ['sunf95', 'sunf90', 'sunf77', 'f95', 'f90', 'f77',
+ 'gfortran', 'g77', 'fortran']
ars = ['sunar']
elif str(platform) == 'hpux':
"prefer aCC tools on HP-UX"
c_compilers = ['gcc', 'cc']
cxx_compilers = ['g++', 'c++']
assemblers = ['as']
- fortran_compilers = ['f95', 'f90', 'g77']
+ fortran_compilers = ['gfortran', 'f95', 'f90', 'g77']
ars = ['ar']
else:
"prefer GNU tools on all other platforms"
c_compilers = ['gcc', 'msvc', 'intelc', 'icc', 'cc']
cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'c++']
assemblers = ['gas', 'nasm', 'masm']
- fortran_compilers = ['f95', 'f90', 'g77', 'ifort', 'ifl', 'fortran']
+ fortran_compilers = ['gfortran', 'g77', 'ifort', 'ifl', 'f95', 'f90', 'f77']
ars = ['ar', 'mslib']
c_compiler = FindTool(c_compilers, env) or c_compilers[0]
import SCons.Scanner.Fortran
import SCons.Tool
import SCons.Util
-import fortran
+from SCons.Tool.FortranCommon import add_all_to_env, add_f77_to_env
compilers = ['f77']
-#
-F77Suffixes = ['.f77']
-F77PPSuffixes = []
-if SCons.Util.case_sensitive_suffixes('.f77', '.F77'):
- F77PPSuffixes.append('.F77')
-else:
- F77Suffixes.append('.F77')
-
-#
-F77Scan = SCons.Scanner.Fortran.FortranScan("F77PATH")
-
-for suffix in F77Suffixes + F77PPSuffixes:
- SCons.Tool.SourceFileScanner.add_scanner(suffix, F77Scan)
-del suffix
-
-#
-fVLG = fortran.VariableListGenerator
-
-F77Generator = fVLG('F77', 'FORTRAN', '_FORTRAND')
-F77FlagsGenerator = fVLG('F77FLAGS', 'FORTRANFLAGS')
-F77CommandGenerator = fVLG('F77COM', 'FORTRANCOM', '_F77COMD')
-F77CommandStrGenerator = fVLG('F77COMSTR', 'FORTRANCOMSTR', '_F77COMSTRD')
-F77PPCommandGenerator = fVLG('F77PPCOM', 'FORTRANPPCOM', '_F77PPCOMD')
-F77PPCommandStrGenerator = fVLG('F77PPCOMSTR', 'FORTRANPPCOMSTR', '_F77PPCOMSTRD')
-ShF77Generator = fVLG('SHF77', 'SHFORTRAN', 'F77', 'FORTRAN', '_FORTRAND')
-ShF77FlagsGenerator = fVLG('SHF77FLAGS', 'SHFORTRANFLAGS')
-ShF77CommandGenerator = fVLG('SHF77COM', 'SHFORTRANCOM', '_SHF77COMD')
-ShF77CommandStrGenerator = fVLG('SHF77COMSTR', 'SHFORTRANCOMSTR', '_SHF77COMSTRD')
-ShF77PPCommandGenerator = fVLG('SHF77PPCOM', 'SHFORTRANPPCOM', '_SHF77PPCOMD')
-ShF77PPCommandStrGenerator = fVLG('SHF77PPCOMSTR', 'SHFORTRANPPCOMSTR', '_SHF77PPCOMSTRD')
-
-del fVLG
-
-#
-F77Action = SCons.Action.Action('$_F77COMG ', '$_F77COMSTRG')
-F77PPAction = SCons.Action.Action('$_F77PPCOMG ', '$_F77PPCOMSTRG')
-ShF77Action = SCons.Action.Action('$_SHF77COMG ', '$_SHF77COMSTRG')
-ShF77PPAction = SCons.Action.Action('$_SHF77PPCOMG ', '$_SHF77PPCOMSTRG')
-
-def add_to_env(env):
- """Add Builders and construction variables for f77 to an Environment."""
- env.AppendUnique(FORTRANSUFFIXES = F77Suffixes + F77PPSuffixes)
-
- static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
-
- for suffix in F77Suffixes:
- static_obj.add_action(suffix, F77Action)
- shared_obj.add_action(suffix, ShF77Action)
- static_obj.add_emitter(suffix, fortran.FortranEmitter)
- shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
-
- for suffix in F77PPSuffixes:
- static_obj.add_action(suffix, F77PPAction)
- shared_obj.add_action(suffix, ShF77PPAction)
- static_obj.add_emitter(suffix, fortran.FortranEmitter)
- shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
-
- env['_F77G'] = F77Generator
- env['_F77FLAGSG'] = F77FlagsGenerator
- env['_F77COMG'] = F77CommandGenerator
- env['_F77PPCOMG'] = F77PPCommandGenerator
- env['_F77COMSTRG'] = F77CommandStrGenerator
- env['_F77PPCOMSTRG'] = F77PPCommandStrGenerator
-
- env['_SHF77G'] = ShF77Generator
- env['_SHF77FLAGSG'] = ShF77FlagsGenerator
- env['_SHF77COMG'] = ShF77CommandGenerator
- env['_SHF77PPCOMG'] = ShF77PPCommandGenerator
- env['_SHF77COMSTRG'] = ShF77CommandStrGenerator
- env['_SHF77PPCOMSTRG'] = ShF77PPCommandStrGenerator
-
- env['_F77INCFLAGS'] = '$( ${_concat(INCPREFIX, F77PATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
-
- env['_F77COMD'] = '$_F77G -o $TARGET -c $_F77FLAGSG $_F77INCFLAGS $SOURCES'
- env['_F77PPCOMD'] = '$_F77G -o $TARGET -c $_F77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS $SOURCES'
- env['_SHF77COMD'] = '$_SHF77G -o $TARGET -c $_SHF77FLAGSG $_F77INCFLAGS $SOURCES'
- env['_SHF77PPCOMD'] = '$_SHF77G -o $TARGET -c $_SHF77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS $SOURCES'
-
def generate(env):
- fortran.add_to_env(env)
-
- import f90
- import f95
- f90.add_to_env(env)
- f95.add_to_env(env)
+ add_all_to_env(env)
+ add_f77_to_env(env)
- add_to_env(env)
+ fcomp = env.Detect(compilers) or 'f77'
+ env['F77'] = fcomp
+ env['SHF77'] = fcomp
- env['_FORTRAND'] = env.Detect(compilers) or 'f77'
+ env['FORTRAN'] = fcomp
+ env['SHFORTRAN'] = fcomp
def exists(env):
return env.Detect(compilers)
F77FLAGS
F77COM
F77PPCOM
+F77FILESUFFIXES
+F77PPFILESUFFIXES
FORTRAN
FORTRANFLAGS
FORTRANCOM
</summary>
</cvar>
+<cvar name="F77FILESUFFIXES">
+<summary>
+The list of file extensions for which the F77 dialect will be used. By
+default, this is ['.f77']
+</summary>
+</cvar>
+
+<cvar name="F77PPFILESUFFIXES">
+<summary>
+The list of file extensions for which the compilation + preprocessor pass for
+F77 dialect will be used. By default, this is empty
+</summary>
+</cvar>
+
<cvar name="F77COMSTR">
<summary>
The string displayed when a Fortran 77 source file
import SCons.Scanner.Fortran
import SCons.Tool
import SCons.Util
-import fortran
+from SCons.Tool.FortranCommon import add_all_to_env, add_f90_to_env
compilers = ['f90']
-#
-F90Suffixes = ['.f90']
-F90PPSuffixes = []
-if SCons.Util.case_sensitive_suffixes('.f90', '.F90'):
- F90PPSuffixes.append('.F90')
-else:
- F90Suffixes.append('.F90')
-
-#
-F90Scan = SCons.Scanner.Fortran.FortranScan("F90PATH")
-
-for suffix in F90Suffixes + F90PPSuffixes:
- SCons.Tool.SourceFileScanner.add_scanner(suffix, F90Scan)
-del suffix
-
-#
-fVLG = fortran.VariableListGenerator
-
-F90Generator = fVLG('F90', 'FORTRAN', '_FORTRAND')
-F90FlagsGenerator = fVLG('F90FLAGS', 'FORTRANFLAGS')
-F90CommandGenerator = fVLG('F90COM', 'FORTRANCOM', '_F90COMD')
-F90CommandStrGenerator = fVLG('F90COMSTR', 'FORTRANCOMSTR', '_F90COMSTRD')
-F90PPCommandGenerator = fVLG('F90PPCOM', 'FORTRANPPCOM', '_F90PPCOMD')
-F90PPCommandStrGenerator = fVLG('F90PPCOMSTR', 'FORTRANPPCOMSTR', '_F90PPCOMSTRD')
-ShF90Generator = fVLG('SHF90', 'SHFORTRAN', 'F90', 'FORTRAN', '_FORTRAND')
-ShF90FlagsGenerator = fVLG('SHF90FLAGS', 'SHFORTRANFLAGS')
-ShF90CommandGenerator = fVLG('SHF90COM', 'SHFORTRANCOM', '_SHF90COMD')
-ShF90CommandStrGenerator = fVLG('SHF90COMSTR', 'SHFORTRANCOMSTR', '_SHF90COMSTRD')
-ShF90PPCommandGenerator = fVLG('SHF90PPCOM', 'SHFORTRANPPCOM', '_SHF90PPCOMD')
-ShF90PPCommandStrGenerator = fVLG('SHF90PPCOMSTR', 'SHFORTRANPPCOMSTR', '_SHF90PPCOMSTRD')
-
-del fVLG
-
-#
-F90Action = SCons.Action.Action('$_F90COMG ', '$_F90COMSTRG')
-F90PPAction = SCons.Action.Action('$_F90PPCOMG ', '$_F90PPCOMSTRG')
-ShF90Action = SCons.Action.Action('$_SHF90COMG ', '$_SHF90COMSTRG')
-ShF90PPAction = SCons.Action.Action('$_SHF90PPCOMG ', '$_SHF90PPCOMSTRG')
-
-def add_to_env(env):
- """Add Builders and construction variables for f90 to an Environment."""
- env.AppendUnique(FORTRANSUFFIXES = F90Suffixes + F90PPSuffixes)
-
- static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
-
- for suffix in F90Suffixes:
- static_obj.add_action(suffix, F90Action)
- shared_obj.add_action(suffix, ShF90Action)
- static_obj.add_emitter(suffix, fortran.FortranEmitter)
- shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
-
- for suffix in F90PPSuffixes:
- static_obj.add_action(suffix, F90PPAction)
- shared_obj.add_action(suffix, ShF90PPAction)
- static_obj.add_emitter(suffix, fortran.FortranEmitter)
- shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
-
- env['_F90G'] = F90Generator
- env['_F90FLAGSG'] = F90FlagsGenerator
- env['_F90COMG'] = F90CommandGenerator
- env['_F90COMSTRG'] = F90CommandStrGenerator
- env['_F90PPCOMG'] = F90PPCommandGenerator
- env['_F90PPCOMSTRG'] = F90PPCommandStrGenerator
-
- env['_SHF90G'] = ShF90Generator
- env['_SHF90FLAGSG'] = ShF90FlagsGenerator
- env['_SHF90COMG'] = ShF90CommandGenerator
- env['_SHF90COMSTRG'] = ShF90CommandStrGenerator
- env['_SHF90PPCOMG'] = ShF90PPCommandGenerator
- env['_SHF90PPCOMSTRG'] = ShF90PPCommandStrGenerator
-
- env['_F90INCFLAGS'] = '$( ${_concat(INCPREFIX, F90PATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
- env['_F90COMD'] = '$_F90G -o $TARGET -c $_F90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG $SOURCES'
- env['_F90PPCOMD'] = '$_F90G -o $TARGET -c $_F90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG $SOURCES'
- env['_SHF90COMD'] = '$_SHF90G -o $TARGET -c $_SHF90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG $SOURCES'
- env['_SHF90PPCOMD'] = '$_SHF90G -o $TARGET -c $_SHF90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG $SOURCES'
-
def generate(env):
- fortran.add_to_env(env)
-
- import f77
- f77.add_to_env(env)
+ add_all_to_env(env)
+ add_f90_to_env(env)
- add_to_env(env)
+ fc = env.Detect(compilers) or 'f90'
+ env['F90'] = fc
+ env['SHF90'] = fc
- env['_FORTRAND'] = env.Detect(compilers) or 'f90'
+ env['FORTRAN'] = fc
+ env['SHFORTRAN'] = fc
def exists(env):
return env.Detect(compilers)
</summary>
</cvar>
+<cvar name="F90FILESUFFIXES">
+<summary>
+The list of file extensions for which the F90 dialect will be used. By
+default, this is ['.f90']
+</summary>
+</cvar>
+
+<cvar name="F90PPFILESUFFIXES">
+<summary>
+The list of file extensions for which the compilation + preprocessor pass for
+F90 dialect will be used. By default, this is empty
+</summary>
+</cvar>
+
<cvar name="F90FLAGS">
<summary>
General user-specified options that are passed to the Fortran 90 compiler.
import SCons.Tool
import SCons.Util
import fortran
+from SCons.Tool.FortranCommon import add_all_to_env, add_f95_to_env
compilers = ['f95']
-#
-F95Suffixes = ['.f95']
-F95PPSuffixes = []
-if SCons.Util.case_sensitive_suffixes('.f95', '.F95'):
- F95PPSuffixes.append('.F95')
-else:
- F95Suffixes.append('.F95')
-
-#
-F95Scan = SCons.Scanner.Fortran.FortranScan("F95PATH")
-
-for suffix in F95Suffixes + F95PPSuffixes:
- SCons.Tool.SourceFileScanner.add_scanner(suffix, F95Scan)
-del suffix
-
-#
-fVLG = fortran.VariableListGenerator
-
-F95Generator = fVLG('F95', 'FORTRAN', '_FORTRAND')
-F95FlagsGenerator = fVLG('F95FLAGS', 'FORTRANFLAGS')
-F95CommandGenerator = fVLG('F95COM', 'FORTRANCOM', '_F95COMD')
-F95CommandStrGenerator = fVLG('F95COMSTR', 'FORTRANCOMSTR', '_F95COMSTRD')
-F95PPCommandGenerator = fVLG('F95PPCOM', 'FORTRANPPCOM', '_F95PPCOMD')
-F95PPCommandStrGenerator = fVLG('F95PPCOMSTR', 'FORTRANPPCOMSTR', '_F95PPCOMSTRD')
-ShF95Generator = fVLG('SHF95', 'SHFORTRAN', 'F95', 'FORTRAN', '_FORTRAND')
-ShF95FlagsGenerator = fVLG('SHF95FLAGS', 'SHFORTRANFLAGS')
-ShF95CommandGenerator = fVLG('SHF95COM', 'SHFORTRANCOM', '_SHF95COMD')
-ShF95CommandStrGenerator = fVLG('SHF95COMSTR', 'SHFORTRANCOMSTR', '_SHF95COMSTRD')
-ShF95PPCommandGenerator = fVLG('SHF95PPCOM', 'SHFORTRANPPCOM', '_SHF95PPCOMD')
-ShF95PPCommandStrGenerator = fVLG('SHF95PPCOMSTR', 'SHFORTRANPPCOMSTR', '_SHF95PPCOMSTRD')
-
-del fVLG
-
-#
-F95Action = SCons.Action.Action('$_F95COMG ', '$_F95COMSTRG')
-F95PPAction = SCons.Action.Action('$_F95PPCOMG ', '$_F95PPCOMSTRG')
-ShF95Action = SCons.Action.Action('$_SHF95COMG ', '$_SHF95COMSTRG')
-ShF95PPAction = SCons.Action.Action('$_SHF95PPCOMG ', '$_SHF95PPCOMSTRG')
-
-def add_to_env(env):
- """Add Builders and construction variables for f95 to an Environment."""
- env.AppendUnique(FORTRANSUFFIXES = F95Suffixes + F95PPSuffixes)
-
- static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
-
- for suffix in F95Suffixes:
- static_obj.add_action(suffix, F95Action)
- shared_obj.add_action(suffix, ShF95Action)
- static_obj.add_emitter(suffix, fortran.FortranEmitter)
- shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
-
- for suffix in F95PPSuffixes:
- static_obj.add_action(suffix, F95PPAction)
- shared_obj.add_action(suffix, ShF95PPAction)
- static_obj.add_emitter(suffix, fortran.FortranEmitter)
- shared_obj.add_emitter(suffix, fortran.ShFortranEmitter)
-
- env['_F95G'] = F95Generator
- env['_F95FLAGSG'] = F95FlagsGenerator
- env['_F95COMG'] = F95CommandGenerator
- env['_F95COMSTRG'] = F95CommandStrGenerator
- env['_F95PPCOMG'] = F95PPCommandGenerator
- env['_F95PPCOMSTRG'] = F95PPCommandStrGenerator
-
- env['_SHF95G'] = ShF95Generator
- env['_SHF95FLAGSG'] = ShF95FlagsGenerator
- env['_SHF95COMG'] = ShF95CommandGenerator
- env['_SHF95COMSTRG'] = ShF95CommandStrGenerator
- env['_SHF95PPCOMG'] = ShF95PPCommandGenerator
- env['_SHF95PPCOMSTRG'] = ShF95PPCommandStrGenerator
-
- env['_F95INCFLAGS'] = '$( ${_concat(INCPREFIX, F95PATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
-
- env['_F95COMD'] = '$_F95G -o $TARGET -c $_F95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG $SOURCES'
- env['_F95PPCOMD'] = '$_F95G -o $TARGET -c $_F95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG $SOURCES'
- env['_SHF95COMD'] = '$_SHF95G -o $TARGET -c $_SHF95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG $SOURCES'
- env['_SHF95PPCOMD'] = '$_SHF95G -o $TARGET -c $_SHF95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG $SOURCES'
-
def generate(env):
- fortran.add_to_env(env)
-
- import f77
- f77.add_to_env(env)
+ add_all_to_env(env)
+ add_f95_to_env(env)
- import f90
- f90.add_to_env(env)
+ fcomp = env.Detect(compilers) or 'f95'
+ env['F95'] = fcomp
+ env['SHF95'] = fcomp
- add_to_env(env)
+ env['FORTRAN'] = fcomp
+ env['SHFORTRAN'] = fcomp
- env['_FORTRAND'] = env.Detect(compilers) or 'f95'
def exists(env):
return env.Detect(compilers)
</summary>
</cvar>
+<cvar name="F95FILESUFFIXES">
+<summary>
+The list of file extensions for which the F95 dialect will be used. By
+default, this is ['.f95']
+</summary>
+</cvar>
+
+<cvar name="F95PPFILESUFFIXES">
+<summary>
+The list of file extensions for which the compilation + preprocessor pass for
+F95 dialect will be used. By default, this is empty
+</summary>
+</cvar>
+
<cvar name="F95FLAGS">
<summary>
General user-specified options that are passed to the Fortran 95 compiler.
import SCons.Scanner.Fortran
import SCons.Tool
import SCons.Util
+from SCons.Tool.FortranCommon import add_all_to_env, add_fortran_to_env
compilers = ['f95', 'f90', 'f77']
-#
-# Not yet sure how to deal with fortran pre-processor functions.
-# Different compilers do this differently in modern fortran. Some still
-# rely on the c pre-processor, some (like cvf, ivf) have their own
-# pre-processor technology and use intermediary suffixes (.i90)
-#
-FortranSuffixes = [".f", ".for", ".ftn", ]
-FortranPPSuffixes = ['.fpp', '.FPP']
-upper_case = [".F", ".FOR", ".FTN"]
-if SCons.Util.case_sensitive_suffixes('.f', '.F'):
- FortranPPSuffixes.extend(upper_case)
-else:
- FortranSuffixes.extend(upper_case)
-
-#
-FortranScan = SCons.Scanner.Fortran.FortranScan("FORTRANPATH")
-
-for suffix in FortranSuffixes + FortranPPSuffixes:
- SCons.Tool.SourceFileScanner.add_scanner(suffix, FortranScan)
-del suffix
-
-#
-def _fortranEmitter(target, source, env):
- node = source[0].rfile()
- if not node.exists() and not node.is_derived():
- print "Could not locate " + str(node.name)
- return ([], [])
- mod_regex = """(?i)^\s*MODULE\s+(?!PROCEDURE)(\w+)"""
- cre = re.compile(mod_regex,re.M)
- # Retrieve all USE'd module names
- modules = cre.findall(node.get_contents())
- # Remove unique items from the list
- modules = SCons.Util.unique(modules)
- # Convert module name to a .mod filename
- suffix = env.subst('$FORTRANMODSUFFIX', target=target, source=source)
- moddir = env.subst('$FORTRANMODDIR', target=target, source=source)
- modules = map(lambda x, s=suffix: string.lower(x) + s, modules)
- for m in modules:
- target.append(env.fs.File(m, moddir))
- return (target, source)
-
-def FortranEmitter(target, source, env):
- target, source = _fortranEmitter(target, source, env)
- return SCons.Defaults.StaticObjectEmitter(target, source, env)
-
-def ShFortranEmitter(target, source, env):
- target, source = _fortranEmitter(target, source, env)
- return SCons.Defaults.SharedObjectEmitter(target, source, env)
-
-class VariableListGenerator:
- def __init__(self, *variablelist):
- self.variablelist = variablelist
- def __call__(self, env, target, source, for_signature=0):
- for v in self.variablelist:
- try: return env[v]
- except KeyError: pass
- return ''
-
-#
-FortranGenerator = VariableListGenerator('FORTRAN', 'F77', '_FORTRAND')
-FortranFlagsGenerator = VariableListGenerator('FORTRANFLAGS', 'F77FLAGS')
-FortranCommandGenerator = VariableListGenerator('FORTRANCOM', 'F77COM', '_FORTRANCOMD')
-FortranCommandStrGenerator = VariableListGenerator('FORTRANCOMSTR', 'F77COMSTR', '_FORTRANCOMSTRD')
-FortranPPCommandGenerator = VariableListGenerator('FORTRANPPCOM', 'F77PPCOM', '_FORTRANPPCOMD')
-FortranPPCommandStrGenerator = VariableListGenerator('FORTRANPPCOMSTR', 'F77PPCOMSTR', '_FORTRANPPCOMSTRD')
-ShFortranGenerator = VariableListGenerator('SHFORTRAN', 'SHF77', 'FORTRAN', 'F77', '_FORTRAND')
-ShFortranFlagsGenerator = VariableListGenerator('SHFORTRANFLAGS', 'SHF77FLAGS')
-ShFortranCommandGenerator = VariableListGenerator('SHFORTRANCOM', 'SHF77COM', '_SHFORTRANCOMD')
-ShFortranCommandStrGenerator = VariableListGenerator('SHFORTRANCOMSTR', 'SHF77COMSTR', '_SHFORTRANCOMSTRD')
-ShFortranPPCommandGenerator = VariableListGenerator('SHFORTRANPPCOM', 'SHF77PPCOM', '_SHFORTRANPPCOMD')
-ShFortranPPCommandStrGenerator = VariableListGenerator('SHFORTRANPPCOMSTR', 'SHF77PPCOMSTR', '_SHFORTRANPPCOMSTRD')
-
-#
-FortranAction = SCons.Action.Action('$_FORTRANCOMG ', '$_FORTRANCOMSTRG')
-FortranPPAction = SCons.Action.Action('$_FORTRANPPCOMG ', '$_FORTRANPPCOMSTRG')
-ShFortranAction = SCons.Action.Action('$_SHFORTRANCOMG ', '$_SHFORTRANCOMSTRG')
-ShFortranPPAction = SCons.Action.Action('$_SHFORTRANPPCOMG ', '$_SHFORTRANPPCOMSTRG')
-
-def add_to_env(env):
- """Add Builders and construction variables for Fortran to an Environment."""
-
- env['_FORTRANG'] = FortranGenerator
- env['_FORTRANFLAGSG'] = FortranFlagsGenerator
- env['_FORTRANCOMG'] = FortranCommandGenerator
- env['_FORTRANCOMSTRG'] = FortranCommandStrGenerator
- env['_FORTRANPPCOMG'] = FortranPPCommandGenerator
- env['_FORTRANPPCOMSTRG'] = FortranPPCommandStrGenerator
-
- env['_SHFORTRANG'] = ShFortranGenerator
- env['_SHFORTRANFLAGSG'] = ShFortranFlagsGenerator
- env['_SHFORTRANCOMG'] = ShFortranCommandGenerator
- env['_SHFORTRANCOMSTRG'] = ShFortranCommandStrGenerator
- env['_SHFORTRANPPCOMG'] = ShFortranPPCommandGenerator
- env['_SHFORTRANPPCOMSTRG'] = ShFortranPPCommandStrGenerator
-
- env['_FORTRANINCFLAGS'] = '$( ${_concat(INCPREFIX, FORTRANPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
-
- env['FORTRANMODPREFIX'] = '' # like $LIBPREFIX
- env['FORTRANMODSUFFIX'] = '.mod' # like $LIBSUFFIX
-
- env['FORTRANMODDIR'] = '' # where the compiler should place .mod files
- env['FORTRANMODDIRPREFIX'] = '' # some prefix to $FORTRANMODDIR - similar to $INCPREFIX
- env['FORTRANMODDIRSUFFIX'] = '' # some suffix to $FORTRANMODDIR - similar to $INCSUFFIX
- env['_FORTRANMODFLAG'] = '$( ${_concat(FORTRANMODDIRPREFIX, FORTRANMODDIR, FORTRANMODDIRSUFFIX, __env__, RDirs)} $)'
-
- env.AppendUnique(FORTRANSUFFIXES = FortranSuffixes + FortranPPSuffixes)
-
- static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
-
- for suffix in FortranSuffixes:
- static_obj.add_action(suffix, FortranAction)
- shared_obj.add_action(suffix, ShFortranAction)
- static_obj.add_emitter(suffix, FortranEmitter)
- shared_obj.add_emitter(suffix, ShFortranEmitter)
-
- for suffix in FortranPPSuffixes:
- static_obj.add_action(suffix, FortranPPAction)
- shared_obj.add_action(suffix, ShFortranPPAction)
- static_obj.add_emitter(suffix, FortranEmitter)
- shared_obj.add_emitter(suffix, ShFortranEmitter)
-
- env['_FORTRANCOMD'] = '$_FORTRANG -o $TARGET -c $_FORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG $SOURCES'
- env['_FORTRANPPCOMD'] = '$_FORTRANG -o $TARGET -c $_FORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG $SOURCES'
- env['_SHFORTRANCOMD'] = '$_SHFORTRANG -o $TARGET -c $_SHFORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG $SOURCES'
- env['_SHFORTRANPPCOMD'] = '$_SHFORTRANG -o $TARGET -c $_SHFORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG $SOURCES'
-
def generate(env):
- import f77
- import f90
- import f95
- f77.add_to_env(env)
- f90.add_to_env(env)
- f95.add_to_env(env)
-
- add_to_env(env)
+ add_all_to_env(env)
+ add_fortran_to_env(env)
- env['_FORTRAND'] = env.Detect(compilers) or 'f77'
+ fc = env.Detect(compilers) or 'f77'
+ env['SHFORTRAN'] = fc
+ env['FORTRAN'] = fc
def exists(env):
return env.Detect(compilers)
</summary>
</cvar>
+<cvar name="FORTRANFILESUFFIXES">
+<summary>
+The list of file extensions for which the FORTRAN dialect will be used. By
+default, this is ['.f', '.for', '.ftn']
+</summary>
+</cvar>
+
+<cvar name="FORTRANPPFILESUFFIXES">
+<summary>
+The list of file extensions for which the compilation + preprocessor pass for
+FORTRAN dialect will be used. By default, this is ['.fpp', '.FPP']
+</summary>
+</cvar>
+
<cvar name="FORTRANFLAGS">
<summary>
General user-specified options that are passed to the Fortran compiler.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import f77
+import SCons.Util
+from SCons.Tool.FortranCommon import add_all_to_env, add_f77_to_env
compilers = ['g77', 'f77']
def generate(env):
"""Add Builders and construction variables for g77 to an Environment."""
- f77.generate(env)
+ add_all_to_env(env)
+ add_f77_to_env(env)
- env['_FORTRAND'] = env.Detect(compilers) or 'g77'
+ fcomp = env.Detect(compilers) or 'g77'
+ if env['PLATFORM'] in ['cygwin', 'win32']:
+ env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS')
+ env['SHF77FLAGS'] = SCons.Util.CLVar('$F77FLAGS')
+ else:
+ env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$SHFORTRANFLAGS -fPIC')
+ env['SHF77FLAGS'] = SCons.Util.CLVar('$SHF77FLAGS -fPIC')
+
+ env['FORTRAN'] = fcomp
+ env['SHFORTRAN'] = '$FORTRAN'
+
+ env['F77'] = fcomp
+ env['SHF77'] = '$F77'
+
+ env['INCFORTRANPREFIX'] = "-I"
+ env['INCFORTRANSUFFIX'] = ""
+
+ env['INCF77PREFIX'] = "-I"
+ env['INCF77SUFFIX'] = ""
def exists(env):
return env.Detect(compilers)
Environment."""
fortran.generate(env)
- # which one is the good one ? ifort uses _FORTRAND, ifl FORTRAN,
- # aixf77 F77 ...
- #env['_FORTRAND'] = 'gfortran'
- env['FORTRAN'] = 'gfortran'
-
- # XXX does this need to be set too ?
- #env['SHFORTRAN'] = 'gfortran'
-
- if env['PLATFORM'] in ['cygwin', 'win32']:
- env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS')
- else:
- env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS -fPIC')
-
- # XXX; Link problems: we need to add -lgfortran somewhere...
+ for dialect in ['F77', 'F90', 'FORTRAN', 'F95']:
+ env['%s' % dialect] = 'gfortran'
+ env['SH%s' % dialect] = '$%s' % dialect
+ if env['PLATFORM'] in ['cygwin', 'win32']:
+ env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS' % dialect)
+ else:
+ env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS -fPIC' % dialect)
+
+ env['INC%sPREFIX' % dialect] = "-I"
+ env['INC%sSUFFIX' % dialect] = ""
def exists(env):
return env.Detect('gfortran')
</summary>
<sets>
FORTRAN
+F77
+F90
+F95
+SHFORTRAN
+SHF77
+SHF90
+SHF95
SHFORTRANFLAGS
+SHF77FLAGS
+SHF90FLAGS
+SHF95FLAGS
</sets>
</tool>
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.Defaults
-
-import fortran
+from SCons.Scanner.Fortran import FortranScan
+from FortranCommon import add_all_to_env
def generate(env):
"""Add Builders and construction variables for ifl to an Environment."""
- SCons.Tool.SourceFileScanner.add_scanner('.i90', fortran.FortranScan)
- fortran.FortranSuffixes.extend(['.i90'])
- fortran.generate(env)
+ fscan = FortranScan("FORTRANPATH")
+ SCons.Tool.SourceFileScanner.add_scanner('.i', fscan)
+ SCons.Tool.SourceFileScanner.add_scanner('.i90', fscan)
+
+ if not env.has_key('FORTRANFILESUFFIXES'):
+ env['FORTRANFILESUFFIXES'] = ['.i']
+ else:
+ env['FORTRANFILESUFFIXES'].append('.i')
+
+ if not env.has_key('F90FILESUFFIXES'):
+ env['F90FILESUFFIXES'] = ['.i90']
+ else:
+ env['F90FILESUFFIXES'].append('.i90')
+
+ add_all_to_env(env)
env['FORTRAN'] = 'ifl'
+ env['SHFORTRAN'] = '$FORTRAN'
env['FORTRANCOM'] = '$FORTRAN $FORTRANFLAGS $_FORTRANINCFLAGS /c $SOURCES /Fo$TARGET'
env['FORTRANPPCOM'] = '$FORTRAN $FORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS /c $SOURCES /Fo$TARGET'
env['SHFORTRANCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $_FORTRANINCFLAGS /c $SOURCES /Fo$TARGET'
import string
import SCons.Defaults
-
-import fortran
+from SCons.Scanner.Fortran import FortranScan
+from FortranCommon import add_all_to_env
def generate(env):
"""Add Builders and construction variables for ifort to an Environment."""
# ifort supports Fortran 90 and Fortran 95
# Additionally, ifort recognizes more file extensions.
- SCons.Tool.SourceFileScanner.add_scanner('.i', fortran.FortranScan)
- SCons.Tool.SourceFileScanner.add_scanner('.i90', fortran.FortranScan)
- fortran.FortranSuffixes.extend(['.i', '.i90'])
- fortran.generate(env)
+ fscan = FortranScan("FORTRANPATH")
+ SCons.Tool.SourceFileScanner.add_scanner('.i', fscan)
+ SCons.Tool.SourceFileScanner.add_scanner('.i90', fscan)
+
+ if not env.has_key('FORTRANFILESUFFIXES'):
+ env['FORTRANFILESUFFIXES'] = ['.i']
+ else:
+ env['FORTRANFILESUFFIXES'].append('.i')
+
+ if not env.has_key('F90FILESUFFIXES'):
+ env['F90FILESUFFIXES'] = ['.i90']
+ else:
+ env['F90FILESUFFIXES'].append('.i90')
- env['_FORTRAND'] = 'ifort'
+ add_all_to_env(env)
- # If files are compiled into objects, the Intel Fortran Compiler must use
- # ld to link shared libraries.
- env['SHLINK'] = 'ld'
+ fc = 'ifort'
- # Additionally, no symbols can be defined in an archive file; to use
- # Intel Fortran to create shared libraries, all external symbols must
- # be in shared libraries.
- env['SHLINKFLAGS'] = '-shared -no_archive'
+ for dialect in ['F77', 'F90', 'FORTRAN', 'F95']:
+ env['%s' % dialect] = fc
+ env['SH%s' % dialect] = '$%s' % dialect
+ env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS -fPIC' % dialect)
- #
if env['PLATFORM'] == 'win32':
# On Windows, the ifort compiler specifies the object on the
# command line with -object:, not -o. Massage the necessary
# command-line construction variables.
- for var in ['_FORTRANCOMD', '_FORTRANPPCOMD',
- '_SHFORTRANCOMD', '_SHFORTRANPPCOMD']:
- env[var] = string.replace(env[var], '-o $TARGET', '-object:$TARGET')
+ for dialect in ['F77', 'F90', 'FORTRAN', 'F95']:
+ for var in ['%sCOM' % dialect, '%sPPCOM' % dialect,
+ 'SH%sCOM' % dialect, 'SH%sPPCOM' % dialect]:
+ env[var] = string.replace(env[var], '-o $TARGET', '-object:$TARGET')
def exists(env):
return env.Detect('ifort')
of the Intel Fortran compiler for Linux.
</summary>
<sets>
-SHLINK
-SHLINKFLAGS
+FORTRAN
+F77
+F90
+F95
+SHFORTRAN
+SHF77
+SHF90
+SHF95
+SHFORTRANFLAGS
+SHF77FLAGS
+SHF90FLAGS
+SHF95FLAGS
</sets>
</tool>
import SCons.Defaults
import SCons.Tool
import SCons.Util
+import SCons.Errors
+
+from SCons.Tool.FortranCommon import isfortran
cplusplus = __import__('c++', globals(), locals(), [])
def smart_link(source, target, env, for_signature):
- if cplusplus.iscplusplus(source):
+ has_cplusplus = cplusplus.iscplusplus(source)
+ has_fortran = isfortran(env, source)
+ if has_cplusplus and has_fortran:
+ raise SCons.Errors.InternalError(
+ "Sorry, scons cannot yet link c++ and fortran code together.")
+ elif has_fortran:
+ return '$FORTRAN'
+ elif has_cplusplus:
return '$CXX'
return '$CC'
--- /dev/null
+"""SCons.Tool.sunf77
+
+Tool-specific initialization for sunf77, the Sun Studio F77 compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import SCons.Util
+
+from FortranCommon import add_all_to_env
+
+compilers = ['sunf77', 'f77']
+
+def generate(env):
+ """Add Builders and construction variables for sunf77 to an Environment."""
+ add_all_to_env(env)
+
+ fcomp = env.Detect(compilers) or 'f77'
+ env['FORTRAN'] = fcomp
+ env['F77'] = fcomp
+
+ env['SHFORTRAN'] = '$FORTRAN'
+ env['SHF77'] = '$F77'
+
+ env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS -KPIC')
+ env['SHF77FLAGS'] = SCons.Util.CLVar('$F77FLAGS -KPIC')
+
+def exists(env):
+ return env.Detect(compilers)
--- /dev/null
+<!--
+__COPYRIGHT__
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+<tool name="sunf77">
+<summary>
+Set construction variables for the Sun &f77; Fortran compiler.
+</summary>
+<sets>
+FORTRAN
+F77
+SHFORTRAN
+SHF77
+SHFORTRANFLAGS
+SHF77FLAGS
+</sets>
+</tool>
--- /dev/null
+"""SCons.Tool.sunf90
+
+Tool-specific initialization for sunf90, the Sun Studio F90 compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import SCons.Util
+
+from FortranCommon import add_all_to_env
+
+compilers = ['sunf90', 'f90']
+
+def generate(env):
+ """Add Builders and construction variables for sun f90 compiler to an
+ Environment."""
+ add_all_to_env(env)
+
+ fcomp = env.Detect(compilers) or 'f90'
+ env['FORTRAN'] = fcomp
+ env['F90'] = fcomp
+
+ env['SHFORTRAN'] = '$FORTRAN'
+ env['SHF90'] = '$F90'
+
+ env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS -KPIC')
+ env['SHF90FLAGS'] = SCons.Util.CLVar('$F90FLAGS -KPIC')
+
+def exists(env):
+ return env.Detect(compilers)
--- /dev/null
+<!--
+__COPYRIGHT__
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+<tool name="sunf90">
+<summary>
+Set construction variables for the Sun &f90; Fortran compiler.
+</summary>
+<sets>
+FORTRAN
+F90
+SHFORTRAN
+SHF90
+SHFORTRANFLAGS
+SHF90FLAGS
+</sets>
+</tool>
--- /dev/null
+"""SCons.Tool.sunf95
+
+Tool-specific initialization for sunf95, the Sun Studio F95 compiler.
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import SCons.Util
+
+from FortranCommon import add_all_to_env
+
+compilers = ['sunf95', 'f95']
+
+def generate(env):
+ """Add Builders and construction variables for sunf95 to an
+ Environment."""
+ add_all_to_env(env)
+
+ fcomp = env.Detect(compilers) or 'f95'
+ env['FORTRAN'] = fcomp
+ env['F95'] = fcomp
+
+ env['SHFORTRAN'] = '$FORTRAN'
+ env['SHF95'] = '$F95'
+
+ env['SHFORTRANFLAGS'] = SCons.Util.CLVar('$FORTRANFLAGS -KPIC')
+ env['SHF95FLAGS'] = SCons.Util.CLVar('$F95FLAGS -KPIC')
+
+def exists(env):
+ return env.Detect(compilers)
--- /dev/null
+<!--
+__COPYRIGHT__
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+<tool name="sunf95">
+<summary>
+Set construction variables for the Sun &f95; Fortran compiler.
+</summary>
+<sets>
+FORTRAN
+F95
+SHFORTRAN
+SHF95
+SHFORTRANFLAGS
+SHF95FLAGS
+</sets>
+</tool>
scons_lib_dir = os.path.join(cwd, 'build', 'scons')
MANIFEST = os.path.join(scons_lib_dir, 'MANIFEST')
+# We expect precisely this many uncaught KeyboardInterrupt exceptions
+# from the files in the following dictionary.
+
+expected_uncaught = {
+ 'engine/SCons/Job.py' : 5,
+ 'engine/SCons/Script/Main.py' : 1,
+ 'engine/SCons/Taskmaster.py' : 3,
+}
+
try:
fp = open(MANIFEST)
except IOError:
line_num = 1 + string.count(contents[:match.start()], '\n')
indent_list.append( (line_num, match.group('try_or_except') ) )
try_except_lines[match.group('indent')] = indent_list
+ uncaught_this_file = []
for indent in try_except_lines.keys():
exc_keyboardint_seen = 0
exc_all_seen = 0
m2 = exceptall_pat.match(statement)
if string.find(statement, indent + 'try') == 0:
if exc_all_seen and not exc_keyboardint_seen:
- uncaughtKeyboardInterrupt = 1
- print "File %s:%d: Uncaught KeyboardInterrupt!" % (f,line)
+ uncaught_this_file.append(line)
exc_keyboardint_seen = 0
exc_all_seen = 0
line = l
else:
pass
#print "Warning: unknown statement %s" % statement
+ expected_num = expected_uncaught.get(f, 0)
+ if expected_num != len(uncaught_this_file):
+ uncaughtKeyboardInterrupt = 1
+ msg = "%s: expected %d uncaught interrupts, got %d:"
+ print msg % (f, expected_num, len(uncaught_this_file))
+ for line in uncaught_this_file:
+ print " File %s:%d: Uncaught KeyboardInterrupt!" % (f,line)
test.fail_test(uncaughtKeyboardInterrupt)
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import getopt
env.Program(target = 'test08', source = 'test08.FPP')
env.Program(target = 'test09', source = 'test09.f77')
env.Program(target = 'test10', source = 'test10.F77')
-env.Program(target = 'test11', source = 'test11.f90')
-env.Program(target = 'test12', source = 'test12.F90')
-env.Program(target = 'test13', source = 'test13.f95')
-env.Program(target = 'test14', source = 'test14.F95')
-env2 = Environment(LINK = r'%(_python_)s mylink.py',
- LINKFLAGS = [],
- F77 = r'%(_python_)s myfortran.py g77')
-env2.Program(target = 'test21', source = 'test21.f')
-env2.Program(target = 'test22', source = 'test22.F')
-env2.Program(target = 'test23', source = 'test23.for')
-env2.Program(target = 'test24', source = 'test24.FOR')
-env2.Program(target = 'test25', source = 'test25.ftn')
-env2.Program(target = 'test26', source = 'test26.FTN')
-env2.Program(target = 'test27', source = 'test27.fpp')
-env2.Program(target = 'test28', source = 'test28.FPP')
-env2.Program(target = 'test29', source = 'test29.f77')
-env2.Program(target = 'test30', source = 'test30.F77')
""" % locals())
test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
test.write('test09.f77', "This is a .f77 file.\n#link\n#g77\n")
test.write('test10.F77', "This is a .F77 file.\n#link\n#g77\n")
-test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#link\n#fortran\n")
-test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#link\n#fortran\n")
-
-test.write('test21.f', "This is a .f file.\n#link\n#g77\n")
-test.write('test22.F', "This is a .F file.\n#link\n#g77\n")
-test.write('test23.for', "This is a .for file.\n#link\n#g77\n")
-test.write('test24.FOR', "This is a .FOR file.\n#link\n#g77\n")
-test.write('test25.ftn', "This is a .ftn file.\n#link\n#g77\n")
-test.write('test26.FTN', "This is a .FTN file.\n#link\n#g77\n")
-test.write('test27.fpp', "This is a .fpp file.\n#link\n#g77\n")
-test.write('test28.FPP', "This is a .FPP file.\n#link\n#g77\n")
-test.write('test29.f77', "This is a .f77 file.\n#link\n#g77\n")
-test.write('test30.F77', "This is a .F77 file.\n#link\n#g77\n")
test.run(arguments = '.', stderr = None)
test.must_match('test08' + _exe, "This is a .FPP file.\n")
test.must_match('test09' + _exe, "This is a .f77 file.\n")
test.must_match('test10' + _exe, "This is a .F77 file.\n")
-test.must_match('test11' + _exe, "This is a .f90 file.\n")
-test.must_match('test12' + _exe, "This is a .F90 file.\n")
-test.must_match('test13' + _exe, "This is a .f95 file.\n")
-test.must_match('test14' + _exe, "This is a .F95 file.\n")
-
-test.must_match('test21' + _exe, "This is a .f file.\n")
-test.must_match('test22' + _exe, "This is a .F file.\n")
-test.must_match('test23' + _exe, "This is a .for file.\n")
-test.must_match('test24' + _exe, "This is a .FOR file.\n")
-test.must_match('test25' + _exe, "This is a .ftn file.\n")
-test.must_match('test26' + _exe, "This is a .FTN file.\n")
-test.must_match('test27' + _exe, "This is a .fpp file.\n")
-test.must_match('test28' + _exe, "This is a .FPP file.\n")
-test.must_match('test29' + _exe, "This is a .f77 file.\n")
-test.must_match('test30' + _exe, "This is a .F77 file.\n")
-
-
-g77 = test.detect('F77', 'g77')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f77'
+f77 = test.detect_tool(fc)
-if g77:
+if f77:
test.write("wrapper.py",
"""import os
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = ['.f'])
f77 = foo.Dictionary('F77')
bar = foo.Clone(F77 = r'%(_python_)s wrapper.py ' + f77)
foo.Program(target = 'foo', source = 'foo.f')
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar' + _exe)
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar' + _exe, stderr = None)
+ else:
+ test.run(arguments = 'bar' + _exe)
test.run(program = test.workpath('bar'), stdout = " bar.f\n")
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import sys
env.Program(target = 'test08', source = 'test08.FPP')
env.Program(target = 'test09', source = 'test09.f77')
env.Program(target = 'test10', source = 'test10.F77')
-env.Program(target = 'test11', source = 'test11.f90')
-env.Program(target = 'test12', source = 'test12.F90')
-env.Program(target = 'test13', source = 'test13.f95')
-env.Program(target = 'test14', source = 'test14.F95')
-env2 = Environment(LINK = r'%(_python_)s mylink.py',
- LINKFLAGS = [],
- F77COM = r'%(_python_)s myfortran.py f77 $TARGET $SOURCES',
- F77PPCOM = r'%(_python_)s myfortran.py f77pp $TARGET $SOURCES')
-env2.Program(target = 'test21', source = 'test21.f')
-env2.Program(target = 'test22', source = 'test22.F')
-env2.Program(target = 'test23', source = 'test23.for')
-env2.Program(target = 'test24', source = 'test24.FOR')
-env2.Program(target = 'test25', source = 'test25.ftn')
-env2.Program(target = 'test26', source = 'test26.FTN')
-env2.Program(target = 'test27', source = 'test27.fpp')
-env2.Program(target = 'test28', source = 'test28.FPP')
-env2.Program(target = 'test29', source = 'test29.f77')
-env2.Program(target = 'test30', source = 'test30.F77')
""" % locals())
test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n")
test.write('test09.f77', "This is a .f77 file.\n#link\n#f77\n")
test.write('test10.F77', "This is a .F77 file.\n#link\n#f77pp\n")
-test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#link\n#fortranpp\n")
-test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#link\n#fortranpp\n")
-
-test.write('test21.f', "This is a .f file.\n#link\n#f77\n")
-test.write('test22.F', "This is a .F file.\n#link\n#f77pp\n")
-test.write('test23.for', "This is a .for file.\n#link\n#f77\n")
-test.write('test24.FOR', "This is a .FOR file.\n#link\n#f77pp\n")
-test.write('test25.ftn', "This is a .ftn file.\n#link\n#f77\n")
-test.write('test26.FTN', "This is a .FTN file.\n#link\n#f77pp\n")
-test.write('test27.fpp', "This is a .fpp file.\n#link\n#f77pp\n")
-test.write('test28.FPP', "This is a .FPP file.\n#link\n#f77pp\n")
-test.write('test29.f77', "This is a .f77 file.\n#link\n#f77\n")
-test.write('test30.F77', "This is a .F77 file.\n#link\n#f77pp\n")
test.run(arguments = '.', stderr = None)
test.must_match('test08' + _exe, "This is a .FPP file.\n")
test.must_match('test09' + _exe, "This is a .f77 file.\n")
test.must_match('test10' + _exe, "This is a .F77 file.\n")
-test.must_match('test11' + _exe, "This is a .f90 file.\n")
-test.must_match('test12' + _exe, "This is a .F90 file.\n")
-test.must_match('test13' + _exe, "This is a .f95 file.\n")
-test.must_match('test14' + _exe, "This is a .F95 file.\n")
-
-test.must_match('test21' + _exe, "This is a .f file.\n")
-test.must_match('test22' + _exe, "This is a .F file.\n")
-test.must_match('test23' + _exe, "This is a .for file.\n")
-test.must_match('test24' + _exe, "This is a .FOR file.\n")
-test.must_match('test25' + _exe, "This is a .ftn file.\n")
-test.must_match('test26' + _exe, "This is a .FTN file.\n")
-test.must_match('test27' + _exe, "This is a .fpp file.\n")
-test.must_match('test28' + _exe, "This is a .FPP file.\n")
-test.must_match('test29' + _exe, "This is a .f77 file.\n")
-test.must_match('test30' + _exe, "This is a .F77 file.\n")
test.pass_test()
F77PPCOM = r'%(_python_)s myfc.py f77pp $TARGET $SOURCES',
F77PPCOMSTR = 'Building f77pp $TARGET from $SOURCES',
OBJSUFFIX='.obj')
-env.Object(source = 'test01.f')
-env.Object(source = 'test02.F')
-env.Object(source = 'test03.for')
-env.Object(source = 'test04.FOR')
-env.Object(source = 'test05.ftn')
-env.Object(source = 'test06.FTN')
-env.Object(source = 'test07.fpp')
-env.Object(source = 'test08.FPP')
env.Object(source = 'test09.f77')
env.Object(source = 'test10.F77')
""" % locals())
-test.write('test01.f', "A .f file.\n#f77\n")
-test.write('test02.F', "A .F file.\n#%s\n" % f77pp)
-test.write('test03.for', "A .for file.\n#f77\n")
-test.write('test04.FOR', "A .FOR file.\n#%s\n" % f77pp)
-test.write('test05.ftn', "A .ftn file.\n#f77\n")
-test.write('test06.FTN', "A .FTN file.\n#%s\n" % f77pp)
-test.write('test07.fpp', "A .fpp file.\n#f77pp\n")
-test.write('test08.FPP', "A .FPP file.\n#f77pp\n")
test.write('test09.f77', "A .f77 file.\n#f77\n")
test.write('test10.F77', "A .F77 file.\n#%s\n" % f77pp)
test.run(stdout = test.wrap_stdout("""\
-Building f77 test01.obj from test01.f
-Building %(f77pp)s test02.obj from test02.F
-Building f77 test03.obj from test03.for
-Building %(f77pp)s test04.obj from test04.FOR
-Building f77 test05.obj from test05.ftn
-Building %(f77pp)s test06.obj from test06.FTN
-Building f77pp test07.obj from test07.fpp
-Building f77pp test08.obj from test08.FPP
Building f77 test09.obj from test09.f77
Building %(f77pp)s test10.obj from test10.F77
""" % locals()))
-test.must_match('test01.obj', "A .f file.\n")
-test.must_match('test02.obj', "A .F file.\n")
-test.must_match('test03.obj', "A .for file.\n")
-test.must_match('test04.obj', "A .FOR file.\n")
-test.must_match('test05.obj', "A .ftn file.\n")
-test.must_match('test06.obj', "A .FTN file.\n")
-test.must_match('test07.obj', "A .fpp file.\n")
-test.must_match('test08.obj', "A .FPP file.\n")
test.must_match('test09.obj', "A .f77 file.\n")
test.must_match('test10.obj', "A .F77 file.\n")
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+from common import write_fake_link
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+write_fake_link(test)
+
+test.write('myfortran.py', r"""
+import getopt
+import sys
+comment = '#' + sys.argv[1]
+opts, args = getopt.getopt(sys.argv[2:], 'co:')
+for opt, arg in opts:
+ if opt == '-o': out = arg
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:len(comment)] != comment:
+ outfile.write(l)
+sys.exit(0)
+""")
+
+# Test default file suffix: .f77/.F77 for F77
+test.write('SConstruct', """
+env = Environment(LINK = r'%(_python_)s mylink.py',
+ LINKFLAGS = [],
+ F77 = r'%(_python_)s myfortran.py g77',
+ FORTRAN = r'%(_python_)s myfortran.py fortran')
+env.Program(target = 'test01', source = 'test01.f')
+env.Program(target = 'test02', source = 'test02.F')
+env.Program(target = 'test03', source = 'test03.for')
+env.Program(target = 'test04', source = 'test04.FOR')
+env.Program(target = 'test05', source = 'test05.ftn')
+env.Program(target = 'test06', source = 'test06.FTN')
+env.Program(target = 'test07', source = 'test07.fpp')
+env.Program(target = 'test08', source = 'test08.FPP')
+env.Program(target = 'test09', source = 'test09.f77')
+env.Program(target = 'test10', source = 'test10.F77')
+""" % locals())
+
+test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
+test.write('test02.F', "This is a .F file.\n#link\n#fortran\n")
+test.write('test03.for', "This is a .for file.\n#link\n#fortran\n")
+test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n")
+test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n")
+test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
+test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
+test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
+test.write('test09.f77', "This is a .f77 file.\n#link\n#g77\n")
+test.write('test10.F77', "This is a .F77 file.\n#link\n#g77\n")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test01' + _exe, "This is a .f file.\n")
+test.must_match('test02' + _exe, "This is a .F file.\n")
+test.must_match('test03' + _exe, "This is a .for file.\n")
+test.must_match('test04' + _exe, "This is a .FOR file.\n")
+test.must_match('test05' + _exe, "This is a .ftn file.\n")
+test.must_match('test06' + _exe, "This is a .FTN file.\n")
+test.must_match('test07' + _exe, "This is a .fpp file.\n")
+test.must_match('test08' + _exe, "This is a .FPP file.\n")
+test.must_match('test09' + _exe, "This is a .f77 file.\n")
+test.must_match('test10' + _exe, "This is a .F77 file.\n")
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+from common import write_fake_link
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+write_fake_link(test)
+
+test.write('myfortran.py', r"""
+import getopt
+import sys
+comment = '#' + sys.argv[1]
+opts, args = getopt.getopt(sys.argv[2:], 'co:')
+for opt, arg in opts:
+ if opt == '-o': out = arg
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:len(comment)] != comment:
+ outfile.write(l)
+sys.exit(0)
+""")
+
+# Test non-default file suffix: .f/.F for F77
+test.write('SConstruct', """
+env = Environment(LINK = r'%(_python_)s mylink.py',
+ LINKFLAGS = [],
+ F77 = r'%(_python_)s myfortran.py g77',
+ F95 = r'%(_python_)s myfortran.py f95',
+ F77FILESUFFIXES = ['.f', '.F'],
+ tools = ['default', 'f77'])
+env.Program(target = 'test01', source = 'test01.f')
+env.Program(target = 'test02', source = 'test02.F')
+env.Program(target = 'test05', source = 'test05.f95')
+env.Program(target = 'test06', source = 'test06.F95')
+""" % locals())
+
+test.write('test01.f', "This is a .f file.\n#link\n#g77\n")
+test.write('test02.F', "This is a .F file.\n#link\n#g77\n")
+test.write('test05.f95', "This is a .f95 file.\n#link\n#f95\n")
+test.write('test06.F95', "This is a .F95 file.\n#link\n#f95\n")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test01' + _exe, "This is a .f file.\n")
+test.must_match('test02' + _exe, "This is a .F file.\n")
+test.must_match('test05' + _exe, "This is a .f95 file.\n")
+test.must_match('test06' + _exe, "This is a .F95 file.\n")
+
+test.pass_test()
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
test = TestSCons.TestSCons()
_exe = TestSCons._exe
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myg77.py', r"""
import getopt
LINKFLAGS = [],
F77 = r'%(_python_)s myg77.py',
F77FLAGS = '-x')
-env.Program(target = 'test01', source = 'test01.f')
-env.Program(target = 'test02', source = 'test02.F')
-env.Program(target = 'test03', source = 'test03.for')
-env.Program(target = 'test04', source = 'test04.FOR')
-env.Program(target = 'test05', source = 'test05.ftn')
-env.Program(target = 'test06', source = 'test06.FTN')
-env.Program(target = 'test07', source = 'test07.fpp')
-env.Program(target = 'test08', source = 'test08.FPP')
env.Program(target = 'test09', source = 'test09.f77')
env.Program(target = 'test10', source = 'test10.F77')
""" % locals())
-test.write('test01.f', "This is a .f file.\n#link\n#g77\n")
-test.write('test02.F', "This is a .F file.\n#link\n#g77\n")
-test.write('test03.for', "This is a .for file.\n#link\n#g77\n")
-test.write('test04.FOR', "This is a .FOR file.\n#link\n#g77\n")
-test.write('test05.ftn', "This is a .ftn file.\n#link\n#g77\n")
-test.write('test06.FTN', "This is a .FTN file.\n#link\n#g77\n")
-test.write('test07.fpp', "This is a .fpp file.\n#link\n#g77\n")
-test.write('test08.FPP', "This is a .FPP file.\n#link\n#g77\n")
test.write('test09.f77', "This is a .f77 file.\n#link\n#g77\n")
test.write('test10.F77', "This is a .F77 file.\n#link\n#g77\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _exe, " -c -x\nThis is a .f file.\n")
-test.must_match('test02' + _exe, " -c -x\nThis is a .F file.\n")
-test.must_match('test03' + _exe, " -c -x\nThis is a .for file.\n")
-test.must_match('test04' + _exe, " -c -x\nThis is a .FOR file.\n")
-test.must_match('test05' + _exe, " -c -x\nThis is a .ftn file.\n")
-test.must_match('test06' + _exe, " -c -x\nThis is a .FTN file.\n")
-test.must_match('test07' + _exe, " -c -x\nThis is a .fpp file.\n")
-test.must_match('test08' + _exe, " -c -x\nThis is a .FPP file.\n")
test.must_match('test09' + _exe, " -c -x\nThis is a .f77 file.\n")
test.must_match('test10' + _exe, " -c -x\nThis is a .F77 file.\n")
-
-g77 = test.detect('F77', 'g77')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f77'
+g77 = test.detect_tool(fc)
if g77:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %FTN_LIBs)
+foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = [".f"])
f77 = foo.Dictionary('F77')
bar = foo.Clone(F77 = r'%(_python_)s wrapper.py ' + f77, F77FLAGS = '-Ix')
foo.Program(target = 'foo', source = 'foo.f')
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar' + _exe)
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar' + _exe, stderr = None)
+ else:
+ test.run(arguments = 'bar' + _exe)
test.run(program = test.workpath('bar'), stdout = " bar.f\n")
import TestSCons
_exe = TestSCons._exe
-FTN_LIB = TestSCons.fortran_lib
prog = 'prog' + _exe
subdir_prog = os.path.join('subdir', 'prog' + _exe)
variant_prog = os.path.join('variant', 'prog' + _exe)
test = TestSCons.TestSCons()
-if not test.detect('_F77G', 'g77'):
- test.skip_test('Could not find a $F77 tool; skipping test.\n')
+fc = 'f77'
+if not test.detect_tool(fc):
+ test.skip_test('Could not find a f77 tool; skipping test.\n')
test.subdir('include',
'subdir',
test.write('SConstruct', """
-env = Environment(F77PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
- LIBS = %s,
+env = Environment(F77 = '%s',
+ F77PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
FOO='include',
F77FLAGS = '-x f77')
obj = env.Object(target='foobar/prog', source='subdir/prog.f77')
VariantDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F77PATH=[include, '#foobar', '#subdir'],
- LIBS = %s,
+env = Environment(F77 = '%s',
+ F77PATH=[include, '#foobar', '#subdir'],
F77FLAGS = '-x f77')
SConscript('variant/SConscript', "env")
-""" % (FTN_LIB, FTN_LIB))
+""" % (fc, fc))
test.write(['subdir', 'SConscript'],
"""
# Change F77PATH and make sure we don't rebuild because of it.
test.write('SConstruct', """
-env = Environment(F77PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
- LIBS = %s,
+env = Environment(F77 = '%s',
+ F77PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
F77FLAGS = '-x f77')
obj = env.Object(target='foobar/prog', source='subdir/prog.f77')
env.Program(target='prog', source=obj)
VariantDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F77PATH=['inc2', include, '#foobar', '#subdir'],
- LIBS = %s,
+env = Environment(F77 = '%s',
+ F77PATH=['inc2', include, '#foobar', '#subdir'],
F77FLAGS = '-x f77')
SConscript('variant/SConscript', "env")
-""" % (FTN_LIB, FTN_LIB))
+""" % (fc, fc))
test.up_to_date(arguments = args)
# Check that a null-string F77PATH doesn't blow up.
test.write('SConstruct', """
-env = Environment(F77PATH = '', LIBS = %s, F77FLAGS = '-x f77')
+env = Environment(tools = ['f77'], F77PATH = '', F77FLAGS = '-x f77')
env.Object('foo', source = 'empty.f77')
-""" % FTN_LIB)
+""")
test.write('empty.f77', '')
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import getopt
env.Program(target = 'test06', source = 'test06.FTN')
env.Program(target = 'test07', source = 'test07.fpp')
env.Program(target = 'test08', source = 'test08.FPP')
-env.Program(target = 'test09', source = 'test09.f77')
-env.Program(target = 'test10', source = 'test10.F77')
env.Program(target = 'test11', source = 'test11.f90')
env.Program(target = 'test12', source = 'test12.F90')
-env.Program(target = 'test13', source = 'test13.f95')
-env.Program(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n")
test.write('test11.f90', "This is a .f90 file.\n#link\n#f90\n")
test.write('test12.F90', "This is a .F90 file.\n#link\n#f90\n")
-test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#link\n#fortran\n")
test.run(arguments = '.', stderr = None)
test.must_match('test06' + _exe, "This is a .FTN file.\n")
test.must_match('test07' + _exe, "This is a .fpp file.\n")
test.must_match('test08' + _exe, "This is a .FPP file.\n")
-test.must_match('test09' + _exe, "This is a .f77 file.\n")
-test.must_match('test10' + _exe, "This is a .F77 file.\n")
test.must_match('test11' + _exe, "This is a .f90 file.\n")
test.must_match('test12' + _exe, "This is a .F90 file.\n")
-test.must_match('test13' + _exe, "This is a .f95 file.\n")
-test.must_match('test14' + _exe, "This is a .F95 file.\n")
-
-g90 = test.detect('F90', 'g90')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f90'
+g90 = test.detect_tool(fc)
if g90:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(F90 = '%(fc)s')
f90 = foo.Dictionary('F90')
bar = foo.Clone(F90 = r'%(_python_)s wrapper.py ' + f90)
-foo.Program(target = 'foo', source = 'foo.f')
-bar.Program(target = 'bar', source = 'bar.f')
+foo.Program(target = 'foo', source = 'foo.f90')
+bar.Program(target = 'bar', source = 'bar.f90')
""" % locals())
- test.write('foo.f', r"""
+ test.write('foo.f90', r"""
PROGRAM FOO
- USE MOD_BAR
- PRINT *,'foo.f'
- CALL P
- STOP
+ PRINT *,'foo.f90'
END
- MODULE MOD_BAR
- IMPLICIT NONE
- CONTAINS
- SUBROUTINE P
- PRINT *,'mod_bar'
- END SUBROUTINE P
- END MODULE MOD_BAR
""")
- test.write('bar.f', r"""
+ test.write('bar.f90', r"""
PROGRAM BAR
- USE MOD_FOO
- PRINT *,'bar.f'
- CALL P
- STOP
+ PRINT *,'bar.f90'
END
""")
- test.write('foo_mod.f', r"""
- MODULE MOD_FOO
- IMPLICIT NONE
- CONTAINS
- SUBROUTINE P
- PRINT *,'mod_foo'
- END SUBROUTINE P
- END MODULE MOD_FOO
-""")
-
test.run(arguments = 'foo' + _exe, stderr = None)
- test.run(program = test.workpath('foo'), stdout = " foo.f\n")
+ test.run(program = test.workpath('foo'), stdout = " foo.f90\n")
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar' + _exe)
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar' + _exe, stderr = None)
+ else:
+ test.run(arguments = 'bar' + _exe)
- test.run(program = test.workpath('bar'), stdout = " bar.f\n")
+ test.run(program = test.workpath('bar'), stdout = " bar.f90\n")
test.must_match('wrapper.out', "wrapper.py\n")
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import sys
env.Program(target = 'test06', source = 'test06.FTN')
env.Program(target = 'test07', source = 'test07.fpp')
env.Program(target = 'test08', source = 'test08.FPP')
-env.Program(target = 'test09', source = 'test09.f77')
-env.Program(target = 'test10', source = 'test10.F77')
env.Program(target = 'test11', source = 'test11.f90')
env.Program(target = 'test12', source = 'test12.F90')
-env.Program(target = 'test13', source = 'test13.f95')
-env.Program(target = 'test14', source = 'test14.F95')
env2 = Environment(LINK = r'%(_python_)s mylink.py',
LINKFLAGS = [],
F90COM = r'%(_python_)s myfortran.py f90 $TARGET $SOURCES',
test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n")
test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n")
-test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#link\n#fortranpp\n")
test.write('test11.f90', "This is a .f90 file.\n#link\n#f90\n")
test.write('test12.F90', "This is a .F90 file.\n#link\n#f90pp\n")
-test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#link\n#fortranpp\n")
test.write('test21.f90', "This is a .f90 file.\n#link\n#f90\n")
test.write('test22.F90', "This is a .F90 file.\n#link\n#f90pp\n")
test.must_match('test06' + _exe, "This is a .FTN file.\n")
test.must_match('test07' + _exe, "This is a .fpp file.\n")
test.must_match('test08' + _exe, "This is a .FPP file.\n")
-test.must_match('test09' + _exe, "This is a .f77 file.\n")
-test.must_match('test10' + _exe, "This is a .F77 file.\n")
test.must_match('test11' + _exe, "This is a .f90 file.\n")
test.must_match('test12' + _exe, "This is a .F90 file.\n")
-test.must_match('test13' + _exe, "This is a .f95 file.\n")
-test.must_match('test14' + _exe, "This is a .F95 file.\n")
test.must_match('test21' + _exe, "This is a .f90 file.\n")
test.must_match('test22' + _exe, "This is a .F90 file.\n")
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+from common import write_fake_link
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+write_fake_link(test)
+
+test.write('myfortran.py', r"""
+import getopt
+import sys
+comment = '#' + sys.argv[1]
+opts, args = getopt.getopt(sys.argv[2:], 'co:')
+for opt, arg in opts:
+ if opt == '-o': out = arg
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:len(comment)] != comment:
+ outfile.write(l)
+sys.exit(0)
+""")
+
+# Test default file suffix: .f90/.F90 for F90
+test.write('SConstruct', """
+env = Environment(LINK = r'%(_python_)s mylink.py',
+ LINKFLAGS = [],
+ F90 = r'%(_python_)s myfortran.py f90',
+ FORTRAN = r'%(_python_)s myfortran.py fortran')
+env.Program(target = 'test01', source = 'test01.f')
+env.Program(target = 'test02', source = 'test02.F')
+env.Program(target = 'test03', source = 'test03.for')
+env.Program(target = 'test04', source = 'test04.FOR')
+env.Program(target = 'test05', source = 'test05.ftn')
+env.Program(target = 'test06', source = 'test06.FTN')
+env.Program(target = 'test07', source = 'test07.fpp')
+env.Program(target = 'test08', source = 'test08.FPP')
+env.Program(target = 'test09', source = 'test09.f90')
+env.Program(target = 'test10', source = 'test10.F90')
+""" % locals())
+
+test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
+test.write('test02.F', "This is a .F file.\n#link\n#fortran\n")
+test.write('test03.for', "This is a .for file.\n#link\n#fortran\n")
+test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n")
+test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n")
+test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
+test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
+test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
+test.write('test09.f90', "This is a .f90 file.\n#link\n#f90\n")
+test.write('test10.F90', "This is a .F90 file.\n#link\n#f90\n")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test01' + _exe, "This is a .f file.\n")
+test.must_match('test02' + _exe, "This is a .F file.\n")
+test.must_match('test03' + _exe, "This is a .for file.\n")
+test.must_match('test04' + _exe, "This is a .FOR file.\n")
+test.must_match('test05' + _exe, "This is a .ftn file.\n")
+test.must_match('test06' + _exe, "This is a .FTN file.\n")
+test.must_match('test07' + _exe, "This is a .fpp file.\n")
+test.must_match('test08' + _exe, "This is a .FPP file.\n")
+test.must_match('test09' + _exe, "This is a .f90 file.\n")
+test.must_match('test10' + _exe, "This is a .F90 file.\n")
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+from common import write_fake_link
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+write_fake_link(test)
+
+test.write('myfortran.py', r"""
+import getopt
+import sys
+comment = '#' + sys.argv[1]
+opts, args = getopt.getopt(sys.argv[2:], 'co:')
+for opt, arg in opts:
+ if opt == '-o': out = arg
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:len(comment)] != comment:
+ outfile.write(l)
+sys.exit(0)
+""")
+
+# Test non-default file suffix: .f/.F for F90
+test.write('SConstruct', """
+env = Environment(LINK = r'%(_python_)s mylink.py',
+ LINKFLAGS = [],
+ F77 = r'%(_python_)s myfortran.py f77',
+ F90 = r'%(_python_)s myfortran.py f90',
+ F90FILESUFFIXES = ['.f', '.F', '.f90', '.F90'],
+ tools = ['default', 'f90'])
+env.Program(target = 'test01', source = 'test01.f')
+env.Program(target = 'test02', source = 'test02.F')
+env.Program(target = 'test03', source = 'test03.f90')
+env.Program(target = 'test04', source = 'test04.F90')
+env.Program(target = 'test05', source = 'test05.f77')
+env.Program(target = 'test06', source = 'test06.F77')
+""" % locals())
+
+test.write('test01.f', "This is a .f file.\n#link\n#f90\n")
+test.write('test02.F', "This is a .F file.\n#link\n#f90\n")
+test.write('test03.f90', "This is a .f90 file.\n#link\n#f90\n")
+test.write('test04.F90', "This is a .F90 file.\n#link\n#f90\n")
+test.write('test05.f77', "This is a .f77 file.\n#link\n#f77\n")
+test.write('test06.F77', "This is a .F77 file.\n#link\n#f77\n")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test01' + _exe, "This is a .f file.\n")
+test.must_match('test02' + _exe, "This is a .F file.\n")
+test.must_match('test03' + _exe, "This is a .f90 file.\n")
+test.must_match('test04' + _exe, "This is a .F90 file.\n")
+test.must_match('test05' + _exe, "This is a .f77 file.\n")
+test.must_match('test06' + _exe, "This is a .F77 file.\n")
+
+test.pass_test()
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
test = TestSCons.TestSCons()
_exe = TestSCons._exe
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import getopt
env.Program(target = 'test06', source = 'test06.FTN')
env.Program(target = 'test07', source = 'test07.fpp')
env.Program(target = 'test08', source = 'test08.FPP')
-env.Program(target = 'test09', source = 'test09.f77')
-env.Program(target = 'test10', source = 'test10.F77')
env.Program(target = 'test11', source = 'test11.f90')
env.Program(target = 'test12', source = 'test12.F90')
-env.Program(target = 'test13', source = 'test13.f95')
-env.Program(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n")
test.write('test11.f90', "This is a .f90 file.\n#link\n#g90\n")
test.write('test12.F90', "This is a .F90 file.\n#link\n#g90\n")
-test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#link\n#fortran\n")
test.run(arguments = '.', stderr = None)
test.must_match('test06' + _exe, " -c -y\nThis is a .FTN file.\n")
test.must_match('test07' + _exe, " -c -y\nThis is a .fpp file.\n")
test.must_match('test08' + _exe, " -c -y\nThis is a .FPP file.\n")
-test.must_match('test09' + _exe, " -c -y\nThis is a .f77 file.\n")
-test.must_match('test10' + _exe, " -c -y\nThis is a .F77 file.\n")
test.must_match('test11' + _exe, " -c -x\nThis is a .f90 file.\n")
test.must_match('test12' + _exe, " -c -x\nThis is a .F90 file.\n")
-test.must_match('test13' + _exe, " -c -y\nThis is a .f95 file.\n")
-test.must_match('test14' + _exe, " -c -y\nThis is a .F95 file.\n")
-g90 = test.detect('F90', 'g90')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f90'
+g90 = test.detect_tool(fc)
if g90:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(F90 = '%(fc)s')
f90 = foo.Dictionary('F90')
-bar = foo.Clone(F90 = r'%(_python_)s wrapper.py ' + f90, F90FLAGS = '-Ix')
-foo.Program(target = 'foo', source = 'foo.f')
-bar.Program(target = 'bar', source = 'bar.f')
+bar = foo.Clone(F90 = r'%(_python_)s wrapper.py ' + f90)
+foo.Program(target = 'foo', source = 'foo.f90')
+bar.Program(target = 'bar', source = 'bar.f90')
""" % locals())
- test.write('foo.f', r"""
+ test.write('foo.f90', r"""
PROGRAM FOO
- USE MOD_BAR
- PRINT *,'foo.f'
- CALL P
- STOP
+ PRINT *,'foo.f90'
END
- MODULE MOD_BAR
- IMPLICIT NONE
- CONTAINS
- SUBROUTINE P
- PRINT *,'mod_bar'
- END SUBROUTINE P
- END MODULE MOD_BAR
""")
- test.write('bar.f', r"""
+ test.write('bar.f90', r"""
PROGRAM BAR
- USE MOD_FOO
- PRINT *,'bar.f'
- CALL P
- STOP
+ PRINT *,'bar.f90'
END
""")
- test.write('foo_mod.f', r"""
- MODULE MOD_FOO
- IMPLICIT NONE
- CONTAINS
- SUBROUTINE P
- PRINT *,'mod_foo'
- END SUBROUTINE P
- END MODULE MOD_FOO
-""")
-
test.run(arguments = 'foo' + _exe, stderr = None)
- test.run(program = test.workpath('foo'), stdout = " foo.f\n")
+ test.run(program = test.workpath('foo'), stdout = " foo.f90\n")
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar' + _exe)
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar' + _exe, stderr = None)
+ else:
+ test.run(arguments = 'bar' + _exe)
- test.run(program = test.workpath('bar'), stdout = " bar.f\n")
+ test.run(program = test.workpath('bar'), stdout = " bar.f90\n")
test.must_match('wrapper.out', "wrapper.py\n")
import TestSCons
_exe = TestSCons._exe
-FTN_LIB = TestSCons.fortran_lib
prog = 'prog' + _exe
subdir_prog = os.path.join('subdir', 'prog' + _exe)
variant_prog = os.path.join('variant', 'prog' + _exe)
test = TestSCons.TestSCons()
-baselist = [
- '/opt/intel_fc_80',
- '/opt/intel/fc/9.0',
-]
-
-F90 = None
-for base in baselist:
- ifort = os.path.join(base, 'bin', 'ifort')
- if os.path.exists(ifort):
- F90 = ifort
-
-if not F90:
- l = string.join(baselist, '\n\t')
- test.skip_test('No (hard-coded) F90 compiler under:' + l + '\n')
-
-LIBPATH = os.path.join(base, 'lib')
-LIBS = ['irc']
-os.environ['LD_LIBRARY_PATH'] = LIBPATH
+fc = 'f90'
+if not test.detect_tool(fc):
+ test.skip_test('Could not find a f90 tool; skipping test.\n')
test.subdir('include',
'subdir',
env = Environment(F90 = r'%s',
F90PATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
LINK = '$F90',
- LIBPATH = %s,
- LIBS = %s,
FOO='include')
obj = env.Object(target='foobar/prog', source='subdir/prog.f90')
env.Program(target='prog', source=obj)
include = Dir('include')
env = Environment(F90 = r'%s',
F90PATH=[include, '#foobar', '#subdir'],
- LINK = '$F90',
- LIBPATH = %s,
- LIBS = %s)
+ LINK = '$F90')
SConscript('variant/SConscript', "env")
-""" % (F90, repr(LIBPATH), LIBS, F90, repr(LIBPATH), LIBS))
+""" % (fc, fc, ))
test.write(['subdir', 'SConscript'],
"""
test.write('SConstruct', """
env = Environment(F90 = r'%s',
F90PATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
- LINK = '$F90',
- LIBPATH = %s,
- LIBS = %s)
+ LINK = '$F90')
obj = env.Object(target='foobar/prog', source='subdir/prog.f90')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
include = Dir('include')
env = Environment(F90 = r'%s',
F90PATH=['inc2', include, '#foobar', '#subdir'],
- LINK = '$F90',
- LIBPATH = %s,
- LIBS = %s)
+ LINK = '$F90')
SConscript('variant/SConscript', "env")
-""" % (F90, repr(LIBPATH), LIBS, F90, repr(LIBPATH), LIBS))
+""" % (fc, fc))
test.up_to_date(arguments = args)
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import getopt
env.Program(target = 'test06', source = 'test06.FTN')
env.Program(target = 'test07', source = 'test07.fpp')
env.Program(target = 'test08', source = 'test08.FPP')
-env.Program(target = 'test09', source = 'test09.f77')
-env.Program(target = 'test10', source = 'test10.F77')
-env.Program(target = 'test11', source = 'test11.f90')
-env.Program(target = 'test12', source = 'test12.F90')
env.Program(target = 'test13', source = 'test13.f95')
env.Program(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n")
-test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#link\n#fortran\n")
test.write('test13.f95', "This is a .f95 file.\n#link\n#f95\n")
test.write('test14.F95', "This is a .F95 file.\n#link\n#f95\n")
test.must_match('test06' + _exe, "This is a .FTN file.\n")
test.must_match('test07' + _exe, "This is a .fpp file.\n")
test.must_match('test08' + _exe, "This is a .FPP file.\n")
-test.must_match('test09' + _exe, "This is a .f77 file.\n")
-test.must_match('test10' + _exe, "This is a .F77 file.\n")
-test.must_match('test11' + _exe, "This is a .f90 file.\n")
-test.must_match('test12' + _exe, "This is a .F90 file.\n")
test.must_match('test13' + _exe, "This is a .f95 file.\n")
test.must_match('test14' + _exe, "This is a .F95 file.\n")
-
-g95 = test.detect('F95', 'g95')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f95'
+g95 = test.detect_tool(fc)
if g95:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(F95 = '%(fc)s')
f95 = foo.Dictionary('F95')
bar = foo.Clone(F95 = r'%(_python_)s wrapper.py ' + f95)
-foo.Program(target = 'foo', source = 'foo.f')
-bar.Program(target = 'bar', source = 'bar.f')
+foo.Program(target = 'foo', source = 'foo.f95')
+bar.Program(target = 'bar', source = 'bar.f95')
""" % locals())
- test.write('foo.f', r"""
+ test.write('foo.f95', r"""
PROGRAM FOO
- PRINT *,'foo.f'
+ PRINT *,'foo.f95'
STOP
END
""")
- test.write('bar.f', r"""
+ test.write('bar.f95', r"""
PROGRAM BAR
- PRINT *,'bar.f'
+ PRINT *,'bar.f95'
STOP
END
""")
test.run(arguments = 'foo' + _exe, stderr = None)
- test.run(program = test.workpath('foo'), stdout = " foo.f\n")
+ test.run(program = test.workpath('foo'), stdout = " foo.f95\n")
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar' + _exe)
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar' + _exe, stderr = None)
+ else:
+ test.run(arguments = 'bar' + _exe)
- test.run(program = test.workpath('bar'), stdout = " bar.f\n")
+ test.run(program = test.workpath('bar'), stdout = " bar.f95\n")
test.must_match('wrapper.out', "wrapper.py\n")
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import sys
env.Program(target = 'test06', source = 'test06.FTN')
env.Program(target = 'test07', source = 'test07.fpp')
env.Program(target = 'test08', source = 'test08.FPP')
-env.Program(target = 'test09', source = 'test09.f77')
-env.Program(target = 'test10', source = 'test10.F77')
-env.Program(target = 'test11', source = 'test11.f90')
-env.Program(target = 'test12', source = 'test12.F90')
env.Program(target = 'test13', source = 'test13.f95')
env.Program(target = 'test14', source = 'test14.F95')
env2 = Environment(LINK = r'%(_python_)s mylink.py',
test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n")
test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n")
-test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#link\n#fortranpp\n")
-test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#link\n#fortranpp\n")
test.write('test13.f95', "This is a .f95 file.\n#link\n#f95\n")
test.write('test14.F95', "This is a .F95 file.\n#link\n#f95pp\n")
test.must_match('test06' + _exe, "This is a .FTN file.\n")
test.must_match('test07' + _exe, "This is a .fpp file.\n")
test.must_match('test08' + _exe, "This is a .FPP file.\n")
-test.must_match('test09' + _exe, "This is a .f77 file.\n")
-test.must_match('test10' + _exe, "This is a .F77 file.\n")
-test.must_match('test11' + _exe, "This is a .f90 file.\n")
-test.must_match('test12' + _exe, "This is a .F90 file.\n")
test.must_match('test13' + _exe, "This is a .f95 file.\n")
test.must_match('test14' + _exe, "This is a .F95 file.\n")
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+from common import write_fake_link
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+write_fake_link(test)
+
+test.write('myfortran.py', r"""
+import getopt
+import sys
+comment = '#' + sys.argv[1]
+opts, args = getopt.getopt(sys.argv[2:], 'co:')
+for opt, arg in opts:
+ if opt == '-o': out = arg
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:len(comment)] != comment:
+ outfile.write(l)
+sys.exit(0)
+""")
+
+# Test default file suffix: .f90/.F90 for F90
+test.write('SConstruct', """
+env = Environment(LINK = r'%(_python_)s mylink.py',
+ LINKFLAGS = [],
+ F95 = r'%(_python_)s myfortran.py f95',
+ FORTRAN = r'%(_python_)s myfortran.py fortran')
+env.Program(target = 'test01', source = 'test01.f')
+env.Program(target = 'test02', source = 'test02.F')
+env.Program(target = 'test03', source = 'test03.for')
+env.Program(target = 'test04', source = 'test04.FOR')
+env.Program(target = 'test05', source = 'test05.ftn')
+env.Program(target = 'test06', source = 'test06.FTN')
+env.Program(target = 'test07', source = 'test07.fpp')
+env.Program(target = 'test08', source = 'test08.FPP')
+env.Program(target = 'test09', source = 'test09.f95')
+env.Program(target = 'test10', source = 'test10.F95')
+""" % locals())
+
+test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
+test.write('test02.F', "This is a .F file.\n#link\n#fortran\n")
+test.write('test03.for', "This is a .for file.\n#link\n#fortran\n")
+test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n")
+test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n")
+test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
+test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
+test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
+test.write('test09.f95', "This is a .f95 file.\n#link\n#f95\n")
+test.write('test10.F95', "This is a .F95 file.\n#link\n#f95\n")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test01' + _exe, "This is a .f file.\n")
+test.must_match('test02' + _exe, "This is a .F file.\n")
+test.must_match('test03' + _exe, "This is a .for file.\n")
+test.must_match('test04' + _exe, "This is a .FOR file.\n")
+test.must_match('test05' + _exe, "This is a .ftn file.\n")
+test.must_match('test06' + _exe, "This is a .FTN file.\n")
+test.must_match('test07' + _exe, "This is a .fpp file.\n")
+test.must_match('test08' + _exe, "This is a .FPP file.\n")
+test.must_match('test09' + _exe, "This is a .f95 file.\n")
+test.must_match('test10' + _exe, "This is a .F95 file.\n")
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+from common import write_fake_link
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+write_fake_link(test)
+
+test.write('myfortran.py', r"""
+import getopt
+import sys
+comment = '#' + sys.argv[1]
+opts, args = getopt.getopt(sys.argv[2:], 'co:')
+for opt, arg in opts:
+ if opt == '-o': out = arg
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:len(comment)] != comment:
+ outfile.write(l)
+sys.exit(0)
+""")
+
+# Test non-default file suffix: .f/.F for F95
+test.write('SConstruct', """
+env = Environment(LINK = r'%(_python_)s mylink.py',
+ LINKFLAGS = [],
+ F77 = r'%(_python_)s myfortran.py f77',
+ F95 = r'%(_python_)s myfortran.py f95',
+ F95FILESUFFIXES = ['.f', '.F', '.f95', '.F95'],
+ tools = ['default', 'f95'])
+env.Program(target = 'test01', source = 'test01.f')
+env.Program(target = 'test02', source = 'test02.F')
+env.Program(target = 'test03', source = 'test03.f95')
+env.Program(target = 'test04', source = 'test04.F95')
+env.Program(target = 'test05', source = 'test05.f77')
+env.Program(target = 'test06', source = 'test06.F77')
+""" % locals())
+
+test.write('test01.f', "This is a .f file.\n#link\n#f95\n")
+test.write('test02.F', "This is a .F file.\n#link\n#f95\n")
+test.write('test03.f95', "This is a .f95 file.\n#link\n#f95\n")
+test.write('test04.F95', "This is a .F95 file.\n#link\n#f95\n")
+test.write('test05.f77', "This is a .f77 file.\n#link\n#f77\n")
+test.write('test06.F77', "This is a .F77 file.\n#link\n#f77\n")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test01' + _exe, "This is a .f file.\n")
+test.must_match('test02' + _exe, "This is a .F file.\n")
+test.must_match('test03' + _exe, "This is a .f95 file.\n")
+test.must_match('test04' + _exe, "This is a .F95 file.\n")
+test.must_match('test05' + _exe, "This is a .f77 file.\n")
+test.must_match('test06' + _exe, "This is a .F77 file.\n")
+
+test.pass_test()
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
test = TestSCons.TestSCons()
_exe = TestSCons._exe
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import getopt
env.Program(target = 'test06', source = 'test06.FTN')
env.Program(target = 'test07', source = 'test07.fpp')
env.Program(target = 'test08', source = 'test08.FPP')
-env.Program(target = 'test09', source = 'test09.f77')
-env.Program(target = 'test10', source = 'test10.F77')
-env.Program(target = 'test11', source = 'test11.f90')
-env.Program(target = 'test12', source = 'test12.F90')
env.Program(target = 'test13', source = 'test13.f95')
env.Program(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n")
-test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#link\n#fortran\n")
test.write('test13.f95', "This is a .f95 file.\n#link\n#g95\n")
test.write('test14.F95', "This is a .F95 file.\n#link\n#g95\n")
test.must_match('test06' + _exe, " -c -y\nThis is a .FTN file.\n")
test.must_match('test07' + _exe, " -c -y\nThis is a .fpp file.\n")
test.must_match('test08' + _exe, " -c -y\nThis is a .FPP file.\n")
-test.must_match('test09' + _exe, " -c -y\nThis is a .f77 file.\n")
-test.must_match('test10' + _exe, " -c -y\nThis is a .F77 file.\n")
-test.must_match('test11' + _exe, " -c -y\nThis is a .f90 file.\n")
-test.must_match('test12' + _exe, " -c -y\nThis is a .F90 file.\n")
test.must_match('test13' + _exe, " -c -x\nThis is a .f95 file.\n")
test.must_match('test14' + _exe, " -c -x\nThis is a .F95 file.\n")
+fc = 'f95'
+g95 = test.detect_tool(fc)
-g95 = test.detect('F95', 'g95')
-FTN_LIB = TestSCons.fortran_lib
if g95:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(F95 = '%(fc)s')
f95 = foo.Dictionary('F95')
bar = foo.Clone(F95 = r'%(_python_)s wrapper.py ' + f95, F95FLAGS = '-Ix')
-foo.Program(target = 'foo', source = 'foo.f')
-bar.Program(target = 'bar', source = 'bar.f')
+foo.Program(target = 'foo', source = 'foo.f95')
+bar.Program(target = 'bar', source = 'bar.f95')
""" % locals())
- test.write('foo.f', r"""
+ test.write('foo.f95', r"""
PROGRAM FOO
- PRINT *,'foo.f'
+ PRINT *,'foo.f95'
STOP
END
""")
- test.write('bar.f', r"""
+ test.write('bar.f95', r"""
PROGRAM BAR
- PRINT *,'bar.f'
+ PRINT *,'bar.f95'
STOP
END
""")
test.run(arguments = 'foo' + _exe, stderr = None)
- test.run(program = test.workpath('foo'), stdout = " foo.f\n")
+ test.run(program = test.workpath('foo'), stdout = " foo.f95\n")
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar' + _exe)
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar' + _exe, stderr = None)
+ else:
+ test.run(arguments = 'bar' + _exe)
- test.run(program = test.workpath('bar'), stdout = " bar.f\n")
+ test.run(program = test.workpath('bar'), stdout = " bar.f95\n")
test.must_match('wrapper.out', "wrapper.py\n")
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myg77.py', r"""
import getopt
env.Program(target = 'test06', source = 'test06.FTN')
env.Program(target = 'test07', source = 'test07.fpp')
env.Program(target = 'test08', source = 'test08.FPP')
-env.Program(target = 'test09', source = 'test09.f77')
-env.Program(target = 'test10', source = 'test10.F77')
-env.Program(target = 'test11', source = 'test11.f90')
-env.Program(target = 'test12', source = 'test12.F90')
-env.Program(target = 'test13', source = 'test13.f95')
-env.Program(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#link\n#g77\n")
test.write('test06.FTN', "This is a .FTN file.\n#link\n#g77\n")
test.write('test07.fpp', "This is a .fpp file.\n#link\n#g77\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#g77\n")
-test.write('test09.f77', "This is a .f77 file.\n#link\n#g77\n")
-test.write('test10.F77', "This is a .F77 file.\n#link\n#g77\n")
-test.write('test11.f90', "This is a .f90 file.\n#link\n#g77\n")
-test.write('test12.F90', "This is a .F90 file.\n#link\n#g77\n")
-test.write('test13.f95', "This is a .f95 file.\n#link\n#g77\n")
-test.write('test14.F95', "This is a .F95 file.\n#link\n#g77\n")
test.run(arguments = '.', stderr = None)
test.must_match('test06' + _exe, "This is a .FTN file.\n")
test.must_match('test07' + _exe, "This is a .fpp file.\n")
test.must_match('test08' + _exe, "This is a .FPP file.\n")
-test.must_match('test09' + _exe, "This is a .f77 file.\n")
-test.must_match('test10' + _exe, "This is a .F77 file.\n")
-test.must_match('test11' + _exe, "This is a .f90 file.\n")
-test.must_match('test12' + _exe, "This is a .F90 file.\n")
-test.must_match('test13' + _exe, "This is a .f95 file.\n")
-test.must_match('test14' + _exe, "This is a .F95 file.\n")
-g77 = test.detect('FORTRAN', 'g77')
+fc = 'f77'
+f77 = test.detect_tool(fc)
FTN_LIB = TestSCons.fortran_lib
-if g77:
+if f77:
test.write("wrapper.py",
"""import os
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(FORTRAN = '%(fc)s')
f77 = foo.Dictionary('FORTRAN')
bar = foo.Clone(FORTRAN = r'%(_python_)s wrapper.py ' + f77)
foo.Program(target = 'foo', source = 'foo.f')
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar' + _exe)
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar' + _exe, stderr = None)
+ else:
+ test.run(arguments = 'bar' + _exe)
test.run(program = test.workpath('bar'), stdout = " bar.f\n")
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
_exe = TestSCons._exe
test = TestSCons.TestSCons()
-
-
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import sys
env.Program(target = 'test06', source = 'test06.FTN')
env.Program(target = 'test07', source = 'test07.fpp')
env.Program(target = 'test08', source = 'test08.FPP')
-env.Program(target = 'test09', source = 'test09.f77')
-env.Program(target = 'test10', source = 'test10.F77')
-env.Program(target = 'test11', source = 'test11.f90')
-env.Program(target = 'test12', source = 'test12.F90')
-env.Program(target = 'test13', source = 'test13.f95')
-env.Program(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n")
test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n")
-test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#link\n#fortranpp\n")
-test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#link\n#fortranpp\n")
-test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#link\n#fortranpp\n")
test.run(arguments = '.', stderr = None)
test.must_match('test06' + _exe, "This is a .FTN file.\n")
test.must_match('test07' + _exe, "This is a .fpp file.\n")
test.must_match('test08' + _exe, "This is a .FPP file.\n")
-test.must_match('test09' + _exe, "This is a .f77 file.\n")
-test.must_match('test10' + _exe, "This is a .F77 file.\n")
-test.must_match('test11' + _exe, "This is a .f90 file.\n")
-test.must_match('test12' + _exe, "This is a .F90 file.\n")
-test.must_match('test13' + _exe, "This is a .f95 file.\n")
-test.must_match('test14' + _exe, "This is a .F95 file.\n")
test.pass_test()
env.Object(source = 'test06.FTN')
env.Object(source = 'test07.fpp')
env.Object(source = 'test08.FPP')
-env.Object(source = 'test09.f77')
-env.Object(source = 'test10.F77')
-env.Object(source = 'test11.f90')
-env.Object(source = 'test12.F90')
-env.Object(source = 'test13.f95')
-env.Object(source = 'test14.F95')
""" % locals())
test.write('test01.f', "A .f file.\n#fortran\n")
test.write('test06.FTN', "A .FTN file.\n#%s\n" % fortranpp)
test.write('test07.fpp', "A .fpp file.\n#fortranpp\n")
test.write('test08.FPP', "A .FPP file.\n#fortranpp\n")
-test.write('test09.f77', "A .f77 file.\n#fortran\n")
-test.write('test10.F77', "A .F77 file.\n#%s\n" % fortranpp)
-test.write('test11.f90', "A .f90 file.\n#fortran\n")
-test.write('test12.F90', "A .F90 file.\n#%s\n" % fortranpp)
-test.write('test13.f95', "A .f95 file.\n#fortran\n")
-test.write('test14.F95', "A .F95 file.\n#%s\n" % fortranpp)
test.run(stdout = test.wrap_stdout("""\
Building fortran test01.obj from test01.f
Building %(fortranpp)s test06.obj from test06.FTN
Building fortranpp test07.obj from test07.fpp
Building fortranpp test08.obj from test08.FPP
-Building fortran test09.obj from test09.f77
-Building %(fortranpp)s test10.obj from test10.F77
-Building fortran test11.obj from test11.f90
-Building %(fortranpp)s test12.obj from test12.F90
-Building fortran test13.obj from test13.f95
-Building %(fortranpp)s test14.obj from test14.F95
""" % locals()))
test.must_match('test01.obj', "A .f file.\n")
test.must_match('test06.obj', "A .FTN file.\n")
test.must_match('test07.obj', "A .fpp file.\n")
test.must_match('test08.obj', "A .FPP file.\n")
-test.must_match('test09.obj', "A .f77 file.\n")
-test.must_match('test10.obj', "A .F77 file.\n")
-test.must_match('test11.obj', "A .f90 file.\n")
-test.must_match('test12.obj', "A .F90 file.\n")
-test.must_match('test13.obj', "A .f95 file.\n")
-test.must_match('test14.obj', "A .F95 file.\n")
test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+from common import write_fake_link
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+write_fake_link(test)
+
+test.write('myfortran.py', r"""
+import getopt
+import sys
+comment = '#' + sys.argv[1]
+opts, args = getopt.getopt(sys.argv[2:], 'co:')
+for opt, arg in opts:
+ if opt == '-o': out = arg
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:len(comment)] != comment:
+ outfile.write(l)
+sys.exit(0)
+""")
+
+# Test default file suffix: .f/.F for FORTRAN
+test.write('SConstruct', """
+env = Environment(LINK = r'%(_python_)s mylink.py',
+ LINKFLAGS = [],
+ FORTRAN = r'%(_python_)s myfortran.py fortran')
+env.Program(target = 'test01', source = 'test01.f')
+env.Program(target = 'test02', source = 'test02.F')
+env.Program(target = 'test03', source = 'test03.for')
+env.Program(target = 'test04', source = 'test04.FOR')
+env.Program(target = 'test05', source = 'test05.ftn')
+env.Program(target = 'test06', source = 'test06.FTN')
+env.Program(target = 'test07', source = 'test07.fpp')
+env.Program(target = 'test08', source = 'test08.FPP')
+""" % locals())
+
+test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
+test.write('test02.F', "This is a .F file.\n#link\n#fortran\n")
+test.write('test03.for', "This is a .for file.\n#link\n#fortran\n")
+test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n")
+test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n")
+test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
+test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
+test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test01' + _exe, "This is a .f file.\n")
+test.must_match('test02' + _exe, "This is a .F file.\n")
+test.must_match('test03' + _exe, "This is a .for file.\n")
+test.must_match('test04' + _exe, "This is a .FOR file.\n")
+test.must_match('test05' + _exe, "This is a .ftn file.\n")
+test.must_match('test06' + _exe, "This is a .FTN file.\n")
+test.must_match('test07' + _exe, "This is a .fpp file.\n")
+test.must_match('test08' + _exe, "This is a .FPP file.\n")
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+import TestSCons
+
+from common import write_fake_link
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+write_fake_link(test)
+
+test.write('myfortran.py', r"""
+import getopt
+import sys
+comment = '#' + sys.argv[1]
+opts, args = getopt.getopt(sys.argv[2:], 'co:')
+for opt, arg in opts:
+ if opt == '-o': out = arg
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:len(comment)] != comment:
+ outfile.write(l)
+sys.exit(0)
+""")
+
+# Test non default file suffix: .f, .f90 and .f95 for FORTRAN
+test.write('SConstruct', """
+env = Environment(LINK = r'%(_python_)s mylink.py',
+ LINKFLAGS = [],
+ F77 = r'%(_python_)s myfortran.py g77',
+ FORTRAN = r'%(_python_)s myfortran.py fortran',
+ FORTRANFILESUFFIXES = ['.f', '.f95', '.f90', '.ffake'],
+ tools = ['default', 'fortran'])
+#print env.Dump()
+env.Program(target = 'test01', source = 'test01.f')
+env.Program(target = 'test02', source = 'test02.f90')
+env.Program(target = 'test03', source = 'test03.f95')
+env.Program(target = 'test04', source = 'test04.ffake')
+env.Program(target = 'test05', source = 'test05.f77')
+""" % locals())
+
+test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
+test.write('test02.f90', "This is a .f90 file.\n#link\n#fortran\n")
+test.write('test03.f95', "This is a .f95 file.\n#link\n#fortran\n")
+test.write('test04.ffake', "This is a .ffake file.\n#link\n#fortran\n")
+test.write('test05.f77', "This is a .f77 file.\n#link\n#g77\n")
+
+test.run(arguments = '.', stderr = None)
+
+test.must_match('test01' + _exe, "This is a .f file.\n")
+test.must_match('test02' + _exe, "This is a .f90 file.\n")
+test.must_match('test03' + _exe, "This is a .f95 file.\n")
+test.must_match('test04' + _exe, "This is a .ffake file.\n")
+test.must_match('test05' + _exe, "This is a .f77 file.\n")
+
+test.pass_test()
import sys
import TestSCons
+from common import write_fake_link
+
_python_ = TestSCons._python_
test = TestSCons.TestSCons()
_exe = TestSCons._exe
-if sys.platform == 'win32':
-
- test.write('mylink.py', r"""
-import string
-import sys
-args = sys.argv[1:]
-while args:
- a = args[0]
- if a[0] != '/':
- break
- args = args[1:]
- if string.lower(a[:5]) == '/out:': out = a[5:]
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
-
-else:
-
- test.write('mylink.py', r"""
-import getopt
-import sys
-opts, args = getopt.getopt(sys.argv[1:], 'o:')
-for opt, arg in opts:
- if opt == '-o': out = arg
-infile = open(args[0], 'rb')
-outfile = open(out, 'wb')
-for l in infile.readlines():
- if l[:5] != '#link':
- outfile.write(l)
-sys.exit(0)
-""")
+write_fake_link(test)
test.write('myfortran.py', r"""
import getopt
env.Program(target = 'test06', source = 'test06.FTN')
env.Program(target = 'test07', source = 'test07.fpp')
env.Program(target = 'test08', source = 'test08.FPP')
-env.Program(target = 'test09', source = 'test09.f77')
-env.Program(target = 'test10', source = 'test10.F77')
-env.Program(target = 'test11', source = 'test11.f90')
-env.Program(target = 'test12', source = 'test12.F90')
-env.Program(target = 'test13', source = 'test13.f95')
-env.Program(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#link\n#fortran\n")
test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#link\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#link\n#fortran\n")
-test.write('test11.f90', "This is a .f90 file.\n#link\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#link\n#fortran\n")
-test.write('test13.f95', "This is a .f95 file.\n#link\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#link\n#fortran\n")
test.run(arguments = '.', stderr = None)
test.must_match('test06' + _exe, " -c -x\nThis is a .FTN file.\n")
test.must_match('test07' + _exe, " -c -x\nThis is a .fpp file.\n")
test.must_match('test08' + _exe, " -c -x\nThis is a .FPP file.\n")
-test.must_match('test09' + _exe, " -c -x\nThis is a .f77 file.\n")
-test.must_match('test10' + _exe, " -c -x\nThis is a .F77 file.\n")
-test.must_match('test11' + _exe, " -c -x\nThis is a .f90 file.\n")
-test.must_match('test12' + _exe, " -c -x\nThis is a .F90 file.\n")
-test.must_match('test13' + _exe, " -c -x\nThis is a .f95 file.\n")
-test.must_match('test14' + _exe, " -c -x\nThis is a .F95 file.\n")
-
-g77 = test.detect('FORTRAN', 'g77')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f77'
+g77 = test.detect_tool(fc)
if g77:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(FORTRAN = '%(fc)s')
f77 = foo.Dictionary('FORTRAN')
bar = foo.Clone(FORTRAN = r'%(_python_)s wrapper.py ' + f77, FORTRANFLAGS = '-Ix')
foo.Program(target = 'foo', source = 'foo.f')
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar' + _exe)
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar' + _exe, stderr = None)
+ else:
+ test.run(arguments = 'bar' + _exe)
test.run(program = test.workpath('bar'), stdout = " bar.f\n")
import TestSCons
_exe = TestSCons._exe
-FTN_LIB = TestSCons.fortran_lib
prog = 'prog' + _exe
subdir_prog = os.path.join('subdir', 'prog' + _exe)
variant_prog = os.path.join('variant', 'prog' + _exe)
test = TestSCons.TestSCons()
-if not test.detect('_FORTRANG', 'g77'):
- test.skip_test('Could not find a $F77 tool; skipping test.\n')
+fc = 'f77'
+if not test.detect_tool(fc):
+ test.skip_test('Could not find a f77 tool; skipping test.\n')
test.subdir('include',
'subdir',
test.write('SConstruct', """
-env = Environment(FORTRANPATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
- LIBS = %s, FOO='include')
+env = Environment(FORTRAN = '%s',
+ FORTRANPATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'],
+ FOO='include')
obj = env.Object(target='foobar/prog', source='subdir/prog.f')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
VariantDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(FORTRANPATH=[include, '#foobar', '#subdir'],
- LIBS = %s)
+env = Environment(FORTRAN = '%s',
+ FORTRANPATH=[include, '#foobar', '#subdir'])
SConscript('variant/SConscript', "env")
-""" % (FTN_LIB, FTN_LIB))
+""" % (fc, fc))
test.write(['subdir', 'SConscript'],
"""
""")
-
-test.run(arguments = args)
+import sys
+if sys.platform[:5] == 'sunos':
+ # Sun f77 always put some junk in stderr
+ test.run(arguments = args, stderr = None)
+else:
+ test.run(arguments = args)
test.run(program = test.workpath(prog),
stdout = """\
INCLUDE 'bar.f'
""")
-test.run(arguments = args)
+if sys.platform[:5] == 'sunos':
+ # Sun f77 always put some junk in stderr
+ test.run(arguments = args, stderr = None)
+else:
+ test.run(arguments = args)
test.run(program = test.workpath(prog),
stdout = """\
PRINT *, 'include/bar.f 2'
""")
-test.run(arguments = args)
+if sys.platform[:5] == 'sunos':
+ # Sun f77 always put some junk in stderr
+ test.run(arguments = args, stderr = None)
+else:
+ test.run(arguments = args)
+
test.run(program = test.workpath(prog),
stdout = """\
# Change FORTRANPATH and make sure we don't rebuild because of it.
test.write('SConstruct', """
-env = Environment(FORTRANPATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'),
- LIBS = %s)
+env = Environment(FORTRAN = '%s',
+ FORTRANPATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}'))
obj = env.Object(target='foobar/prog', source='subdir/prog.f')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
VariantDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(FORTRANPATH=['inc2', include, '#foobar', '#subdir'],
- LIBS = %s)
+env = Environment(FORTRAN = '%s',
+ FORTRANPATH=['inc2', include, '#foobar', '#subdir'])
SConscript('variant/SConscript', "env")
-""" % (FTN_LIB, FTN_LIB))
+""" % (fc, fc))
test.up_to_date(arguments = args)
INCLUDE 'bar.f'
""")
-test.run(arguments = args)
+if sys.platform[:5] == 'sunos':
+ # Sun f77 always put some junk in stderr
+ test.run(arguments = args, stderr = None)
+else:
+ test.run(arguments = args)
+
test.run(program = test.workpath(prog),
stdout = """\
# Check that a null-string FORTRANPATH doesn't blow up.
test.write('SConstruct', """
-env = Environment(FORTRANPATH = '', LIBS = %s)
+env = Environment(FORTRANPATH = '')
env.Object('foo', source = 'empty.f')
-""" % FTN_LIB)
+""")
test.write('empty.f', '')
-test.run(arguments = '.')
-
-
+if sys.platform[:5] == 'sunos':
+ # Sun f77 always put some junk in stderr
+ test.run(arguments = '.', stderr = None)
+else:
+ test.run(arguments = '.')
test.pass_test()
_python_ = TestSCons._python_
_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
import getopt
import sys
comment = '#' + sys.argv[1]
-opts, args = getopt.getopt(sys.argv[2:], 'cf:o:')
+opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:')
for opt, arg in opts:
if opt == '-o': out = arg
infile = open(args[0], 'rb')
env.SharedObject(target = 'test08', source = 'test08.FPP')
env.SharedObject(target = 'test09', source = 'test09.f77')
env.SharedObject(target = 'test10', source = 'test10.F77')
-env.SharedObject(target = 'test11', source = 'test11.f90')
-env.SharedObject(target = 'test12', source = 'test12.F90')
-env.SharedObject(target = 'test13', source = 'test13.f95')
-env.SharedObject(target = 'test14', source = 'test14.F95')
-env2 = Environment(SHF77 = r'%(_python_)s myfortran.py g77')
-env2.SharedObject(target = 'test21', source = 'test21.f')
-env2.SharedObject(target = 'test22', source = 'test22.F')
-env2.SharedObject(target = 'test23', source = 'test23.for')
-env2.SharedObject(target = 'test24', source = 'test24.FOR')
-env2.SharedObject(target = 'test25', source = 'test25.ftn')
-env2.SharedObject(target = 'test26', source = 'test26.FTN')
-env2.SharedObject(target = 'test27', source = 'test27.fpp')
-env2.SharedObject(target = 'test28', source = 'test28.FPP')
""" % locals())
test.write('test01.f', "This is a .f file.\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortran\n")
test.write('test09.f77', "This is a .f77 file.\n#g77\n")
test.write('test10.F77', "This is a .F77 file.\n#g77\n")
-test.write('test11.f90', "This is a .f90 file.\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#fortran\n")
-test.write('test13.f95', "This is a .f95 file.\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#fortran\n")
-
-test.write('test21.f', "This is a .f file.\n#g77\n")
-test.write('test22.F', "This is a .F file.\n#g77\n")
-test.write('test23.for', "This is a .for file.\n#g77\n")
-test.write('test24.FOR', "This is a .FOR file.\n#g77\n")
-test.write('test25.ftn', "This is a .ftn file.\n#g77\n")
-test.write('test26.FTN', "This is a .FTN file.\n#g77\n")
-test.write('test27.fpp', "This is a .fpp file.\n#g77\n")
-test.write('test28.FPP', "This is a .FPP file.\n#g77\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, "This is a .f file.\n")
-test.must_match('test02' + _obj, "This is a .F file.\n")
-test.must_match('test03' + _obj, "This is a .for file.\n")
-test.must_match('test04' + _obj, "This is a .FOR file.\n")
-test.must_match('test05' + _obj, "This is a .ftn file.\n")
-test.must_match('test06' + _obj, "This is a .FTN file.\n")
-test.must_match('test07' + _obj, "This is a .fpp file.\n")
-test.must_match('test08' + _obj, "This is a .FPP file.\n")
-test.must_match('test09' + _obj, "This is a .f77 file.\n")
-test.must_match('test10' + _obj, "This is a .F77 file.\n")
-test.must_match('test11' + _obj, "This is a .f90 file.\n")
-test.must_match('test12' + _obj, "This is a .F90 file.\n")
-test.must_match('test13' + _obj, "This is a .f95 file.\n")
-test.must_match('test14' + _obj, "This is a .F95 file.\n")
+test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n")
+test.must_match(obj_ + 'test09' + _obj, "This is a .f77 file.\n")
-test.must_match('test21' + _obj, "This is a .f file.\n")
-test.must_match('test22' + _obj, "This is a .F file.\n")
-test.must_match('test23' + _obj, "This is a .for file.\n")
-test.must_match('test24' + _obj, "This is a .FOR file.\n")
-test.must_match('test25' + _obj, "This is a .ftn file.\n")
-test.must_match('test26' + _obj, "This is a .FTN file.\n")
-test.must_match('test27' + _obj, "This is a .fpp file.\n")
-test.must_match('test28' + _obj, "This is a .FPP file.\n")
+fc = 'f77'
+f77 = test.detect_tool(fc)
-
-
-g77 = test.detect('F77', 'g77')
-
-if g77:
+if f77:
test.write("wrapper.py",
"""import os
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = 'g2c')
+foo = Environment(SHF77 = '%(fc)s')
shf77 = foo.Dictionary('SHF77')
-bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77)
+bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77, tools = ['default', 'f77'], F77FILESUFFIXES = ['.f'])
foo.SharedObject(target = 'foo/foo', source = 'foo.f')
bar.SharedObject(target = 'bar/bar', source = 'bar.f')
""" % locals())
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar')
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar', stderr = None)
+ else:
+ test.run(arguments = 'bar')
test.must_match('wrapper.out', "wrapper.py\n")
_python_ = TestSCons._python_
_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
env.SharedObject(target = 'test08', source = 'test08.FPP')
env.SharedObject(target = 'test09', source = 'test09.f77')
env.SharedObject(target = 'test10', source = 'test10.F77')
-env.SharedObject(target = 'test11', source = 'test11.f90')
-env.SharedObject(target = 'test12', source = 'test12.F90')
-env.SharedObject(target = 'test13', source = 'test13.f95')
-env.SharedObject(target = 'test14', source = 'test14.F95')
-env2 = Environment(SHF77COM = r'%(_python_)s myfortran.py f77 $TARGET $SOURCES',
- SHF77PPCOM = r'%(_python_)s myfortran.py f77pp $TARGET $SOURCES')
-env2.SharedObject(target = 'test21', source = 'test21.f')
-env2.SharedObject(target = 'test22', source = 'test22.F')
-env2.SharedObject(target = 'test23', source = 'test23.for')
-env2.SharedObject(target = 'test24', source = 'test24.FOR')
-env2.SharedObject(target = 'test25', source = 'test25.ftn')
-env2.SharedObject(target = 'test26', source = 'test26.FTN')
-env2.SharedObject(target = 'test27', source = 'test27.fpp')
-env2.SharedObject(target = 'test28', source = 'test28.FPP')
-env2.SharedObject(target = 'test29', source = 'test29.f77')
-env2.SharedObject(target = 'test30', source = 'test30.F77')
""" % locals())
test.write('test01.f', "This is a .f file.\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n")
test.write('test09.f77', "This is a .f77 file.\n#f77\n")
test.write('test10.F77', "This is a .F77 file.\n#f77pp\n")
-test.write('test11.f90', "This is a .f90 file.\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#fortranpp\n")
-test.write('test13.f95', "This is a .f95 file.\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#fortranpp\n")
-
-test.write('test21.f', "This is a .f file.\n#f77\n")
-test.write('test22.F', "This is a .F file.\n#f77pp\n")
-test.write('test23.for', "This is a .for file.\n#f77\n")
-test.write('test24.FOR', "This is a .FOR file.\n#f77pp\n")
-test.write('test25.ftn', "This is a .ftn file.\n#f77\n")
-test.write('test26.FTN', "This is a .FTN file.\n#f77pp\n")
-test.write('test27.fpp', "This is a .fpp file.\n#f77pp\n")
-test.write('test28.FPP', "This is a .FPP file.\n#f77pp\n")
-test.write('test29.f77', "This is a .f77 file.\n#f77\n")
-test.write('test30.F77', "This is a .F77 file.\n#f77pp\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, "This is a .f file.\n")
-test.must_match('test02' + _obj, "This is a .F file.\n")
-test.must_match('test03' + _obj, "This is a .for file.\n")
-test.must_match('test04' + _obj, "This is a .FOR file.\n")
-test.must_match('test05' + _obj, "This is a .ftn file.\n")
-test.must_match('test06' + _obj, "This is a .FTN file.\n")
-test.must_match('test07' + _obj, "This is a .fpp file.\n")
-test.must_match('test08' + _obj, "This is a .FPP file.\n")
-test.must_match('test09' + _obj, "This is a .f77 file.\n")
-test.must_match('test10' + _obj, "This is a .F77 file.\n")
-test.must_match('test11' + _obj, "This is a .f90 file.\n")
-test.must_match('test12' + _obj, "This is a .F90 file.\n")
-test.must_match('test13' + _obj, "This is a .f95 file.\n")
-test.must_match('test14' + _obj, "This is a .F95 file.\n")
-
-test.must_match('test21' + _obj, "This is a .f file.\n")
-test.must_match('test22' + _obj, "This is a .F file.\n")
-test.must_match('test23' + _obj, "This is a .for file.\n")
-test.must_match('test24' + _obj, "This is a .FOR file.\n")
-test.must_match('test25' + _obj, "This is a .ftn file.\n")
-test.must_match('test26' + _obj, "This is a .FTN file.\n")
-test.must_match('test27' + _obj, "This is a .fpp file.\n")
-test.must_match('test28' + _obj, "This is a .FPP file.\n")
-test.must_match('test29' + _obj, "This is a .f77 file.\n")
-test.must_match('test30' + _obj, "This is a .F77 file.\n")
+test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n")
+test.must_match(obj_ + 'test09' + _obj, "This is a .f77 file.\n")
+test.must_match(obj_ + 'test10' + _obj, "This is a .F77 file.\n")
test.pass_test()
SHF77PPCOM = r'%(_python_)s myfc.py f77pp $TARGET $SOURCES',
SHF77PPCOMSTR = 'Building f77pp $TARGET from $SOURCES',
SHOBJPREFIX='', SHOBJSUFFIX='.shobj')
-env.SharedObject(source = 'test01.f')
-env.SharedObject(source = 'test02.F')
-env.SharedObject(source = 'test03.for')
-env.SharedObject(source = 'test04.FOR')
-env.SharedObject(source = 'test05.ftn')
-env.SharedObject(source = 'test06.FTN')
-env.SharedObject(source = 'test07.fpp')
-env.SharedObject(source = 'test08.FPP')
env.SharedObject(source = 'test09.f77')
env.SharedObject(source = 'test10.F77')
""" % locals())
test.write('test10.F77', "A .F77 file.\n#%s\n" % f77pp)
test.run(stdout = test.wrap_stdout("""\
-Building f77 test01.shobj from test01.f
-Building %(f77pp)s test02.shobj from test02.F
-Building f77 test03.shobj from test03.for
-Building %(f77pp)s test04.shobj from test04.FOR
-Building f77 test05.shobj from test05.ftn
-Building %(f77pp)s test06.shobj from test06.FTN
-Building f77pp test07.shobj from test07.fpp
-Building f77pp test08.shobj from test08.FPP
Building f77 test09.shobj from test09.f77
Building %(f77pp)s test10.shobj from test10.F77
""" % locals()))
-test.must_match('test01.shobj', "A .f file.\n")
-test.must_match('test02.shobj', "A .F file.\n")
-test.must_match('test03.shobj', "A .for file.\n")
-test.must_match('test04.shobj', "A .FOR file.\n")
-test.must_match('test05.shobj', "A .ftn file.\n")
-test.must_match('test06.shobj', "A .FTN file.\n")
-test.must_match('test07.shobj', "A .fpp file.\n")
-test.must_match('test08.shobj', "A .FPP file.\n")
test.must_match('test09.shobj', "A .f77 file.\n")
test.must_match('test10.shobj', "A .F77 file.\n")
_python_ = TestSCons._python_
-if sys.platform == 'win32':
- _obj = '.obj'
-else:
- if string.find(sys.platform, 'irix') > -1:
- _obj = '.o'
- else:
- _obj = '.os'
+_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
test.write('myg77.py', r"""
import getopt
import sys
-opts, args = getopt.getopt(sys.argv[1:], 'co:x')
+opts, args = getopt.getopt(sys.argv[1:], 'cf:o:x')
optstring = ''
for opt, arg in opts:
if opt == '-o': out = arg
- else: optstring = optstring + ' ' + opt
+ elif opt != '-f': optstring = optstring + ' ' + opt
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
outfile.write(optstring + "\n")
test.write('SConstruct', """
-env = Environment(SHF77 = r'%(_python_)s myg77.py',
- SHF77FLAGS = '-x')
-env.SharedObject(target = 'test01', source = 'test01.f')
-env.SharedObject(target = 'test02', source = 'test02.F')
-env.SharedObject(target = 'test03', source = 'test03.for')
-env.SharedObject(target = 'test04', source = 'test04.FOR')
-env.SharedObject(target = 'test05', source = 'test05.ftn')
-env.SharedObject(target = 'test06', source = 'test06.FTN')
-env.SharedObject(target = 'test07', source = 'test07.fpp')
-env.SharedObject(target = 'test08', source = 'test08.FPP')
+env = Environment(SHF77 = r'%(_python_)s myg77.py')
+env.Append(SHF77FLAGS = '-x')
env.SharedObject(target = 'test09', source = 'test09.f77')
env.SharedObject(target = 'test10', source = 'test10.F77')
""" % locals())
-test.write('test01.f', "This is a .f file.\n#g77\n")
-test.write('test02.F', "This is a .F file.\n#g77\n")
-test.write('test03.for', "This is a .for file.\n#g77\n")
-test.write('test04.FOR', "This is a .FOR file.\n#g77\n")
-test.write('test05.ftn', "This is a .ftn file.\n#g77\n")
-test.write('test06.FTN', "This is a .FTN file.\n#g77\n")
-test.write('test07.fpp', "This is a .fpp file.\n#g77\n")
-test.write('test08.FPP', "This is a .FPP file.\n#g77\n")
test.write('test09.f77', "This is a .f77 file.\n#g77\n")
test.write('test10.F77', "This is a .F77 file.\n#g77\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, " -c -x\nThis is a .f file.\n")
-test.must_match('test02' + _obj, " -c -x\nThis is a .F file.\n")
-test.must_match('test03' + _obj, " -c -x\nThis is a .for file.\n")
-test.must_match('test04' + _obj, " -c -x\nThis is a .FOR file.\n")
-test.must_match('test05' + _obj, " -c -x\nThis is a .ftn file.\n")
-test.must_match('test06' + _obj, " -c -x\nThis is a .FTN file.\n")
-test.must_match('test07' + _obj, " -c -x\nThis is a .fpp file.\n")
-test.must_match('test08' + _obj, " -c -x\nThis is a .FPP file.\n")
-test.must_match('test09' + _obj, " -c -x\nThis is a .f77 file.\n")
-test.must_match('test10' + _obj, " -c -x\nThis is a .F77 file.\n")
-
+test.must_match(obj_ + 'test09' + _obj, " -c -x\nThis is a .f77 file.\n")
+test.must_match(obj_ + 'test10' + _obj, " -c -x\nThis is a .F77 file.\n")
-g77 = test.detect('F77', 'g77')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f77'
+g77 = test.detect_tool(fc)
if g77:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(SHF77 = '%(fc)s')
shf77 = foo.Dictionary('SHF77')
-bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77, SHF77FLAGS = '-Ix')
+bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77,
+ tools = ["default", 'f77'], F77FILESUFFIXES = [".f"])
+bar.Append(SHF77FLAGS = '-Ix')
foo.SharedLibrary(target = 'foo/foo', source = 'foo.f')
bar.SharedLibrary(target = 'bar/bar', source = 'bar.f')
""" % locals())
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar')
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar', stderr = None)
+ else:
+ test.run(arguments = 'bar')
test.must_match('wrapper.out', "wrapper.py\n")
_python_ = TestSCons._python_
_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
import getopt
import sys
comment = '#' + sys.argv[1]
-opts, args = getopt.getopt(sys.argv[2:], 'cf:o:')
+opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:')
for opt, arg in opts:
if opt == '-o': out = arg
infile = open(args[0], 'rb')
env.SharedObject(target = 'test06', source = 'test06.FTN')
env.SharedObject(target = 'test07', source = 'test07.fpp')
env.SharedObject(target = 'test08', source = 'test08.FPP')
-env.SharedObject(target = 'test09', source = 'test09.f77')
-env.SharedObject(target = 'test10', source = 'test10.F77')
env.SharedObject(target = 'test11', source = 'test11.f90')
env.SharedObject(target = 'test12', source = 'test12.F90')
-env.SharedObject(target = 'test13', source = 'test13.f95')
-env.SharedObject(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#fortran\n")
test.write('test06.FTN', "This is a .FTN file.\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#fortran\n")
test.write('test11.f90', "This is a .f90 file.\n#g90\n")
test.write('test12.F90', "This is a .F90 file.\n#g90\n")
-test.write('test13.f95', "This is a .f95 file.\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#fortran\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, "This is a .f file.\n")
-test.must_match('test02' + _obj, "This is a .F file.\n")
-test.must_match('test03' + _obj, "This is a .for file.\n")
-test.must_match('test04' + _obj, "This is a .FOR file.\n")
-test.must_match('test05' + _obj, "This is a .ftn file.\n")
-test.must_match('test06' + _obj, "This is a .FTN file.\n")
-test.must_match('test07' + _obj, "This is a .fpp file.\n")
-test.must_match('test08' + _obj, "This is a .FPP file.\n")
-test.must_match('test09' + _obj, "This is a .f77 file.\n")
-test.must_match('test10' + _obj, "This is a .F77 file.\n")
-test.must_match('test11' + _obj, "This is a .f90 file.\n")
-test.must_match('test12' + _obj, "This is a .F90 file.\n")
-test.must_match('test13' + _obj, "This is a .f95 file.\n")
-test.must_match('test14' + _obj, "This is a .F95 file.\n")
+test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n")
+test.must_match(obj_ + 'test11' + _obj, "This is a .f90 file.\n")
+test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n")
-
-g90 = test.detect('F90', 'g90')
+fc = 'f90'
+g90 = test.detect_tool(fc)
if g90:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = 'g2c')
+foo = Environment(SHF90 = '%(fc)s')
shf90 = foo.Dictionary('SHF90')
bar = foo.Clone(SHF90 = r'%(_python_)s wrapper.py ' + shf90)
-foo.SharedObject(target = 'foo/foo', source = 'foo.f')
-bar.SharedObject(target = 'bar/bar', source = 'bar.f')
+foo.SharedObject(target = 'foo/foo', source = 'foo.f90')
+bar.SharedObject(target = 'bar/bar', source = 'bar.f90')
""" % locals())
- test.write('foo.f', r"""
+ test.write('foo.f90', r"""
PROGRAM FOO
- PRINT *,'foo.f'
+ PRINT *,'foo.f90'
STOP
END
""")
- test.write('bar.f', r"""
+ test.write('bar.f90', r"""
PROGRAM BAR
- PRINT *,'bar.f'
+ PRINT *,'bar.f90'
STOP
END
""")
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar')
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar', stderr = None)
+ else:
+ test.run(arguments = 'bar')
test.must_match('wrapper.out', "wrapper.py\n")
_python_ = TestSCons._python_
_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
env.SharedObject(target = 'test06', source = 'test06.FTN')
env.SharedObject(target = 'test07', source = 'test07.fpp')
env.SharedObject(target = 'test08', source = 'test08.FPP')
-env.SharedObject(target = 'test09', source = 'test09.f77')
-env.SharedObject(target = 'test10', source = 'test10.F77')
env.SharedObject(target = 'test11', source = 'test11.f90')
env.SharedObject(target = 'test12', source = 'test12.F90')
-env.SharedObject(target = 'test13', source = 'test13.f95')
-env.SharedObject(target = 'test14', source = 'test14.F95')
env2 = Environment(SHF90COM = r'%(_python_)s myfortran.py f90 $TARGET $SOURCES',
SHF90PPCOM = r'%(_python_)s myfortran.py f90pp $TARGET $SOURCES')
env2.SharedObject(target = 'test21', source = 'test21.f90')
test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n")
test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n")
-test.write('test09.f77', "This is a .f77 file.\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#fortranpp\n")
test.write('test11.f90', "This is a .f90 file.\n#f90\n")
test.write('test12.F90', "This is a .F90 file.\n#f90pp\n")
-test.write('test13.f95', "This is a .f95 file.\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#fortranpp\n")
test.write('test21.f90', "This is a .f90 file.\n#f90\n")
test.write('test22.F90', "This is a .F90 file.\n#f90pp\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, "This is a .f file.\n")
-test.must_match('test02' + _obj, "This is a .F file.\n")
-test.must_match('test03' + _obj, "This is a .for file.\n")
-test.must_match('test04' + _obj, "This is a .FOR file.\n")
-test.must_match('test05' + _obj, "This is a .ftn file.\n")
-test.must_match('test06' + _obj, "This is a .FTN file.\n")
-test.must_match('test07' + _obj, "This is a .fpp file.\n")
-test.must_match('test08' + _obj, "This is a .FPP file.\n")
-test.must_match('test09' + _obj, "This is a .f77 file.\n")
-test.must_match('test10' + _obj, "This is a .F77 file.\n")
-test.must_match('test11' + _obj, "This is a .f90 file.\n")
-test.must_match('test12' + _obj, "This is a .F90 file.\n")
-test.must_match('test13' + _obj, "This is a .f95 file.\n")
-test.must_match('test14' + _obj, "This is a .F95 file.\n")
-
-test.must_match('test21' + _obj, "This is a .f90 file.\n")
-test.must_match('test22' + _obj, "This is a .F90 file.\n")
+test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n")
+test.must_match(obj_ + 'test11' + _obj, "This is a .f90 file.\n")
+test.must_match(obj_ + 'test12' + _obj, "This is a .F90 file.\n")
+
+test.must_match(obj_ + 'test21' + _obj, "This is a .f90 file.\n")
+test.must_match(obj_ + 'test22' + _obj, "This is a .F90 file.\n")
test.pass_test()
_python_ = TestSCons._python_
-if sys.platform == 'win32':
- _obj = '.obj'
-else:
- if string.find(sys.platform, 'irix') > -1:
- _obj = '.o'
- else:
- _obj = '.os'
+_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
import getopt
import sys
comment = '#' + sys.argv[1]
-opts, args = getopt.getopt(sys.argv[2:], 'co:xy')
+opts, args = getopt.getopt(sys.argv[2:], 'cf:o:xy')
optstring = ''
for opt, arg in opts:
if opt == '-o': out = arg
- else: optstring = optstring + ' ' + opt
+ elif opt != '-f': optstring = optstring + ' ' + opt
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
outfile.write(optstring + "\n")
test.write('SConstruct', """
env = Environment(SHF90 = r'%(_python_)s myfortran.py g90',
- SHF90FLAGS = '-x',
- SHFORTRAN = r'%(_python_)s myfortran.py fortran',
- SHFORTRANFLAGS = '-y')
+ SHFORTRAN = r'%(_python_)s myfortran.py fortran')
+env.Append(SHF90FLAGS = '-x',
+ SHFORTRANFLAGS = '-y')
env.SharedObject(target = 'test01', source = 'test01.f')
env.SharedObject(target = 'test02', source = 'test02.F')
env.SharedObject(target = 'test03', source = 'test03.for')
env.SharedObject(target = 'test06', source = 'test06.FTN')
env.SharedObject(target = 'test07', source = 'test07.fpp')
env.SharedObject(target = 'test08', source = 'test08.FPP')
-env.SharedObject(target = 'test09', source = 'test09.f77')
-env.SharedObject(target = 'test10', source = 'test10.F77')
env.SharedObject(target = 'test11', source = 'test11.f90')
env.SharedObject(target = 'test12', source = 'test12.F90')
-env.SharedObject(target = 'test13', source = 'test13.f95')
-env.SharedObject(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#fortran\n")
test.write('test06.FTN', "This is a .FTN file.\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#fortran\n")
test.write('test11.f90', "This is a .f90 file.\n#g90\n")
test.write('test12.F90', "This is a .F90 file.\n#g90\n")
-test.write('test13.f95', "This is a .f95 file.\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#fortran\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, " -c -y\nThis is a .f file.\n")
-test.must_match('test02' + _obj, " -c -y\nThis is a .F file.\n")
-test.must_match('test03' + _obj, " -c -y\nThis is a .for file.\n")
-test.must_match('test04' + _obj, " -c -y\nThis is a .FOR file.\n")
-test.must_match('test05' + _obj, " -c -y\nThis is a .ftn file.\n")
-test.must_match('test06' + _obj, " -c -y\nThis is a .FTN file.\n")
-test.must_match('test07' + _obj, " -c -y\nThis is a .fpp file.\n")
-test.must_match('test08' + _obj, " -c -y\nThis is a .FPP file.\n")
-test.must_match('test09' + _obj, " -c -y\nThis is a .f77 file.\n")
-test.must_match('test10' + _obj, " -c -y\nThis is a .F77 file.\n")
-test.must_match('test11' + _obj, " -c -x\nThis is a .f90 file.\n")
-test.must_match('test12' + _obj, " -c -x\nThis is a .F90 file.\n")
-test.must_match('test13' + _obj, " -c -y\nThis is a .f95 file.\n")
-test.must_match('test14' + _obj, " -c -y\nThis is a .F95 file.\n")
-
+test.must_match(obj_ + 'test01' + _obj, " -c -y\nThis is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, " -c -y\nThis is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, " -c -y\nThis is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, " -c -y\nThis is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, " -c -y\nThis is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, " -c -y\nThis is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, " -c -y\nThis is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, " -c -y\nThis is a .FPP file.\n")
+test.must_match(obj_ + 'test11' + _obj, " -c -x\nThis is a .f90 file.\n")
+test.must_match(obj_ + 'test12' + _obj, " -c -x\nThis is a .F90 file.\n")
-
-g90 = test.detect('F90', 'g90')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f90'
+g90 = test.detect_tool(fc)
if g90:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(SHF90 = '%(fc)s')
shf90 = foo.Dictionary('SHF90')
-bar = foo.Clone(SHF90 = r'%(_python_)s wrapper.py ' + shf90, SHF90FLAGS = '-Ix')
-foo.SharedLibrary(target = 'foo/foo', source = 'foo.f')
-bar.SharedLibrary(target = 'bar/bar', source = 'bar.f')
+bar = foo.Clone(SHF90 = r'%(_python_)s wrapper.py ' + shf90)
+bar.Append(SHF90FLAGS = '-Ix')
+foo.SharedLibrary(target = 'foo/foo', source = 'foo.f90')
+bar.SharedLibrary(target = 'bar/bar', source = 'bar.f90')
""" % locals())
- test.write('foo.f', r"""
+ test.write('foo.f90', r"""
PROGRAM FOO
- PRINT *,'foo.f'
+ PRINT *,'foo.f90'
STOP
END
""")
- test.write('bar.f', r"""
+ test.write('bar.f90', r"""
PROGRAM BAR
- PRINT *,'bar.f'
+ PRINT *,'bar.f90'
STOP
END
""")
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar')
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar', stderr = None)
+ else:
+ test.run(arguments = 'bar')
test.must_match('wrapper.out', "wrapper.py\n")
_python_ = TestSCons._python_
_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
import getopt
import sys
comment = '#' + sys.argv[1]
-opts, args = getopt.getopt(sys.argv[2:], 'cf:o:')
+opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:')
for opt, arg in opts:
if opt == '-o': out = arg
infile = open(args[0], 'rb')
env.SharedObject(target = 'test06', source = 'test06.FTN')
env.SharedObject(target = 'test07', source = 'test07.fpp')
env.SharedObject(target = 'test08', source = 'test08.FPP')
-env.SharedObject(target = 'test09', source = 'test09.f77')
-env.SharedObject(target = 'test10', source = 'test10.F77')
-env.SharedObject(target = 'test11', source = 'test11.f90')
-env.SharedObject(target = 'test12', source = 'test12.F90')
env.SharedObject(target = 'test13', source = 'test13.f95')
env.SharedObject(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test06.FTN', "This is a .FTN file.\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#fortran\n")
-test.write('test11.f90', "This is a .f90 file.\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#fortran\n")
test.write('test13.f95', "This is a .f95 file.\n#g95\n")
test.write('test14.F95', "This is a .F95 file.\n#g95\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, "This is a .f file.\n")
-test.must_match('test02' + _obj, "This is a .F file.\n")
-test.must_match('test03' + _obj, "This is a .for file.\n")
-test.must_match('test04' + _obj, "This is a .FOR file.\n")
-test.must_match('test05' + _obj, "This is a .ftn file.\n")
-test.must_match('test06' + _obj, "This is a .FTN file.\n")
-test.must_match('test07' + _obj, "This is a .fpp file.\n")
-test.must_match('test08' + _obj, "This is a .FPP file.\n")
-test.must_match('test09' + _obj, "This is a .f77 file.\n")
-test.must_match('test10' + _obj, "This is a .F77 file.\n")
-test.must_match('test11' + _obj, "This is a .f90 file.\n")
-test.must_match('test12' + _obj, "This is a .F90 file.\n")
-test.must_match('test13' + _obj, "This is a .f95 file.\n")
-test.must_match('test14' + _obj, "This is a .F95 file.\n")
+test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n")
+test.must_match(obj_ + 'test13' + _obj, "This is a .f95 file.\n")
+test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n")
-
-
-g95 = test.detect('F95', 'g95')
+fc = 'f95'
+g95 = test.detect_tool(fc)
if g95:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = 'g2c')
+foo = Environment(SHF95 = '%(fc)s')
shf95 = foo.Dictionary('SHF95')
bar = foo.Clone(SHF95 = r'%(_python_)s wrapper.py ' + shf95)
-foo.SharedObject(target = 'foo/foo', source = 'foo.f')
-bar.SharedObject(target = 'bar/bar', source = 'bar.f')
+foo.SharedObject(target = 'foo/foo', source = 'foo.f95')
+bar.SharedObject(target = 'bar/bar', source = 'bar.f95')
""" % locals())
- test.write('foo.f', r"""
+ test.write('foo.f95', r"""
PROGRAM FOO
- PRINT *,'foo.f'
+ PRINT *,'foo.f95'
STOP
END
""")
- test.write('bar.f', r"""
+ test.write('bar.f95', r"""
PROGRAM BAR
- PRINT *,'bar.f'
+ PRINT *,'bar.f95'
STOP
END
""")
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar')
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar', stderr = None)
+ else:
+ test.run(arguments = 'bar')
test.must_match('wrapper.out', "wrapper.py\n")
_python_ = TestSCons._python_
_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
env.SharedObject(target = 'test06', source = 'test06.FTN')
env.SharedObject(target = 'test07', source = 'test07.fpp')
env.SharedObject(target = 'test08', source = 'test08.FPP')
-env.SharedObject(target = 'test09', source = 'test09.f77')
-env.SharedObject(target = 'test10', source = 'test10.F77')
-env.SharedObject(target = 'test11', source = 'test11.f90')
-env.SharedObject(target = 'test12', source = 'test12.F90')
env.SharedObject(target = 'test13', source = 'test13.f95')
env.SharedObject(target = 'test14', source = 'test14.F95')
env2 = Environment(SHF95COM = r'%(_python_)s myfortran.py f95 $TARGET $SOURCES',
test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n")
test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n")
-test.write('test09.f77', "This is a .f77 file.\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#fortranpp\n")
-test.write('test11.f90', "This is a .f90 file.\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#fortranpp\n")
test.write('test13.f95', "This is a .f95 file.\n#f95\n")
test.write('test14.F95', "This is a .F95 file.\n#f95pp\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, "This is a .f file.\n")
-test.must_match('test02' + _obj, "This is a .F file.\n")
-test.must_match('test03' + _obj, "This is a .for file.\n")
-test.must_match('test04' + _obj, "This is a .FOR file.\n")
-test.must_match('test05' + _obj, "This is a .ftn file.\n")
-test.must_match('test06' + _obj, "This is a .FTN file.\n")
-test.must_match('test07' + _obj, "This is a .fpp file.\n")
-test.must_match('test08' + _obj, "This is a .FPP file.\n")
-test.must_match('test09' + _obj, "This is a .f77 file.\n")
-test.must_match('test10' + _obj, "This is a .F77 file.\n")
-test.must_match('test11' + _obj, "This is a .f90 file.\n")
-test.must_match('test12' + _obj, "This is a .F90 file.\n")
-test.must_match('test13' + _obj, "This is a .f95 file.\n")
-test.must_match('test14' + _obj, "This is a .F95 file.\n")
-
-test.must_match('test21' + _obj, "This is a .f95 file.\n")
-test.must_match('test22' + _obj, "This is a .F95 file.\n")
+test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n")
+test.must_match(obj_ + 'test13' + _obj, "This is a .f95 file.\n")
+test.must_match(obj_ + 'test14' + _obj, "This is a .F95 file.\n")
+
+test.must_match(obj_ + 'test21' + _obj, "This is a .f95 file.\n")
+test.must_match(obj_ + 'test22' + _obj, "This is a .F95 file.\n")
test.pass_test()
_python_ = TestSCons._python_
-if sys.platform == 'win32':
- _obj = '.obj'
-else:
- if string.find(sys.platform, 'irix') > -1:
- _obj = '.o'
- else:
- _obj = '.os'
+_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
import getopt
import sys
comment = '#' + sys.argv[1]
-opts, args = getopt.getopt(sys.argv[2:], 'co:xy')
+opts, args = getopt.getopt(sys.argv[2:], 'cf:o:xy')
optstring = ''
for opt, arg in opts:
if opt == '-o': out = arg
- else: optstring = optstring + ' ' + opt
+ elif opt != '-f': optstring = optstring + ' ' + opt
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
outfile.write(optstring + "\n")
test.write('SConstruct', """
env = Environment(SHF95 = r'%(_python_)s myfortran.py g95',
- SHF95FLAGS = '-x',
- SHFORTRAN = r'%(_python_)s myfortran.py fortran',
- SHFORTRANFLAGS = '-y')
+ SHFORTRAN = r'%(_python_)s myfortran.py fortran')
+env.Append(SHF95FLAGS = '-x',
+ SHFORTRANFLAGS = '-y')
env.SharedObject(target = 'test01', source = 'test01.f')
env.SharedObject(target = 'test02', source = 'test02.F')
env.SharedObject(target = 'test03', source = 'test03.for')
env.SharedObject(target = 'test06', source = 'test06.FTN')
env.SharedObject(target = 'test07', source = 'test07.fpp')
env.SharedObject(target = 'test08', source = 'test08.FPP')
-env.SharedObject(target = 'test09', source = 'test09.f77')
-env.SharedObject(target = 'test10', source = 'test10.F77')
-env.SharedObject(target = 'test11', source = 'test11.f90')
-env.SharedObject(target = 'test12', source = 'test12.F90')
env.SharedObject(target = 'test13', source = 'test13.f95')
env.SharedObject(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test06.FTN', "This is a .FTN file.\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#fortran\n")
-test.write('test11.f90', "This is a .f90 file.\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#fortran\n")
test.write('test13.f95', "This is a .f95 file.\n#g95\n")
test.write('test14.F95', "This is a .F95 file.\n#g95\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, " -c -y\nThis is a .f file.\n")
-test.must_match('test02' + _obj, " -c -y\nThis is a .F file.\n")
-test.must_match('test03' + _obj, " -c -y\nThis is a .for file.\n")
-test.must_match('test04' + _obj, " -c -y\nThis is a .FOR file.\n")
-test.must_match('test05' + _obj, " -c -y\nThis is a .ftn file.\n")
-test.must_match('test06' + _obj, " -c -y\nThis is a .FTN file.\n")
-test.must_match('test07' + _obj, " -c -y\nThis is a .fpp file.\n")
-test.must_match('test08' + _obj, " -c -y\nThis is a .FPP file.\n")
-test.must_match('test09' + _obj, " -c -y\nThis is a .f77 file.\n")
-test.must_match('test10' + _obj, " -c -y\nThis is a .F77 file.\n")
-test.must_match('test11' + _obj, " -c -y\nThis is a .f90 file.\n")
-test.must_match('test12' + _obj, " -c -y\nThis is a .F90 file.\n")
-test.must_match('test13' + _obj, " -c -x\nThis is a .f95 file.\n")
-test.must_match('test14' + _obj, " -c -x\nThis is a .F95 file.\n")
+test.must_match(obj_ + 'test01' + _obj, " -c -y\nThis is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, " -c -y\nThis is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, " -c -y\nThis is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, " -c -y\nThis is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, " -c -y\nThis is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, " -c -y\nThis is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, " -c -y\nThis is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, " -c -y\nThis is a .FPP file.\n")
+test.must_match(obj_ + 'test13' + _obj, " -c -x\nThis is a .f95 file.\n")
+test.must_match(obj_ + 'test14' + _obj, " -c -x\nThis is a .F95 file.\n")
-g95 = test.detect('F95', 'g95')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f95'
+g95 = test.detect_tool(fc)
if g95:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(SHF95 = '%(fc)s')
shf95 = foo.Dictionary('SHF95')
-bar = foo.Clone(SHF95 = r'%(_python_)s wrapper.py ' + shf95, SHF95FLAGS = '-Ix')
-foo.SharedLibrary(target = 'foo/foo', source = 'foo.f')
-bar.SharedLibrary(target = 'bar/bar', source = 'bar.f')
+bar = foo.Clone(SHF95 = r'%(_python_)s wrapper.py ' + shf95)
+bar.Append(SHF95FLAGS = '-Ix')
+foo.SharedLibrary(target = 'foo/foo', source = 'foo.f95')
+bar.SharedLibrary(target = 'bar/bar', source = 'bar.f95')
""" % locals())
- test.write('foo.f', r"""
+ test.write('foo.f95', r"""
PROGRAM FOO
- PRINT *,'foo.f'
+ PRINT *,'foo.f95'
STOP
END
""")
- test.write('bar.f', r"""
+ test.write('bar.f95', r"""
PROGRAM BAR
- PRINT *,'bar.f'
+ PRINT *,'bar.f95'
STOP
END
""")
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar')
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar', stderr = None)
+ else:
+ test.run(arguments = 'bar')
test.must_match('wrapper.out', "wrapper.py\n")
_python_ = TestSCons._python_
_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
test.write('myfortran.py', r"""
import getopt
import sys
-opts, args = getopt.getopt(sys.argv[1:], 'cf:o:')
+opts, args = getopt.getopt(sys.argv[1:], 'cf:o:K:')
for opt, arg in opts:
if opt == '-o': out = arg
infile = open(args[0], 'rb')
env.SharedObject(target = 'test06', source = 'test06.FTN')
env.SharedObject(target = 'test07', source = 'test07.fpp')
env.SharedObject(target = 'test08', source = 'test08.FPP')
-env.SharedObject(target = 'test09', source = 'test09.f77')
-env.SharedObject(target = 'test10', source = 'test10.F77')
-env.SharedObject(target = 'test11', source = 'test11.f90')
-env.SharedObject(target = 'test12', source = 'test12.F90')
-env.SharedObject(target = 'test13', source = 'test13.f95')
-env.SharedObject(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#fortran\n")
test.write('test06.FTN', "This is a .FTN file.\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#fortran\n")
-test.write('test11.f90', "This is a .f90 file.\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#fortran\n")
-test.write('test13.f95', "This is a .f95 file.\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#fortran\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, "This is a .f file.\n")
-test.must_match('test02' + _obj, "This is a .F file.\n")
-test.must_match('test03' + _obj, "This is a .for file.\n")
-test.must_match('test04' + _obj, "This is a .FOR file.\n")
-test.must_match('test05' + _obj, "This is a .ftn file.\n")
-test.must_match('test06' + _obj, "This is a .FTN file.\n")
-test.must_match('test07' + _obj, "This is a .fpp file.\n")
-test.must_match('test08' + _obj, "This is a .FPP file.\n")
-test.must_match('test09' + _obj, "This is a .f77 file.\n")
-test.must_match('test10' + _obj, "This is a .F77 file.\n")
-test.must_match('test11' + _obj, "This is a .f90 file.\n")
-test.must_match('test12' + _obj, "This is a .F90 file.\n")
-test.must_match('test13' + _obj, "This is a .f95 file.\n")
-test.must_match('test14' + _obj, "This is a .F95 file.\n")
+test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n")
-fortran = test.detect('FORTRAN', 'g77')
+fc = 'f77'
+fortran = test.detect_tool(fc)
if fortran:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = 'g2c')
+foo = Environment(SHFORTRAN = '%(fc)s')
shfortran = foo.Dictionary('SHFORTRAN')
bar = foo.Clone(SHFORTRAN = r'%(_python_)s wrapper.py ' + shfortran)
foo.SharedObject(target = 'foo/foo', source = 'foo.f')
test.run(arguments = 'foo', stderr = None)
- test.must_exist('wrapper.out')
+ test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar')
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar', stderr = None)
+ else:
+ test.run(arguments = 'bar')
test.must_match('wrapper.out', "wrapper.py\n")
_python_ = TestSCons._python_
_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
env.SharedObject(target = 'test06', source = 'test06.FTN')
env.SharedObject(target = 'test07', source = 'test07.fpp')
env.SharedObject(target = 'test08', source = 'test08.FPP')
-env.SharedObject(target = 'test09', source = 'test09.f77')
-env.SharedObject(target = 'test10', source = 'test10.F77')
-env.SharedObject(target = 'test11', source = 'test11.f90')
-env.SharedObject(target = 'test12', source = 'test12.F90')
-env.SharedObject(target = 'test13', source = 'test13.f95')
-env.SharedObject(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#fortran\n")
test.write('test06.FTN', "This is a .FTN file.\n#fortranpp\n")
test.write('test07.fpp', "This is a .fpp file.\n#fortranpp\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortranpp\n")
-test.write('test09.f77', "This is a .f77 file.\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#fortranpp\n")
-test.write('test11.f90', "This is a .f90 file.\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#fortranpp\n")
-test.write('test13.f95', "This is a .f95 file.\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#fortranpp\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, "This is a .f file.\n")
-test.must_match('test02' + _obj, "This is a .F file.\n")
-test.must_match('test03' + _obj, "This is a .for file.\n")
-test.must_match('test04' + _obj, "This is a .FOR file.\n")
-test.must_match('test05' + _obj, "This is a .ftn file.\n")
-test.must_match('test06' + _obj, "This is a .FTN file.\n")
-test.must_match('test07' + _obj, "This is a .fpp file.\n")
-test.must_match('test08' + _obj, "This is a .FPP file.\n")
-test.must_match('test09' + _obj, "This is a .f77 file.\n")
-test.must_match('test10' + _obj, "This is a .F77 file.\n")
-test.must_match('test11' + _obj, "This is a .f90 file.\n")
-test.must_match('test12' + _obj, "This is a .F90 file.\n")
-test.must_match('test13' + _obj, "This is a .f95 file.\n")
-test.must_match('test14' + _obj, "This is a .F95 file.\n")
+test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n")
test.pass_test()
env.SharedObject(source = 'test06.FTN')
env.SharedObject(source = 'test07.fpp')
env.SharedObject(source = 'test08.FPP')
-env.SharedObject(source = 'test09.f77')
-env.SharedObject(source = 'test10.F77')
-env.SharedObject(source = 'test11.f90')
-env.SharedObject(source = 'test12.F90')
-env.SharedObject(source = 'test13.f95')
-env.SharedObject(source = 'test14.F95')
""" % locals())
test.write('test01.f', "A .f file.\n#fortran\n")
test.write('test06.FTN', "A .FTN file.\n#%s\n" % fortranpp)
test.write('test07.fpp', "A .fpp file.\n#fortranpp\n")
test.write('test08.FPP', "A .FPP file.\n#fortranpp\n")
-test.write('test09.f77', "A .f77 file.\n#fortran\n")
-test.write('test10.F77', "A .F77 file.\n#%s\n" % fortranpp)
-test.write('test11.f90', "A .f90 file.\n#fortran\n")
-test.write('test12.F90', "A .F90 file.\n#%s\n" % fortranpp)
-test.write('test13.f95', "A .f95 file.\n#fortran\n")
-test.write('test14.F95', "A .F95 file.\n#%s\n" % fortranpp)
test.run(stdout = test.wrap_stdout("""\
Building fortran test01.shobj from test01.f
Building %(fortranpp)s test06.shobj from test06.FTN
Building fortranpp test07.shobj from test07.fpp
Building fortranpp test08.shobj from test08.FPP
-Building fortran test09.shobj from test09.f77
-Building %(fortranpp)s test10.shobj from test10.F77
-Building fortran test11.shobj from test11.f90
-Building %(fortranpp)s test12.shobj from test12.F90
-Building fortran test13.shobj from test13.f95
-Building %(fortranpp)s test14.shobj from test14.F95
""" % locals()))
test.must_match('test01.shobj', "A .f file.\n")
test.must_match('test06.shobj', "A .FTN file.\n")
test.must_match('test07.shobj', "A .fpp file.\n")
test.must_match('test08.shobj', "A .FPP file.\n")
-test.must_match('test09.shobj', "A .f77 file.\n")
-test.must_match('test10.shobj', "A .F77 file.\n")
-test.must_match('test11.shobj', "A .f90 file.\n")
-test.must_match('test12.shobj', "A .F90 file.\n")
-test.must_match('test13.shobj', "A .f95 file.\n")
-test.must_match('test14.shobj', "A .F95 file.\n")
test.pass_test()
import TestSCons
_python_ = TestSCons._python_
-
-if sys.platform == 'win32':
- _obj = '.obj'
-else:
- if string.find(sys.platform, 'irix') > -1:
- _obj = '.o'
- else:
- _obj = '.os'
+_obj = TestSCons._shobj
+obj_ = TestSCons.shobj_
test = TestSCons.TestSCons()
test.write('myfortran.py', r"""
import getopt
import sys
-opts, args = getopt.getopt(sys.argv[1:], 'co:x')
+opts, args = getopt.getopt(sys.argv[1:], 'cf:o:x')
optstring = ''
for opt, arg in opts:
if opt == '-o': out = arg
- else: optstring = optstring + ' ' + opt
+ elif opt != '-f': optstring = optstring + ' ' + opt
infile = open(args[0], 'rb')
outfile = open(out, 'wb')
outfile.write(optstring + "\n")
test.write('SConstruct', """
-env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py',
- SHFORTRANFLAGS = '-x')
+env = Environment(SHFORTRAN = r'%(_python_)s myfortran.py')
+env.Append(SHFORTRANFLAGS = '-x')
env.SharedObject(target = 'test01', source = 'test01.f')
env.SharedObject(target = 'test02', source = 'test02.F')
env.SharedObject(target = 'test03', source = 'test03.for')
env.SharedObject(target = 'test06', source = 'test06.FTN')
env.SharedObject(target = 'test07', source = 'test07.fpp')
env.SharedObject(target = 'test08', source = 'test08.FPP')
-env.SharedObject(target = 'test09', source = 'test09.f77')
-env.SharedObject(target = 'test10', source = 'test10.F77')
-env.SharedObject(target = 'test11', source = 'test11.f90')
-env.SharedObject(target = 'test12', source = 'test12.F90')
-env.SharedObject(target = 'test13', source = 'test13.f95')
-env.SharedObject(target = 'test14', source = 'test14.F95')
""" % locals())
test.write('test01.f', "This is a .f file.\n#fortran\n")
test.write('test06.FTN', "This is a .FTN file.\n#fortran\n")
test.write('test07.fpp', "This is a .fpp file.\n#fortran\n")
test.write('test08.FPP', "This is a .FPP file.\n#fortran\n")
-test.write('test09.f77', "This is a .f77 file.\n#fortran\n")
-test.write('test10.F77', "This is a .F77 file.\n#fortran\n")
-test.write('test11.f90', "This is a .f90 file.\n#fortran\n")
-test.write('test12.F90', "This is a .F90 file.\n#fortran\n")
-test.write('test13.f95', "This is a .f95 file.\n#fortran\n")
-test.write('test14.F95', "This is a .F95 file.\n#fortran\n")
test.run(arguments = '.', stderr = None)
-test.must_match('test01' + _obj, " -c -x\nThis is a .f file.\n")
-test.must_match('test02' + _obj, " -c -x\nThis is a .F file.\n")
-test.must_match('test03' + _obj, " -c -x\nThis is a .for file.\n")
-test.must_match('test04' + _obj, " -c -x\nThis is a .FOR file.\n")
-test.must_match('test05' + _obj, " -c -x\nThis is a .ftn file.\n")
-test.must_match('test06' + _obj, " -c -x\nThis is a .FTN file.\n")
-test.must_match('test07' + _obj, " -c -x\nThis is a .fpp file.\n")
-test.must_match('test08' + _obj, " -c -x\nThis is a .FPP file.\n")
-test.must_match('test09' + _obj, " -c -x\nThis is a .f77 file.\n")
-test.must_match('test10' + _obj, " -c -x\nThis is a .F77 file.\n")
-test.must_match('test11' + _obj, " -c -x\nThis is a .f90 file.\n")
-test.must_match('test12' + _obj, " -c -x\nThis is a .F90 file.\n")
-test.must_match('test13' + _obj, " -c -x\nThis is a .f95 file.\n")
-test.must_match('test14' + _obj, " -c -x\nThis is a .F95 file.\n")
-
+test.must_match(obj_ + 'test01' + _obj, " -c -x\nThis is a .f file.\n")
+test.must_match(obj_ + 'test02' + _obj, " -c -x\nThis is a .F file.\n")
+test.must_match(obj_ + 'test03' + _obj, " -c -x\nThis is a .for file.\n")
+test.must_match(obj_ + 'test04' + _obj, " -c -x\nThis is a .FOR file.\n")
+test.must_match(obj_ + 'test05' + _obj, " -c -x\nThis is a .ftn file.\n")
+test.must_match(obj_ + 'test06' + _obj, " -c -x\nThis is a .FTN file.\n")
+test.must_match(obj_ + 'test07' + _obj, " -c -x\nThis is a .fpp file.\n")
+test.must_match(obj_ + 'test08' + _obj, " -c -x\nThis is a .FPP file.\n")
-
-fortran = test.detect('FORTRAN', 'g77')
-FTN_LIB = TestSCons.fortran_lib
+fc = 'f77'
+fortran = test.detect_tool(fc)
if fortran:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = %(FTN_LIB)s)
+foo = Environment(SHFORTRAN = '%(fc)s')
shfortran = foo.Dictionary('SHFORTRAN')
-bar = foo.Clone(SHFORTRAN = r'%(_python_)s wrapper.py ' + shfortran,
- SHFORTRANFLAGS = '-Ix')
+bar = foo.Clone(SHFORTRAN = r'%(_python_)s wrapper.py ' + shfortran)
+bar.Append(SHFORTRANFLAGS = '-Ix')
foo.SharedLibrary(target = 'foo/foo', source = 'foo.f')
bar.SharedLibrary(target = 'bar/bar', source = 'bar.f')
""" % locals())
test.must_not_exist('wrapper.out')
- test.run(arguments = 'bar')
+ import sys
+ if sys.platform[:5] == 'sunos':
+ test.run(arguments = 'bar', stderr = None)
+ else:
+ test.run(arguments = 'bar')
test.must_match('wrapper.out', "wrapper.py\n")
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+
+"""This module implements common code to all fortran tests."""
+
+import sys
+
+def write_fake_link(t):
+ """Writes a mylink.py script to remove the link step for 'fake' (e.g.
+ non-compiled) tests."""
+ if sys.platform == 'win32':
+ t.write('mylink.py', r"""
+import string
+import sys
+args = sys.argv[1:]
+while args:
+ a = args[0]
+ if a[0] != '/':
+ break
+ args = args[1:]
+ if string.lower(a[:5]) == '/out:': out = a[5:]
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:5] != '#link':
+ outfile.write(l)
+sys.exit(0)
+ """)
+ else:
+ t.write('mylink.py', r"""
+import getopt
+import sys
+opts, args = getopt.getopt(sys.argv[1:], 'o:')
+for opt, arg in opts:
+ if opt == '-o': out = arg
+infile = open(args[0], 'rb')
+outfile = open(out, 'wb')
+for l in infile.readlines():
+ if l[:5] != '#link':
+ outfile.write(l)
+sys.exit(0)
+ """)
test.write('SConstruct', """\
env = Environment(FORTRANMODDIRPREFIX = '-M',
FORTRANMODDIR = 'modules',
- F90 = r'%(_python_)s myfortran.py f90',
FORTRAN = r'%(_python_)s myfortran.py fortran',
AR = 'myar.py',
ARCOM = r'%(_python_)s $AR $TARGET $SOURCES',
Import('env')
env['FORTRANMODDIR'] = 'build'
-sources = ['src/modfile.f90']
+sources = ['src/modfile.f']
objs = env.Object(sources)
Return("objs")
""")
-test.write(['subdir', 'src', 'modfile.f90'], """\
-#f90 comment
+test.write(['subdir', 'src', 'modfile.f'], """\
+#fortran comment
module somemodule
integer :: nothing