<s> """<STR_LIT>""" <EOL> __revision__ = "<STR_LIT>" <EOL> import re <EOL> import os . path <EOL> import SCons . Action <EOL> import SCons . Defaults <EOL> import SCons . Scanner . Fortran <EOL> import SCons . Tool <EOL> import SCons . Util <EOL> def isfortran ( env , source ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> fsuffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> return <NUM_LIT:0> <EOL> if not source : <EOL> return <NUM_LIT:0> <EOL> for s in source : <EOL> if s . sources : <EOL> ext = os . path . splitext ( str ( s . sources [ <NUM_LIT:0> ] ) ) [ <NUM_LIT:1> ] <EOL> if ext in fsuffixes : <EOL> return <NUM_LIT:1> <EOL> return <NUM_LIT:0> <EOL> def _fortranEmitter ( target , source , env ) : <EOL> node = source [ <NUM_LIT:0> ] . rfile ( ) <EOL> if not node . exists ( ) and not node . is_derived ( ) : <EOL> print "<STR_LIT>" + str ( node . name ) <EOL> return ( [ ] , [ ] ) <EOL> mod_regex = """<STR_LIT>""" <EOL> cre = re . compile ( mod_regex , re . M ) <EOL> modules = cre . findall ( node . get_text_contents ( ) ) <EOL> modules = SCons . Util . unique ( modules ) <EOL> suffix = env . subst ( '<STR_LIT>' , target = target , source = source ) <EOL> moddir = env . subst ( '<STR_LIT>' , target = target , source = source ) <EOL> modules = [ x . lower ( ) + suffix for x in modules ] <EOL> for m in modules : <EOL> target . append ( env . fs . File ( m , moddir ) ) <EOL> return ( target , source ) <EOL> def FortranEmitter ( target , source , env ) : <EOL> target , source = _fortranEmitter ( target , source , env ) <EOL> return SCons . Defaults . StaticObjectEmitter ( target , source , env ) <EOL> def ShFortranEmitter ( target , source , env ) : <EOL> target , source = _fortranEmitter ( target , source , env ) <EOL> return SCons . Defaults . SharedObjectEmitter ( target , source , env ) <EOL> def ComputeFortranSuffixes ( suffixes , ppsuffixes ) : <EOL> """<STR_LIT>""" <EOL> assert len ( suffixes ) > <NUM_LIT:0> <EOL> s = suffixes [ <NUM_LIT:0> ] <EOL> sup = s . upper ( ) <EOL> upper_suffixes = [ _ . upper ( ) for _ in suffixes ] <EOL> if SCons . Util . case_sensitive_suffixes ( s , sup ) : <EOL> ppsuffixes . extend ( upper_suffixes ) <EOL> else : <EOL> suffixes . extend ( upper_suffixes ) <EOL> def CreateDialectActions ( dialect ) : <EOL> """<STR_LIT>""" <EOL> CompAction = SCons . Action . Action ( '<STR_LIT>' % dialect , '<STR_LIT>' % dialect ) <EOL> CompPPAction = SCons . Action . Action ( '<STR_LIT>' % dialect , '<STR_LIT>' % dialect ) <EOL> ShCompAction = SCons . Action . Action ( '<STR_LIT>' % dialect , '<STR_LIT>' % dialect ) <EOL> ShCompPPAction = SCons . Action . Action ( '<STR_LIT>' % dialect , '<STR_LIT>' % dialect ) <EOL> return CompAction , CompPPAction , ShCompAction , ShCompPPAction <EOL> def DialectAddToEnv ( env , dialect , suffixes , ppsuffixes , support_module = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> ComputeFortranSuffixes ( suffixes , ppsuffixes ) <EOL> fscan = SCons . Scanner . Fortran . FortranScan ( "<STR_LIT>" % dialect ) <EOL> for suffix in suffixes + ppsuffixes : <EOL> SCons . Tool . SourceFileScanner . add_scanner ( suffix , fscan ) <EOL> env . AppendUnique ( FORTRANSUFFIXES = suffixes + ppsuffixes ) <EOL> compaction , compppaction , shcompaction , shcompppaction = CreateDialectActions ( dialect ) <EOL> static_obj , shared_obj = SCons . Tool . createObjBuilders ( env ) <EOL> for suffix in suffixes : <EOL> static_obj . add_action ( suffix , compaction ) <EOL> shared_obj . add_action ( suffix , shcompaction ) <EOL> static_obj . add_emitter ( suffix , FortranEmitter ) <EOL> shared_obj . add_emitter ( suffix , ShFortranEmitter ) <EOL> for suffix in ppsuffixes : <EOL> static_obj . add_action ( suffix , compppaction ) <EOL> shared_obj . add_action ( suffix , shcompppaction ) <EOL> static_obj . add_emitter ( suffix , FortranEmitter ) <EOL> shared_obj . add_emitter ( suffix , ShFortranEmitter ) <EOL> if '<STR_LIT>' % dialect not in env : <EOL> env [ '<STR_LIT>' % dialect ] = SCons . Util . CLVar ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' % dialect not in env : <EOL> env [ '<STR_LIT>' % dialect ] = SCons . Util . CLVar ( '<STR_LIT>' % dialect ) <EOL> if '<STR_LIT>' % dialect not in env : <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' <EOL> if '<STR_LIT>' % dialect not in env : <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' % ( dialect , dialect , dialect ) <EOL> if support_module == <NUM_LIT:1> : <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' % ( dialect , dialect , dialect ) <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' % ( dialect , dialect , dialect ) <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' % ( dialect , dialect , dialect ) <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' % ( dialect , dialect , dialect ) <EOL> else : <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' % ( dialect , dialect , dialect ) <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' % ( dialect , dialect , dialect ) <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' % ( dialect , dialect , dialect ) <EOL> env [ '<STR_LIT>' % dialect ] = '<STR_LIT>' % ( dialect , dialect , dialect ) <EOL> def add_fortran_to_env ( env ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> FortranSuffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> FortranSuffixes = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> try : <EOL> FortranPPSuffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> FortranPPSuffixes = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> DialectAddToEnv ( env , "<STR_LIT>" , FortranSuffixes , <EOL> FortranPPSuffixes , support_module = <NUM_LIT:1> ) <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> def add_f77_to_env ( env ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> F77Suffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> F77Suffixes = [ '<STR_LIT>' ] <EOL> try : <EOL> F77PPSuffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> F77PPSuffixes = [ ] <EOL> DialectAddToEnv ( env , "<STR_LIT>" , F77Suffixes , F77PPSuffixes ) <EOL> def add_f90_to_env ( env ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> F90Suffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> F90Suffixes = [ '<STR_LIT>' ] <EOL> try : <EOL> F90PPSuffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> F90PPSuffixes = [ ] <EOL> DialectAddToEnv ( env , "<STR_LIT>" , F90Suffixes , F90PPSuffixes , <EOL> support_module = <NUM_LIT:1> ) <EOL> def add_f95_to_env ( env ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> F95Suffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> F95Suffixes = [ '<STR_LIT>' ] <EOL> try : <EOL> F95PPSuffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> F95PPSuffixes = [ ] <EOL> DialectAddToEnv ( env , "<STR_LIT>" , F95Suffixes , F95PPSuffixes , <EOL> support_module = <NUM_LIT:1> ) <EOL> def add_f03_to_env ( env ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> F03Suffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> F03Suffixes = [ '<STR_LIT>' ] <EOL> try : <EOL> F03PPSuffixes = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> F03PPSuffixes = [ ] <EOL> DialectAddToEnv ( env , "<STR_LIT>" , F03Suffixes , F03PPSuffixes , <EOL> support_module = <NUM_LIT:1> ) <EOL> def add_all_to_env ( env ) : <EOL> """<STR_LIT>""" <EOL> add_fortran_to_env ( env ) <EOL> add_f77_to_env ( env ) <EOL> add_f90_to_env ( env ) <EOL> add_f95_to_env ( env ) <EOL> add_f03_to_env ( env ) </s>
