From fb16f07bac7dfd01c1d29fd5c12721ead1cc0624 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Wed, 11 Aug 2004 04:20:05 +0000 Subject: Fix handling of ${F77,F90,F95,FORTRAN}COM so they can be overridden properly. --- src/engine/SCons/Tool/cvf.py | 8 +- src/engine/SCons/Tool/f77.py | 53 +++++++----- src/engine/SCons/Tool/f90.py | 54 +++++++----- src/engine/SCons/Tool/f95.py | 55 +++++++----- src/engine/SCons/Tool/fortran.py | 35 +++++--- src/engine/SCons/Tool/ifl.py | 2 +- test/Fortran/F77COM.py | 177 +++++++++++++++++++++++++++++++++++++++ test/Fortran/F90COM.py | 153 +++++++++++++++++++++++++++++++++ test/Fortran/F95COM.py | 153 +++++++++++++++++++++++++++++++++ test/Fortran/FORTRANCOM.py | 139 ++++++++++++++++++++++++++++++ test/Fortran/SHF77COM.py | 139 ++++++++++++++++++++++++++++++ test/Fortran/SHF90COM.py | 115 +++++++++++++++++++++++++ test/Fortran/SHF95COM.py | 115 +++++++++++++++++++++++++ test/Fortran/SHFORTRANCOM.py | 103 +++++++++++++++++++++++ 14 files changed, 1222 insertions(+), 79 deletions(-) create mode 100644 test/Fortran/F77COM.py create mode 100644 test/Fortran/F90COM.py create mode 100644 test/Fortran/F95COM.py create mode 100644 test/Fortran/FORTRANCOM.py create mode 100644 test/Fortran/SHF77COM.py create mode 100644 test/Fortran/SHF90COM.py create mode 100644 test/Fortran/SHF95COM.py create mode 100644 test/Fortran/SHFORTRANCOM.py diff --git a/src/engine/SCons/Tool/cvf.py b/src/engine/SCons/Tool/cvf.py index 15db1da..2f70078 100644 --- a/src/engine/SCons/Tool/cvf.py +++ b/src/engine/SCons/Tool/cvf.py @@ -40,10 +40,10 @@ def generate(env): fortran.generate(env) env['FORTRAN'] = 'f90' - env['FORTRANCOM'] = '$FORTRAN $FORTRANFLAGS $_FORTRANMODODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}' - env['FORTRANPPCOM'] = '$FORTRAN $FORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANMODODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}' - env['SHFORTRANCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $_FORTRANMODODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}' - env['SHFORTRANPPCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANMODODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}' + env['FORTRANCOM'] = '$FORTRAN $FORTRANFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}' + env['FORTRANPPCOM'] = '$FORTRAN $FORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}' + env['SHFORTRANCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}' + env['SHFORTRANPPCOM'] = '$SHFORTRAN $SHFORTRANFLAGS $CPPFLAGS $_CPPDEFFLAGS $_FORTRANMODFLAG $_FORTRANINCFLAGS /compile_only ${SOURCES.win32} /object:${TARGET.win32}' env['OBJSUFFIX'] = '.obj' env['FORTRANMODDIR'] = '${TARGET.dir}' env['FORTRANMODDIRPREFIX'] = '/module:' diff --git a/src/engine/SCons/Tool/f77.py b/src/engine/SCons/Tool/f77.py index 0651585..e0473a1 100644 --- a/src/engine/SCons/Tool/f77.py +++ b/src/engine/SCons/Tool/f77.py @@ -42,12 +42,6 @@ import fortran compilers = ['f77'] # -F77Action = SCons.Action.Action("$F77COM") -ShF77Action = SCons.Action.Action("$SHF77COM") -F77PPAction = SCons.Action.Action("$F77PPCOM") -ShF77PPAction = SCons.Action.Action("$SHF77PPCOM") - -# F77Suffixes = ['.f77'] F77PPSuffixes = [] if SCons.Util.case_sensitive_suffixes('.f77', '.F77'): @@ -62,10 +56,24 @@ for suffix in F77Suffixes + F77PPSuffixes: SCons.Defaults.ObjSourceScan.add_scanner(suffix, F77Scan) # -F77Generator = fortran.VariableListGenerator('F77', 'FORTRAN', '_FORTRAND') -F77FlagsGenerator = fortran.VariableListGenerator('F77FLAGS', 'FORTRANFLAGS') -ShF77Generator = fortran.VariableListGenerator('SHF77', 'SHFORTRAN', 'F77', 'FORTRAN', '_FORTRAND') -ShF77FlagsGenerator = fortran.VariableListGenerator('SHF77FLAGS', 'SHFORTRANFLAGS') +fVLG = fortran.VariableListGenerator + +F77Generator = fVLG('F77', 'FORTRAN', '_FORTRAND') +F77FlagsGenerator = fVLG('F77FLAGS', 'FORTRANFLAGS') +F77CommandGenerator = fVLG('F77COM', 'FORTRANCOM', '_F77COMD') +F77PPCommandGenerator = fVLG('F77PPCOM', 'FORTRANPPCOM', '_F77PPCOMD') +ShF77Generator = fVLG('SHF77', 'SHFORTRAN', 'F77', 'FORTRAN', '_FORTRAND') +ShF77FlagsGenerator = fVLG('SHF77FLAGS', 'SHFORTRANFLAGS') +ShF77CommandGenerator = fVLG('SHF77COM', 'SHFORTRANCOM', '_SHF77COMD') +ShF77PPCommandGenerator = fVLG('SHF77PPCOM', 'SHFORTRANPPCOM', '_SHF77PPCOMD') + +del fVLG + +# +F77Action = SCons.Action.Action('$_F77COMG ') +F77PPAction = SCons.Action.Action('$_F77PPCOMG ') +ShF77Action = SCons.Action.Action('$_SHF77COMG ') +ShF77PPAction = SCons.Action.Action('$_SHF77PPCOMG ') def add_to_env(env): """Add Builders and construction variables for f77 to an Environment.""" @@ -76,27 +84,32 @@ def add_to_env(env): for suffix in F77Suffixes: static_obj.add_action(suffix, F77Action) shared_obj.add_action(suffix, ShF77Action) - static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) - shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) + 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, SCons.Defaults.StaticObjectEmitter) - shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) + static_obj.add_emitter(suffix, fortran.FortranEmitter) + shared_obj.add_emitter(suffix, fortran.ShFortranEmitter) - env['_F77G'] = F77Generator - env['_F77FLAGSG'] = F77FlagsGenerator - env['F77COM'] = '$_F77G $_F77FLAGSG $_F77INCFLAGS -c -o $TARGET $SOURCES' - env['F77PPCOM'] = '$_F77G $_F77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' + env['_F77G'] = F77Generator + env['_F77FLAGSG'] = F77FlagsGenerator + env['_F77COMG'] = F77CommandGenerator + env['_F77PPCOMG'] = F77PPCommandGenerator env['_SHF77G'] = ShF77Generator env['_SHF77FLAGSG'] = ShF77FlagsGenerator - env['SHF77COM'] = '$_SHF77G $_SHF77FLAGSG $_F77INCFLAGS -c -o $TARGET $SOURCES' - env['SHF77PPCOM'] = '$_SHF77G $_SHF77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' + env['_SHF77COMG'] = ShF77CommandGenerator + env['_SHF77PPCOMG'] = ShF77PPCommandGenerator env['_F77INCFLAGS'] = '$( ${_concat(INCPREFIX, F77PATH, INCSUFFIX, __env__, RDirs)} $)' + env['_F77COMD'] = '$_F77G $_F77FLAGSG $_F77INCFLAGS -c -o $TARGET $SOURCES' + env['_F77PPCOMD'] = '$_F77G $_F77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' + env['_SHF77COMD'] = '$_SHF77G $_SHF77FLAGSG $_F77INCFLAGS -c -o $TARGET $SOURCES' + env['_SHF77PPCOMD'] = '$_SHF77G $_SHF77FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F77INCFLAGS -c -o $TARGET $SOURCES' + def generate(env): fortran.add_to_env(env) diff --git a/src/engine/SCons/Tool/f90.py b/src/engine/SCons/Tool/f90.py index b00a76e..47be38f 100644 --- a/src/engine/SCons/Tool/f90.py +++ b/src/engine/SCons/Tool/f90.py @@ -42,12 +42,6 @@ import fortran compilers = ['f90'] # -F90Action = SCons.Action.Action("$F90COM") -ShF90Action = SCons.Action.Action("$SHF90COM") -F90PPAction = SCons.Action.Action("$F90PPCOM") -ShF90PPAction = SCons.Action.Action("$SHF90PPCOM") - -# F90Suffixes = ['.f90'] F90PPSuffixes = [] if SCons.Util.case_sensitive_suffixes('.f90', '.F90'): @@ -62,10 +56,24 @@ for suffix in F90Suffixes + F90PPSuffixes: SCons.Defaults.ObjSourceScan.add_scanner(suffix, F90Scan) # -F90Generator = fortran.VariableListGenerator('F90', 'FORTRAN', '_FORTRAND') -F90FlagsGenerator = fortran.VariableListGenerator('F90FLAGS', 'FORTRANFLAGS') -ShF90Generator = fortran.VariableListGenerator('SHF90', 'SHFORTRAN', 'F90', 'FORTRAN', '_FORTRAND') -ShF90FlagsGenerator = fortran.VariableListGenerator('SHF90FLAGS', 'SHFORTRANFLAGS') +fVLG = fortran.VariableListGenerator + +F90Generator = fVLG('F90', 'FORTRAN', '_FORTRAND') +F90FlagsGenerator = fVLG('F90FLAGS', 'FORTRANFLAGS') +F90CommandGenerator = fVLG('F90COM', 'FORTRANCOM', '_F90COMD') +F90PPCommandGenerator = fVLG('F90PPCOM', 'FORTRANPPCOM', '_F90PPCOMD') +ShF90Generator = fVLG('SHF90', 'SHFORTRAN', 'F90', 'FORTRAN', '_FORTRAND') +ShF90FlagsGenerator = fVLG('SHF90FLAGS', 'SHFORTRANFLAGS') +ShF90CommandGenerator = fVLG('SHF90COM', 'SHFORTRANCOM', '_SHF90COMD') +ShF90PPCommandGenerator = fVLG('SHF90PPCOM', 'SHFORTRANPPCOM', '_SHF90PPCOMD') + +del fVLG + +# +F90Action = SCons.Action.Action('$_F90COMG ') +F90PPAction = SCons.Action.Action('$_F90PPCOMG ') +ShF90Action = SCons.Action.Action('$_SHF90COMG ') +ShF90PPAction = SCons.Action.Action('$_SHF90PPCOMG ') def add_to_env(env): """Add Builders and construction variables for f90 to an Environment.""" @@ -76,32 +84,36 @@ def add_to_env(env): for suffix in F90Suffixes: static_obj.add_action(suffix, F90Action) shared_obj.add_action(suffix, ShF90Action) - static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) - shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) + 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, SCons.Defaults.StaticObjectEmitter) - shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) + static_obj.add_emitter(suffix, fortran.FortranEmitter) + shared_obj.add_emitter(suffix, fortran.ShFortranEmitter) - env['_F90G'] = F90Generator - env['_F90FLAGSG'] = F90FlagsGenerator - env['F90COM'] = '$_F90G $_F90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' - env['F90PPCOM'] = '$_F90G $_F90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_F90G'] = F90Generator + env['_F90FLAGSG'] = F90FlagsGenerator + env['_F90COMG'] = F90CommandGenerator + env['_F90PPCOMG'] = F90PPCommandGenerator env['_SHF90G'] = ShF90Generator env['_SHF90FLAGSG'] = ShF90FlagsGenerator - env['SHF90COM'] = '$_SHF90G $_SHF90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' - env['SHF90PPCOM'] = '$_SHF90G $_SHF90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_SHF90COMG'] = ShF90CommandGenerator + env['_SHF90PPCOMG'] = ShF90PPCommandGenerator env['_F90INCFLAGS'] = '$( ${_concat(INCPREFIX, F90PATH, INCSUFFIX, __env__, RDirs)} $)' + env['_F90COMD'] = '$_F90G $_F90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_F90PPCOMD'] = '$_F90G $_F90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_SHF90COMD'] = '$_SHF90G $_SHF90FLAGSG $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_SHF90PPCOMD'] = '$_SHF90G $_SHF90FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F90INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' def generate(env): fortran.add_to_env(env) add_to_env(env) - env['_FORTRAND'] = env.Detect(compilers) or 'f90' + env['_FORTRAND'] = env.Detect(compilers) or 'f90' def exists(env): return env.Detect(compilers) diff --git a/src/engine/SCons/Tool/f95.py b/src/engine/SCons/Tool/f95.py index 291c980..4f413a0 100644 --- a/src/engine/SCons/Tool/f95.py +++ b/src/engine/SCons/Tool/f95.py @@ -41,12 +41,6 @@ import fortran compilers = ['f95'] # -F95Action = SCons.Action.Action("$F95COM") -ShF95Action = SCons.Action.Action("$SHF95COM") -F95PPAction = SCons.Action.Action("$F95PPCOM") -ShF95PPAction = SCons.Action.Action("$SHF95PPCOM") - -# F95Suffixes = ['.f95'] F95PPSuffixes = [] if SCons.Util.case_sensitive_suffixes('.f95', '.F95'): @@ -61,10 +55,24 @@ for suffix in F95Suffixes + F95PPSuffixes: SCons.Defaults.ObjSourceScan.add_scanner(suffix, F95Scan) # -F95Generator = fortran.VariableListGenerator('F95', 'FORTRAN', '_FORTRAND') -F95FlagsGenerator = fortran.VariableListGenerator('F95FLAGS', 'FORTRANFLAGS') -ShF95Generator = fortran.VariableListGenerator('SHF95', 'SHFORTRAN', 'F95', 'FORTRAN', '_FORTRAND') -ShF95FlagsGenerator = fortran.VariableListGenerator('SHF95FLAGS', 'SHFORTRANFLAGS') +fVLG = fortran.VariableListGenerator + +F95Generator = fVLG('F95', 'FORTRAN', '_FORTRAND') +F95FlagsGenerator = fVLG('F95FLAGS', 'FORTRANFLAGS') +F95CommandGenerator = fVLG('F95COM', 'FORTRANCOM', '_F95COMD') +F95PPCommandGenerator = fVLG('F95PPCOM', 'FORTRANPPCOM', '_F95PPCOMD') +ShF95Generator = fVLG('SHF95', 'SHFORTRAN', 'F95', 'FORTRAN', '_FORTRAND') +ShF95FlagsGenerator = fVLG('SHF95FLAGS', 'SHFORTRANFLAGS') +ShF95CommandGenerator = fVLG('SHF95COM', 'SHFORTRANCOM', '_SHF95COMD') +ShF95PPCommandGenerator = fVLG('SHF95PPCOM', 'SHFORTRANPPCOM', '_SHF95PPCOMD') + +del fVLG + +# +F95Action = SCons.Action.Action('$_F95COMG ') +F95PPAction = SCons.Action.Action('$_F95PPCOMG ') +ShF95Action = SCons.Action.Action('$_SHF95COMG ') +ShF95PPAction = SCons.Action.Action('$_SHF95PPCOMG ') def add_to_env(env): """Add Builders and construction variables for f95 to an Environment.""" @@ -75,32 +83,37 @@ def add_to_env(env): for suffix in F95Suffixes: static_obj.add_action(suffix, F95Action) shared_obj.add_action(suffix, ShF95Action) - static_obj.add_emitter(suffix, SCons.Defaults.StaticObjectEmitter) - shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) + 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, SCons.Defaults.StaticObjectEmitter) - shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter) + static_obj.add_emitter(suffix, fortran.FortranEmitter) + shared_obj.add_emitter(suffix, fortran.ShFortranEmitter) - env['_F95G'] = F95Generator - env['_F95FLAGSG'] = F95FlagsGenerator - env['F95COM'] = '$_F95G $_F95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' - env['F95PPCOM'] = '$_F95G $_F95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_F95G'] = F95Generator + env['_F95FLAGSG'] = F95FlagsGenerator + env['_F95COMG'] = F95CommandGenerator + env['_F95PPCOMG'] = F95PPCommandGenerator env['_SHF95G'] = ShF95Generator env['_SHF95FLAGSG'] = ShF95FlagsGenerator - env['SHF95COM'] = '$_SHF95G $_SHF95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' - env['SHF95PPCOM'] = '$_SHF95G $_SHF95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_SHF95COMG'] = ShF95CommandGenerator + env['_SHF95PPCOMG'] = ShF95PPCommandGenerator env['_F95INCFLAGS'] = '$( ${_concat(INCPREFIX, F95PATH, INCSUFFIX, __env__, RDirs)} $)' + env['_F95COMD'] = '$_F95G $_F95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_F95PPCOMD'] = '$_F95G $_F95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_SHF95COMD'] = '$_SHF95G $_SHF95FLAGSG $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_SHF95PPCOMD'] = '$_SHF95G $_SHF95FLAGSG $CPPFLAGS $_CPPDEFFLAGS $_F95INCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + def generate(env): fortran.add_to_env(env) add_to_env(env) - env['_FORTRAND'] = env.Detect(compilers) or 'f95' + env['_FORTRAND'] = env.Detect(compilers) or 'f95' def exists(env): return env.Detect(compilers) diff --git a/src/engine/SCons/Tool/fortran.py b/src/engine/SCons/Tool/fortran.py index 5e2b5eb..42a597e 100644 --- a/src/engine/SCons/Tool/fortran.py +++ b/src/engine/SCons/Tool/fortran.py @@ -44,11 +44,6 @@ import SCons.Util compilers = ['f95', 'f90', 'f77'] -FortranAction = SCons.Action.Action("$FORTRANCOM") -ShFortranAction = SCons.Action.Action("$SHFORTRANCOM") -FortranPPAction = SCons.Action.Action("$FORTRANPPCOM") -ShFortranPPAction = SCons.Action.Action("$SHFORTRANPPCOM") - # # Not yet sure how to deal with fortran pre-processor functions. # Different compilers do this differently in modern fortran. Some still @@ -85,7 +80,7 @@ def _fortranEmitter(target, source, env): suffix = env.subst('$FORTRANMODSUFFIX') modules = map(lambda x, s=suffix: string.lower(x) + s, modules) for m in modules: - target.append(m) + target.append(env.fs.File(m)) return (target, source) def FortranEmitter(target, source, env): @@ -105,23 +100,34 @@ class VariableListGenerator: except KeyError: pass return '' +# FortranGenerator = VariableListGenerator('FORTRAN', 'F77', '_FORTRAND') FortranFlagsGenerator = VariableListGenerator('FORTRANFLAGS', 'F77FLAGS') +FortranCommandGenerator = VariableListGenerator('FORTRANCOM', 'F77COM', '_FORTRANCOMD') +FortranPPCommandGenerator = VariableListGenerator('FORTRANPPCOM', 'F77PPCOM', '_FORTRANPPCOMD') ShFortranGenerator = VariableListGenerator('SHFORTRAN', 'SHF77', 'FORTRAN', 'F77', '_FORTRAND') ShFortranFlagsGenerator = VariableListGenerator('SHFORTRANFLAGS', 'SHF77FLAGS') +ShFortranCommandGenerator = VariableListGenerator('SHFORTRANCOM', 'SHF77COM', '_SHFORTRANCOMD') +ShFortranPPCommandGenerator = VariableListGenerator('SHFORTRANPPCOM', 'SHF77PPCOM', '_SHFORTRANPPCOMD') + +# +FortranAction = SCons.Action.Action('$_FORTRANCOMG ') +FortranPPAction = SCons.Action.Action('$_FORTRANPPCOMG ') +ShFortranAction = SCons.Action.Action('$_SHFORTRANCOMG ') +ShFortranPPAction = SCons.Action.Action('$_SHFORTRANPPCOMG ') def add_to_env(env): """Add Builders and construction variables for Fortran to an Environment.""" - env['_FORTRANG'] = FortranGenerator - env['_FORTRANFLAGSG'] = FortranFlagsGenerator - env['FORTRANCOM'] = '$_FORTRANG $_FORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' - env['FORTRANPPCOM'] = '$_FORTRANG $_FORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_FORTRANG'] = FortranGenerator + env['_FORTRANFLAGSG'] = FortranFlagsGenerator + env['_FORTRANCOMG'] = FortranCommandGenerator + env['_FORTRANPPCOMG'] = FortranPPCommandGenerator env['_SHFORTRANG'] = ShFortranGenerator env['_SHFORTRANFLAGSG'] = ShFortranFlagsGenerator - env['SHFORTRANCOM'] = '$_SHFORTRANG $_SHFORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' - env['SHFORTRANPPCOM'] = '$_SHFORTRANG $_SHFORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_SHFORTRANCOMG'] = ShFortranCommandGenerator + env['_SHFORTRANPPCOMG'] = ShFortranPPCommandGenerator env['_FORTRANINCFLAGS'] = '$( ${_concat(INCPREFIX, FORTRANPATH, INCSUFFIX, __env__, RDirs)} $)' @@ -149,6 +155,11 @@ def add_to_env(env): static_obj.add_emitter(suffix, FortranEmitter) shared_obj.add_emitter(suffix, ShFortranEmitter) + env['_FORTRANCOMD'] = '$_FORTRANG $_FORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_FORTRANPPCOMD'] = '$_FORTRANG $_FORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_SHFORTRANCOMD'] = '$_SHFORTRANG $_SHFORTRANFLAGSG $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + env['_SHFORTRANPPCOMD'] = '$_SHFORTRANG $_SHFORTRANFLAGSG $CPPFLAGS $_CPPDEFFLAGS $_FORTRANINCFLAGS $_FORTRANMODFLAG -c -o $TARGET $SOURCES' + def generate(env): import f77 import f90 diff --git a/src/engine/SCons/Tool/ifl.py b/src/engine/SCons/Tool/ifl.py index 8d800e2..923e5ef 100644 --- a/src/engine/SCons/Tool/ifl.py +++ b/src/engine/SCons/Tool/ifl.py @@ -43,7 +43,7 @@ def generate(env): fortran.FortranSuffixes.extend(['.i90']) fortran.generate(env) - env['_FORTRAND'] = 'ifl' + env['FORTRAN'] = 'ifl' 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' diff --git a/test/Fortran/F77COM.py b/test/Fortran/F77COM.py new file mode 100644 index 0000000..53e0a31 --- /dev/null +++ b/test/Fortran/F77COM.py @@ -0,0 +1,177 @@ +#!/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 + +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) +""") + +test.write('myfortran.py', r""" +import sys +comment = '#' + sys.argv[1] +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LINK = r'%s mylink.py', + LINKFLAGS = [], + F77COM = r'%s myfortran.py f77 $TARGET $SOURCES', + F77PPCOM = r'%s myfortran.py f77pp $TARGET $SOURCES', + FORTRANCOM = r'%s myfortran.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%s myfortran.py fortranpp $TARGET $SOURCES') +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') +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'%s mylink.py', + LINKFLAGS = [], + F77COM = r'%s myfortran.py f77 $TARGET $SOURCES', + F77PPCOM = r'%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') +""" % (python, python, python, python, python, python, python, python)) + +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#fortranpp\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#fortranpp\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#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#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('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.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() diff --git a/test/Fortran/F90COM.py b/test/Fortran/F90COM.py new file mode 100644 index 0000000..da679a8 --- /dev/null +++ b/test/Fortran/F90COM.py @@ -0,0 +1,153 @@ +#!/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 + +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) +""") + +test.write('myfortran.py', r""" +import sys +comment = '#' + sys.argv[1] +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LINK = r'%s mylink.py', + LINKFLAGS = [], + F90COM = r'%s myfortran.py f90 $TARGET $SOURCES', + F90PPCOM = r'%s myfortran.py f90pp $TARGET $SOURCES', + FORTRANCOM = r'%s myfortran.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%s myfortran.py fortranpp $TARGET $SOURCES') +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') +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'%s mylink.py', + LINKFLAGS = [], + F90COM = r'%s myfortran.py f90 $TARGET $SOURCES', + F90PPCOM = r'%s myfortran.py f90pp $TARGET $SOURCES') +env2.Program(target = 'test21', source = 'test21.f90') +env2.Program(target = 'test22', source = 'test22.F90') +""" % (python, python, python, python, python, python, python, python)) + +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#fortranpp\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#fortranpp\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#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.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.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") + +test.pass_test() diff --git a/test/Fortran/F95COM.py b/test/Fortran/F95COM.py new file mode 100644 index 0000000..14c03e6 --- /dev/null +++ b/test/Fortran/F95COM.py @@ -0,0 +1,153 @@ +#!/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 + +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) +""") + +test.write('myfortran.py', r""" +import sys +comment = '#' + sys.argv[1] +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LINK = r'%s mylink.py', + LINKFLAGS = [], + F95COM = r'%s myfortran.py f95 $TARGET $SOURCES', + F95PPCOM = r'%s myfortran.py f95pp $TARGET $SOURCES', + FORTRANCOM = r'%s myfortran.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%s myfortran.py fortranpp $TARGET $SOURCES') +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') +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'%s mylink.py', + LINKFLAGS = [], + F95COM = r'%s myfortran.py f95 $TARGET $SOURCES', + F95PPCOM = r'%s myfortran.py f95pp $TARGET $SOURCES') +env2.Program(target = 'test21', source = 'test21.f95') +env2.Program(target = 'test22', source = 'test22.F95') +""" % (python, python, python, python, python, python, python, python)) + +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#fortranpp\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#fortranpp\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#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.write('test21.f95', "This is a .f95 file.\n#link\n#f95\n") +test.write('test22.F95', "This is a .F95 file.\n#link\n#f95pp\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.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 .f95 file.\n") +test.must_match('test22' + _exe, "This is a .F95 file.\n") + +test.pass_test() diff --git a/test/Fortran/FORTRANCOM.py b/test/Fortran/FORTRANCOM.py new file mode 100644 index 0000000..6fbaf8f --- /dev/null +++ b/test/Fortran/FORTRANCOM.py @@ -0,0 +1,139 @@ +#!/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 + +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) +""") + +test.write('myfortran.py', r""" +import sys +comment = '#' + sys.argv[1] +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LINK = r'%s mylink.py', + LINKFLAGS = [], + FORTRANCOM = r'%s myfortran.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%s myfortran.py fortranpp $TARGET $SOURCES') +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') +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') +""" % (python, python, python)) + +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#fortranpp\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#fortranpp\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#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('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.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() diff --git a/test/Fortran/SHF77COM.py b/test/Fortran/SHF77COM.py new file mode 100644 index 0000000..7501fbf --- /dev/null +++ b/test/Fortran/SHF77COM.py @@ -0,0 +1,139 @@ +#!/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 + +python = TestSCons.python +_obj = TestSCons._shobj + +test = TestSCons.TestSCons() + + + +test.write('myfortran.py', r""" +import sys +comment = '#' + sys.argv[1] +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + + + +test.write('SConstruct', """ +env = Environment(SHF77COM = r'%s myfortran.py f77 $TARGET $SOURCES', + SHF77PPCOM = r'%s myfortran.py f77pp $TARGET $SOURCES', + SHFORTRANCOM = r'%s myfortran.py fortran $TARGET $SOURCES', + SHFORTRANPPCOM = r'%s myfortran.py fortranpp $TARGET $SOURCES') +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.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'%s myfortran.py f77 $TARGET $SOURCES', + SHF77PPCOM = r'%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') +""" % (python, python, python, python, python, python)) + +test.write('test01.f', "This is a .f file.\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#fortranpp\n") +test.write('test03.for', "This is a .for file.\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#fortranpp\n") +test.write('test05.ftn', "This is a .ftn 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#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.pass_test() diff --git a/test/Fortran/SHF90COM.py b/test/Fortran/SHF90COM.py new file mode 100644 index 0000000..0ff8316 --- /dev/null +++ b/test/Fortran/SHF90COM.py @@ -0,0 +1,115 @@ +#!/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 + +python = TestSCons.python +_obj = TestSCons._shobj + +test = TestSCons.TestSCons() + + + +test.write('myfortran.py', r""" +import sys +comment = '#' + sys.argv[1] +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + + + +test.write('SConstruct', """ +env = Environment(SHF90COM = r'%s myfortran.py f90 $TARGET $SOURCES', + SHF90PPCOM = r'%s myfortran.py f90pp $TARGET $SOURCES', + SHFORTRANCOM = r'%s myfortran.py fortran $TARGET $SOURCES', + SHFORTRANPPCOM = r'%s myfortran.py fortranpp $TARGET $SOURCES') +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.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'%s myfortran.py f90 $TARGET $SOURCES', + SHF90PPCOM = r'%s myfortran.py f90pp $TARGET $SOURCES') +env2.SharedObject(target = 'test21', source = 'test21.f90') +env2.SharedObject(target = 'test22', source = 'test22.F90') +""" % (python, python, python, python, python, python)) + +test.write('test01.f', "This is a .f file.\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#fortranpp\n") +test.write('test03.for', "This is a .for file.\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#fortranpp\n") +test.write('test05.ftn', "This is a .ftn 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#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.pass_test() diff --git a/test/Fortran/SHF95COM.py b/test/Fortran/SHF95COM.py new file mode 100644 index 0000000..d335083 --- /dev/null +++ b/test/Fortran/SHF95COM.py @@ -0,0 +1,115 @@ +#!/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 + +python = TestSCons.python +_obj = TestSCons._shobj + +test = TestSCons.TestSCons() + + + +test.write('myfortran.py', r""" +import sys +comment = '#' + sys.argv[1] +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + + + +test.write('SConstruct', """ +env = Environment(SHF95COM = r'%s myfortran.py f95 $TARGET $SOURCES', + SHF95PPCOM = r'%s myfortran.py f95pp $TARGET $SOURCES', + SHFORTRANCOM = r'%s myfortran.py fortran $TARGET $SOURCES', + SHFORTRANPPCOM = r'%s myfortran.py fortranpp $TARGET $SOURCES') +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.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'%s myfortran.py f95 $TARGET $SOURCES', + SHF95PPCOM = r'%s myfortran.py f95pp $TARGET $SOURCES') +env2.SharedObject(target = 'test21', source = 'test21.f95') +env2.SharedObject(target = 'test22', source = 'test22.F95') +""" % (python, python, python, python, python, python)) + +test.write('test01.f', "This is a .f file.\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#fortranpp\n") +test.write('test03.for', "This is a .for file.\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#fortranpp\n") +test.write('test05.ftn', "This is a .ftn 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#f95\n") +test.write('test14.F95', "This is a .F95 file.\n#f95pp\n") + +test.write('test21.f95', "This is a .f95 file.\n#f95\n") +test.write('test22.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.pass_test() diff --git a/test/Fortran/SHFORTRANCOM.py b/test/Fortran/SHFORTRANCOM.py new file mode 100644 index 0000000..16d38a6 --- /dev/null +++ b/test/Fortran/SHFORTRANCOM.py @@ -0,0 +1,103 @@ +#!/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 + +python = TestSCons.python +_obj = TestSCons._shobj + +test = TestSCons.TestSCons() + + + +test.write('myfortran.py', r""" +import sys +comment = '#' + sys.argv[1] +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + + + +test.write('SConstruct', """ +env = Environment(SHFORTRANCOM = r'%s myfortran.py fortran $TARGET $SOURCES', + SHFORTRANPPCOM = r'%s myfortran.py fortranpp $TARGET $SOURCES') +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.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') +""" % (python, python)) + +test.write('test01.f', "This is a .f file.\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#fortranpp\n") +test.write('test03.for', "This is a .for file.\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#fortranpp\n") +test.write('test05.ftn', "This is a .ftn 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.pass_test() -- cgit v0.12