diff options
author | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2022-06-26 11:40:02 (GMT) |
---|---|---|
committer | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2022-06-26 11:40:02 (GMT) |
commit | 0b5f192428beb061d77d707d1e010c6119528a57 (patch) | |
tree | 4ca0a529e3369dbcdb46656f4eb85b57f2ed2df3 /SCons/Tool | |
parent | 607d719e44d58de52f261b95a6c7c8a4dfa5b225 (diff) | |
parent | 07dc10b25b6169c9fb7e16dd78de8bb9ea107be6 (diff) | |
download | SCons-0b5f192428beb061d77d707d1e010c6119528a57.zip SCons-0b5f192428beb061d77d707d1e010c6119528a57.tar.gz SCons-0b5f192428beb061d77d707d1e010c6119528a57.tar.bz2 |
Merge branch 'master' into jbrill-msvc-batchargs
Diffstat (limited to 'SCons/Tool')
-rw-r--r-- | SCons/Tool/FortranCommon.py | 178 | ||||
-rw-r--r-- | SCons/Tool/f03.xml | 5 | ||||
-rw-r--r-- | SCons/Tool/f08.xml | 5 | ||||
-rw-r--r-- | SCons/Tool/f77.xml | 7 | ||||
-rw-r--r-- | SCons/Tool/f90.xml | 5 | ||||
-rw-r--r-- | SCons/Tool/f95.xml | 5 | ||||
-rw-r--r-- | SCons/Tool/fortran.xml | 13 | ||||
-rw-r--r-- | SCons/Tool/g77.py | 2 | ||||
-rw-r--r-- | SCons/Tool/g77.xml | 27 | ||||
-rw-r--r-- | SCons/Tool/gfortran.py | 18 | ||||
-rw-r--r-- | SCons/Tool/gfortran.xml | 5 | ||||
-rw-r--r-- | SCons/Tool/ifl.py | 21 | ||||
-rw-r--r-- | SCons/Tool/ifort.py | 13 | ||||
-rw-r--r-- | SCons/Tool/lex.py | 15 |
14 files changed, 174 insertions, 145 deletions
diff --git a/SCons/Tool/FortranCommon.py b/SCons/Tool/FortranCommon.py index cad16b6..aff0f92 100644 --- a/SCons/Tool/FortranCommon.py +++ b/SCons/Tool/FortranCommon.py @@ -21,43 +21,48 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -""" - -Stuff for processing Fortran, common to all fortran dialects. - -""" +"""Routines for setting up Fortran, common to all dialects.""" import re import os.path +from typing import Tuple -import SCons.Action import SCons.Scanner.Fortran import SCons.Tool import SCons.Util +from SCons.Action import Action + +def isfortran(env, source) -> bool: + """Returns True if source has any fortran files in it. -def isfortran(env, source): - """Return 1 if any of code in source has fortran files in it, 0 - otherwise.""" + Only checks based on filename suffixes, does not examine code. + """ try: fsuffixes = env['FORTRANSUFFIXES'] except KeyError: # If no FORTRANSUFFIXES, no fortran tool, so there is no need to look # for fortran sources. - return 0 + return False if not source: # Source might be None for unusual cases like SConf. - return 0 + return False for s in source: if s.sources: ext = os.path.splitext(str(s.sources[0]))[1] if ext in fsuffixes: - return 1 - return 0 + return True + return False -def _fortranEmitter(target, source, env): +def _fortranEmitter(target, source, env) -> Tuple: + """Common code for Fortran emitter. + + Called by both the static and shared object emitters, + mainly to account for generated module files. + """ + node = source[0].rfile() if not node.exists() and not node.is_derived(): print("Could not locate " + str(node.name)) @@ -78,21 +83,29 @@ def _fortranEmitter(target, source, env): return (target, source) -def FortranEmitter(target, source, env): +def FortranEmitter(target, source, env) -> Tuple: import SCons.Defaults target, source = _fortranEmitter(target, source, env) return SCons.Defaults.StaticObjectEmitter(target, source, env) -def ShFortranEmitter(target, source, env): +def ShFortranEmitter(target, source, env) -> Tuple: import SCons.Defaults 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.""" +def ComputeFortranSuffixes(suffixes, ppsuffixes) -> None: + """Update the suffix lists to reflect the platform requirements. + + If upper-cased suffixes can be distinguished from lower, those are + added to *ppsuffixes*. If not, they are added to *suffixes*. + + Args: + suffixes (list): indicate regular Fortran source files + ppsuffixes (list): indicate Fortran source files that should be + be run through the pre-processor + """ assert len(suffixes) > 0 s = suffixes[0] sup = s.upper() @@ -102,31 +115,34 @@ def ComputeFortranSuffixes(suffixes, ppsuffixes): else: suffixes.extend(upper_suffixes) - -def CreateDialectActions(dialect): +def CreateDialectActions(dialect) -> Tuple[Action, Action, Action, Action]: """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) - + CompAction = Action(f'${dialect}COM ', cmdstr=f'${dialect}COMSTR') + CompPPAction = Action(f'${dialect}PPCOM ', cmdstr=f'${dialect}PPCOMSTR') + ShCompAction = Action(f'$SH{dialect}COM ', cmdstr=f'$SH{dialect}COMSTR') + ShCompPPAction = Action(f'$SH{dialect}PPCOM ', cmdstr=f'$SH{dialect}PPCOMSTR') return CompAction, CompPPAction, ShCompAction, ShCompPPAction -def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module=False): - """Add dialect specific construction variables.""" - ComputeFortranSuffixes(suffixes, ppsuffixes) +def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_mods=False) -> None: + """Add dialect specific construction variables. - fscan = SCons.Scanner.Fortran.FortranScan("%sPATH" % dialect) + Args: + dialect (str): dialect name + suffixes (list): suffixes associated with this dialect + ppsuffixes (list): suffixes using cpp associated with this dialect + support_mods (bool): whether this dialect supports modules + """ + ComputeFortranSuffixes(suffixes, ppsuffixes) + fscan = SCons.Scanner.Fortran.FortranScan(f"{dialect}PATH") for suffix in suffixes + ppsuffixes: SCons.Tool.SourceFileScanner.add_scanner(suffix, fscan) - env.AppendUnique(FORTRANSUFFIXES = suffixes + ppsuffixes) + env.AppendUnique(FORTRANSUFFIXES=suffixes + ppsuffixes) compaction, compppaction, shcompaction, shcompppaction = \ CreateDialectActions(dialect) - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) for suffix in suffixes: @@ -141,64 +157,60 @@ def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module=False): static_obj.add_emitter(suffix, FortranEmitter) shared_obj.add_emitter(suffix, ShFortranEmitter) - if '%sFLAGS' % dialect not in env: - env['%sFLAGS' % dialect] = SCons.Util.CLVar('') - - if 'SH%sFLAGS' % dialect not in env: - env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS' % dialect) + if f'{dialect}FLAGS' not in env: + env[f'{dialect}FLAGS'] = SCons.Util.CLVar('') + if f'SH{dialect}FLAGS' not in env: + env[f'SH{dialect}FLAGS'] = SCons.Util.CLVar(f'${dialect}FLAGS') # If a tool does not define fortran prefix/suffix for include path, use C ones - if 'INC%sPREFIX' % dialect not in env: - env['INC%sPREFIX' % dialect] = '$INCPREFIX' - - if 'INC%sSUFFIX' % dialect not in env: - env['INC%sSUFFIX' % dialect] = '$INCSUFFIX' - - env['_%sINCFLAGS' % dialect] = '${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}' % (dialect, dialect, dialect) - - if support_module: - 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) + if f'INC{dialect}PREFIX' not in env: + env[f'INC{dialect}PREFIX'] = '$INCPREFIX' + if f'INC{dialect}SUFFIX' not in env: + env[f'INC{dialect}SUFFIX'] = '$INCSUFFIX' + + env[f'_{dialect}INCFLAGS'] = f'${{_concat(INC{dialect}PREFIX, {dialect}PATH, INC{dialect}SUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}}' + + if support_mods: + env[f'{dialect}COM'] = f'${dialect} -o $TARGET -c $FORTRANCOMMONFLAGS ${dialect}FLAGS $_{dialect}INCFLAGS $_FORTRANMODFLAG $SOURCES' + env[f'{dialect}PPCOM'] = f'${dialect} -o $TARGET -c $FORTRANCOMMONFLAGS ${dialect}FLAGS $CPPFLAGS $_CPPDEFFLAGS $_{dialect}INCFLAGS $_FORTRANMODFLAG $SOURCES' + env[f'SH{dialect}COM'] = f'$SH{dialect} -o $TARGET -c $FORTRANCOMMONFLAGS $SH{dialect}FLAGS $_{dialect}INCFLAGS $_FORTRANMODFLAG $SOURCES' + env[f'SH{dialect}PPCOM'] = f'$SH{dialect} -o $TARGET -c $FORTRANCOMMONFLAGS $SH{dialect}FLAGS $CPPFLAGS $_CPPDEFFLAGS $_{dialect}INCFLAGS $_FORTRANMODFLAG $SOURCES' 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) + env[f'{dialect}COM'] = f'${dialect} -o $TARGET -c $FORTRANCOMMONFLAGS ${dialect}FLAGS $_{dialect}INCFLAGS $SOURCES' + env[f'{dialect}PPCOM'] = f'${dialect} -o $TARGET -c $FORTRANCOMMONFLAGS ${dialect}FLAGS $CPPFLAGS $_CPPDEFFLAGS $_{dialect}INCFLAGS $SOURCES' + env[f'SH{dialect}COM'] = f'$SH{dialect} -o $TARGET -c $FORTRANCOMMONFLAGS $SH{dialect}FLAGS $_{dialect}INCFLAGS $SOURCES' + env[f'SH{dialect}PPCOM'] = f'$SH{dialect} -o $TARGET -c $FORTRANCOMMONFLAGS $SH{dialect}FLAGS $CPPFLAGS $_CPPDEFFLAGS $_{dialect}INCFLAGS $SOURCES' + -def add_fortran_to_env(env): - """Add Builders and construction variables for Fortran to an Environment.""" +def add_fortran_to_env(env) -> None: + """Add Builders and construction variables for Fortran/generic.""" 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=True) + DialectAddToEnv(env, "FORTRAN", FortranSuffixes, FortranPPSuffixes, support_mods=True) + # Module support 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, TARGET, SOURCE)} $)' -def add_f77_to_env(env): - """Add Builders and construction variables for f77 to an Environment.""" +def add_f77_to_env(env) -> None: + """Add Builders and construction variables for f77 dialect.""" try: F77Suffixes = env['F77FILESUFFIXES'] except KeyError: F77Suffixes = ['.f77'] - #print("Adding %s to f77 suffixes" % F77Suffixes) try: F77PPSuffixes = env['F77PPFILESUFFIXES'] except KeyError: @@ -206,59 +218,50 @@ def add_f77_to_env(env): DialectAddToEnv(env, "F77", F77Suffixes, F77PPSuffixes) -def add_f90_to_env(env): - """Add Builders and construction variables for f90 to an Environment.""" +def add_f90_to_env(env) -> None: + """Add Builders and construction variables for f90 dialect.""" 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=True) - + DialectAddToEnv(env, "F90", F90Suffixes, F90PPSuffixes, support_mods=True) -def add_f95_to_env(env): - """Add Builders and construction variables for f95 to an Environment.""" +def add_f95_to_env(env) -> None: + """Add Builders and construction variables for f95 dialect.""" 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=True) - + DialectAddToEnv(env, "F95", F95Suffixes, F95PPSuffixes, support_mods=True) -def add_f03_to_env(env): - """Add Builders and construction variables for f03 to an Environment.""" +def add_f03_to_env(env) -> None: + """Add Builders and construction variables for f03 dialect.""" try: F03Suffixes = env['F03FILESUFFIXES'] except KeyError: F03Suffixes = ['.f03'] - #print("Adding %s to f95 suffixes" % F95Suffixes) try: F03PPSuffixes = env['F03PPFILESUFFIXES'] except KeyError: F03PPSuffixes = [] - DialectAddToEnv(env, "F03", F03Suffixes, F03PPSuffixes, - support_module=True) + DialectAddToEnv(env, "F03", F03Suffixes, F03PPSuffixes, support_mods=True) - -def add_f08_to_env(env): - """Add Builders and construction variables for f08 to an Environment.""" +def add_f08_to_env(env) -> None: + """Add Builders and construction variables for f08 dialect.""" try: F08Suffixes = env['F08FILESUFFIXES'] except KeyError: @@ -269,13 +272,10 @@ def add_f08_to_env(env): except KeyError: F08PPSuffixes = [] - DialectAddToEnv(env, "F08", F08Suffixes, F08PPSuffixes, - support_module=True) - + DialectAddToEnv(env, "F08", F08Suffixes, F08PPSuffixes, support_mods=True) -def add_all_to_env(env): - """Add builders and construction variables for all supported fortran - dialects.""" +def add_all_to_env(env) -> None: + """Add builders and construction variables for all supported dialects.""" add_fortran_to_env(env) add_f77_to_env(env) add_f90_to_env(env) diff --git a/SCons/Tool/f03.xml b/SCons/Tool/f03.xml index fc14ace..c989385 100644 --- a/SCons/Tool/f03.xml +++ b/SCons/Tool/f03.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- -__COPYRIGHT__ +Copyright The SCons Foundation This file is processed by the bin/SConsDoc.py module. See its __doc__ string for a discussion of the format. @@ -45,6 +45,7 @@ Set construction variables for generic POSIX Fortran 03 compilers. <item>F03PPCOMSTR</item> <item>SHF03COMSTR</item> <item>SHF03PPCOMSTR</item> +<item>FORTRANCOMMONFLAGS</item> </uses> </tool> @@ -271,7 +272,7 @@ Options that are passed to the Fortran 03 compiler to generated shared-library objects. You only need to set &cv-link-SHF03FLAGS; if you need to define specific user options for Fortran 03 files. -You should normally set the &cv-link-SHFORTRANFLAGS; variable, +You should normally set the &cv-link-FORTRANCOMMONFLAGS; variable, which specifies the user-specified options passed to the default Fortran compiler for all Fortran versions. diff --git a/SCons/Tool/f08.xml b/SCons/Tool/f08.xml index fa7f633..8f69b93 100644 --- a/SCons/Tool/f08.xml +++ b/SCons/Tool/f08.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- -__COPYRIGHT__ +Copyright The SCons Foundation This file is processed by the bin/SConsDoc.py module. See its __doc__ string for a discussion of the format. @@ -45,6 +45,7 @@ Set construction variables for generic POSIX Fortran 08 compilers. <item>F08PPCOMSTR</item> <item>SHF08COMSTR</item> <item>SHF08PPCOMSTR</item> +<item>FORTRANCOMMONFLAGS</item> </uses> </tool> @@ -271,7 +272,7 @@ Options that are passed to the Fortran 08 compiler to generated shared-library objects. You only need to set &cv-link-SHF08FLAGS; if you need to define specific user options for Fortran 08 files. -You should normally set the &cv-link-SHFORTRANFLAGS; variable, +You should normally set the &cv-link-FORTRANCOMMONFLAGS; variable, which specifies the user-specified options passed to the default Fortran compiler for all Fortran versions. diff --git a/SCons/Tool/f77.xml b/SCons/Tool/f77.xml index cade57f..f60d617 100644 --- a/SCons/Tool/f77.xml +++ b/SCons/Tool/f77.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- -__COPYRIGHT__ +Copyright The SCons Foundation This file is processed by the bin/SConsDoc.py module. See its __doc__ string for a discussion of the format. @@ -58,6 +58,9 @@ Set construction variables for generic POSIX Fortran 77 compilers. <item>SHF77PPCOMSTR</item> <item>SHFORTRANCOMSTR</item> <item>SHFORTRANPPCOMSTR</item> +<item>FORTRANFLAGS</item> +<item>FORTRANCOMMONFLAGS</item> +<item>SHFORTRANFLAGS</item> </uses> </tool> @@ -284,7 +287,7 @@ Options that are passed to the Fortran 77 compiler to generated shared-library objects. You only need to set &cv-link-SHF77FLAGS; if you need to define specific user options for Fortran 77 files. -You should normally set the &cv-link-SHFORTRANFLAGS; variable, +You should normally set the &cv-link-FORTRANCOMMONFLAGS; variable, which specifies the user-specified options passed to the default Fortran compiler for all Fortran versions. diff --git a/SCons/Tool/f90.xml b/SCons/Tool/f90.xml index 343aefe..ab76def 100644 --- a/SCons/Tool/f90.xml +++ b/SCons/Tool/f90.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- -__COPYRIGHT__ +Copyright The SCons Foundation This file is processed by the bin/SConsDoc.py module. See its __doc__ string for a discussion of the format. @@ -45,6 +45,7 @@ Set construction variables for generic POSIX Fortran 90 compilers. <item>F90PPCOMSTR</item> <item>SHF90COMSTR</item> <item>SHF90PPCOMSTR</item> +<item>FORTRANCOMMONFLAGS</item> </uses> </tool> @@ -270,7 +271,7 @@ Options that are passed to the Fortran 90 compiler to generated shared-library objects. You only need to set &cv-link-SHF90FLAGS; if you need to define specific user options for Fortran 90 files. -You should normally set the &cv-link-SHFORTRANFLAGS; variable, +You should normally set the &cv-link-FORTRANCOMMONFLAGS; variable, which specifies the user-specified options passed to the default Fortran compiler for all Fortran versions. diff --git a/SCons/Tool/f95.xml b/SCons/Tool/f95.xml index 3f38030..59cfd78 100644 --- a/SCons/Tool/f95.xml +++ b/SCons/Tool/f95.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- -__COPYRIGHT__ +Copyright The SCons Foundation This file is processed by the bin/SConsDoc.py module. See its __doc__ string for a discussion of the format. @@ -45,6 +45,7 @@ Set construction variables for generic POSIX Fortran 95 compilers. <item>F95PPCOMSTR</item> <item>SHF95COMSTR</item> <item>SHF95PPCOMSTR</item> +<item>FORTRANCOMMONFLAGS</item> </uses> </tool> @@ -271,7 +272,7 @@ Options that are passed to the Fortran 95 compiler to generated shared-library objects. You only need to set &cv-link-SHF95FLAGS; if you need to define specific user options for Fortran 95 files. -You should normally set the &cv-link-SHFORTRANFLAGS; variable, +You should normally set the &cv-link-FORTRANCOMMONFLAGS; variable, which specifies the user-specified options passed to the default Fortran compiler for all Fortran versions. diff --git a/SCons/Tool/fortran.xml b/SCons/Tool/fortran.xml index 4f0517b..5bb1bd2 100644 --- a/SCons/Tool/fortran.xml +++ b/SCons/Tool/fortran.xml @@ -102,7 +102,8 @@ FORTRAN dialect will be used. By default, this is <literal>['.fpp', '.FPP']</lit <cvar name="FORTRANFLAGS"> <summary> <para> -General user-specified options that are passed to the Fortran compiler. +General user-specified options for the FORTRAN dialect +that are passed to the Fortran compiler. Note that this variable does <emphasis>not</emphasis> contain @@ -117,6 +118,16 @@ for the variables that expand those options. </summary> </cvar> +<cvar name="FORTRANCOMMONFLAGS"> +<summary> +<para> +General user-specified options that are passed to the Fortran compiler. +Similar to &cv-link-FORTRANFLAGS;, +but this variable is applied to all dialects. +</para> +</summary> +</cvar> + <cvar name="_FORTRANINCFLAGS"> <summary> <para> diff --git a/SCons/Tool/g77.py b/SCons/Tool/g77.py index e61181e..aea419a 100644 --- a/SCons/Tool/g77.py +++ b/SCons/Tool/g77.py @@ -22,13 +22,11 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - Tool-specific initialization for g77. 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. - """ import SCons.Util diff --git a/SCons/Tool/g77.xml b/SCons/Tool/g77.xml index 40516ba..febfeb3 100644 --- a/SCons/Tool/g77.xml +++ b/SCons/Tool/g77.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- -__COPYRIGHT__ +Copyright The SCons Foundation This file is processed by the bin/SConsDoc.py module. See its __doc__ string for a discussion of the format. @@ -27,10 +27,31 @@ See its __doc__ string for a discussion of the format. <summary> <para> Set construction variables for the &g77; Fortran compiler. -Calls the &t-f77; Tool module -to set variables. </para> </summary> +<sets> +<item>F77</item> +<item>F77COM</item> +<item>F77PPCOM</item> +<item>F77FILESUFFIXES</item> +<item>F77PPFILESUFFIXES</item> +<item>FORTRAN</item> +<item>FORTRANCOM</item> +<item>FORTRANPPCOM</item> +<item>SHF77</item> +<item>SHF77COM</item> +<item>SHF77PPCOM</item> +<item>SHF77FLAGS</item> +<item>SHFORTRAN</item> +<item>SHFORTRANCOM</item> +<item>SHFORTRANPPCOM</item> +<item>SHFORTRANFLAGS</item> +</sets> +<uses> +<item>F77FLAGS</item> +<item>FORTRANFLAGS</item> +<item>FORTRANCOMMONFLAGS</item> +</uses> </tool> </sconsdoc> diff --git a/SCons/Tool/gfortran.py b/SCons/Tool/gfortran.py index c4ca295..3c7e8b5 100644 --- a/SCons/Tool/gfortran.py +++ b/SCons/Tool/gfortran.py @@ -22,17 +22,13 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - -Tool-specific initialization for gfortran, the GNU Fortran 95/Fortran -2003 compiler. +Tool-specific initialization for gfortran, the GNU Fortran 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. - """ - import SCons.Util from . import fortran @@ -44,15 +40,15 @@ def generate(env): fortran.generate(env) for dialect in ['F77', 'F90', 'FORTRAN', 'F95', 'F03', 'F08']: - env['%s' % dialect] = 'gfortran' - env['SH%s' % dialect] = '$%s' % dialect + env[f'{dialect}'] = 'gfortran' + env[f'SH{dialect}'] = f'${dialect}' if env['PLATFORM'] in ['cygwin', 'win32']: - env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS' % dialect) + env[f'SH{dialect}FLAGS'] = SCons.Util.CLVar(f'${dialect}FLAGS') else: - env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS -fPIC' % dialect) + env[f'SH{dialect}FLAGS'] = SCons.Util.CLVar(f'${dialect}FLAGS -fPIC') - env['INC%sPREFIX' % dialect] = "-I" - env['INC%sSUFFIX' % dialect] = "" + env[f'INC{dialect}PREFIX'] = "-I" + env[f'INC{dialect}SUFFIX'] = "" env['FORTRANMODDIRPREFIX'] = "-J" diff --git a/SCons/Tool/gfortran.xml b/SCons/Tool/gfortran.xml index b5bad1a..95458fc 100644 --- a/SCons/Tool/gfortran.xml +++ b/SCons/Tool/gfortran.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- -__COPYRIGHT__ +Copyright The SCons Foundation This file is processed by the bin/SConsDoc.py module. See its __doc__ string for a discussion of the format. @@ -26,7 +26,8 @@ See its __doc__ string for a discussion of the format. <tool name="gfortran"> <summary> <para> -Sets construction variables for the GNU F95/F2003 GNU compiler. +Sets construction variables for the GNU Fortran compiler. +Calls the &t-link-fortran; Tool module to set variables. </para> </summary> <sets> diff --git a/SCons/Tool/ifl.py b/SCons/Tool/ifl.py index 865d2ba..5746950 100644 --- a/SCons/Tool/ifl.py +++ b/SCons/Tool/ifl.py @@ -1,15 +1,6 @@ -"""SCons.Tool.ifl - -Tool-specific initialization for the Intel Fortran 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. - -""" - +# MIT License # -# __COPYRIGHT__ +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -29,9 +20,13 @@ selection method. # 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__" +"""Tool-specific initialization for the Intel Fortran 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. +""" import SCons.Defaults from SCons.Scanner.Fortran import FortranScan diff --git a/SCons/Tool/ifort.py b/SCons/Tool/ifort.py index c8a6035..bf39b7f 100644 --- a/SCons/Tool/ifort.py +++ b/SCons/Tool/ifort.py @@ -22,17 +22,14 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ - Tool-specific initialization for newer versions of the Intel Fortran Compiler for Linux/Windows (and possibly Mac OS X). 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. - """ - import SCons.Defaults from SCons.Scanner.Fortran import FortranScan from .FortranCommon import add_all_to_env @@ -61,18 +58,18 @@ def generate(env): fc = 'ifort' for dialect in ['F77', 'F90', 'FORTRAN', 'F95']: - env['%s' % dialect] = fc - env['SH%s' % dialect] = '$%s' % dialect + env[f'{dialect}'] = fc + env[f'SH{dialect}'] = f'${dialect}' if env['PLATFORM'] == 'posix': - env['SH%sFLAGS' % dialect] = SCons.Util.CLVar('$%sFLAGS -fPIC' % dialect) + env[f'SH{dialect}FLAGS'] = SCons.Util.CLVar(f'${dialect}FLAGS -fPIC') 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 dialect in ['F77', 'F90', 'FORTRAN', 'F95']: - for var in ['%sCOM' % dialect, '%sPPCOM' % dialect, - 'SH%sCOM' % dialect, 'SH%sPPCOM' % dialect]: + for var in [f'{dialect}COM', f'{dialect}PPCOM', + f'SH{dialect}COM', f'SH{dialect}PPCOM']: env[var] = env[var].replace('-o $TARGET', '-object:$TARGET') env['FORTRANMODDIRPREFIX'] = "/module:" else: diff --git a/SCons/Tool/lex.py b/SCons/Tool/lex.py index d8d8de4..96f9bcb 100644 --- a/SCons/Tool/lex.py +++ b/SCons/Tool/lex.py @@ -46,6 +46,7 @@ if sys.platform == 'win32': else: BINS = ["flex", "lex"] + def lexEmitter(target, source, env): sourceBase, sourceExt = os.path.splitext(SCons.Util.to_String(source[0])) @@ -56,18 +57,19 @@ def lexEmitter(target, source, env): # files generated by flex. # Different options that are used to trigger the creation of extra files. - fileGenOptions = ["--header-file=", "--tables-file="] + file_gen_options = ["--header-file=", "--tables-file="] - lexflags = env.subst("$LEXFLAGS", target=target, source=source) + lexflags = env.subst_list("$LEXFLAGS", target=target, source=source) for option in SCons.Util.CLVar(lexflags): - for fileGenOption in fileGenOptions: + for fileGenOption in file_gen_options: l = len(fileGenOption) if option[:l] == fileGenOption: # A file generating option is present, so add the # file name to the target list. - fileName = option[l:].strip() - target.append(fileName) - return (target, source) + file_name = option[l:].strip() + target.append(file_name) + return target, source + def get_lex_path(env, append_paths=False): """ @@ -128,6 +130,7 @@ def generate(env): env["LEX"] = env.Detect(BINS) env["LEXCOM"] = "$LEX $LEXFLAGS -t $SOURCES > $TARGET" + def exists(env): if sys.platform == 'win32': return get_lex_path(env) |