Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions SCons/Tool/FortranCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# 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.
"""SCons.Tool.FortranCommon

"""

Stuff for processing Fortran, common to all fortran dialects.

Expand Down Expand Up @@ -55,6 +56,7 @@ def isfortran(env, source):
return 1
return 0


def _fortranEmitter(target, source, env):
node = source[0].rfile()
if not node.exists() and not node.is_derived():
Expand All @@ -75,16 +77,19 @@ def _fortranEmitter(target, source, env):
target.append(env.fs.File(m, moddir))
return (target, source)


def FortranEmitter(target, source, env):
import SCons.Defaults
target, source = _fortranEmitter(target, source, env)
return SCons.Defaults.StaticObjectEmitter(target, source, env)


def ShFortranEmitter(target, source, env):
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."""
Expand All @@ -97,6 +102,7 @@ def ComputeFortranSuffixes(suffixes, ppsuffixes):
else:
suffixes.extend(upper_suffixes)


def CreateDialectActions(dialect):
"""Create dialect specific actions."""
CompAction = SCons.Action.Action('$%sCOM ' % dialect, '$%sCOMSTR' % dialect)
Expand All @@ -106,7 +112,8 @@ def CreateDialectActions(dialect):

return CompAction, CompPPAction, ShCompAction, ShCompPPAction

def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module = 0):

def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module=False):
"""Add dialect specific construction variables."""
ComputeFortranSuffixes(suffixes, ppsuffixes)

Expand Down Expand Up @@ -149,7 +156,7 @@ def DialectAddToEnv(env, dialect, suffixes, ppsuffixes, support_module = 0):

env['_%sINCFLAGS' % dialect] = '${_concat(INC%sPREFIX, %sPATH, INC%sSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}' % (dialect, dialect, dialect)

if support_module == 1:
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)
Expand All @@ -174,7 +181,7 @@ def add_fortran_to_env(env):
FortranPPSuffixes = ['.fpp', '.FPP']

DialectAddToEnv(env, "FORTRAN", FortranSuffixes,
FortranPPSuffixes, support_module = 1)
FortranPPSuffixes, support_module=True)

env['FORTRANMODPREFIX'] = '' # like $LIBPREFIX
env['FORTRANMODSUFFIX'] = '.mod' # like $LIBSUFFIX
Expand Down Expand Up @@ -213,7 +220,8 @@ def add_f90_to_env(env):
F90PPSuffixes = []

DialectAddToEnv(env, "F90", F90Suffixes, F90PPSuffixes,
support_module = 1)
support_module=True)


def add_f95_to_env(env):
"""Add Builders and construction variables for f95 to an Environment."""
Expand All @@ -229,7 +237,8 @@ def add_f95_to_env(env):
F95PPSuffixes = []

DialectAddToEnv(env, "F95", F95Suffixes, F95PPSuffixes,
support_module = 1)
support_module=True)


def add_f03_to_env(env):
"""Add Builders and construction variables for f03 to an Environment."""
Expand All @@ -245,7 +254,8 @@ def add_f03_to_env(env):
F03PPSuffixes = []

DialectAddToEnv(env, "F03", F03Suffixes, F03PPSuffixes,
support_module = 1)
support_module=True)


def add_f08_to_env(env):
"""Add Builders and construction variables for f08 to an Environment."""
Expand All @@ -260,7 +270,8 @@ def add_f08_to_env(env):
F08PPSuffixes = []

DialectAddToEnv(env, "F08", F08Suffixes, F08PPSuffixes,
support_module = 1)
support_module=True)


def add_all_to_env(env):
"""Add builders and construction variables for all supported fortran
Expand Down
2 changes: 2 additions & 0 deletions SCons/Tool/fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

compilers = ['f95', 'f90', 'f77']


def generate(env):
add_all_to_env(env)
add_fortran_to_env(env)
Expand All @@ -41,6 +42,7 @@ def generate(env):
if 'SHFORTRAN' not in env:
env['SHFORTRAN'] = '$FORTRAN'


def exists(env):
return env.Detect(compilers)

Expand Down
26 changes: 13 additions & 13 deletions SCons/Tool/g77.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
"""SCons.Tool.g77

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.

"""

# 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
Expand All @@ -29,15 +20,23 @@
# 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 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
from SCons.Tool.FortranCommon import add_all_to_env, add_f77_to_env

compilers = ['g77', 'f77']


def generate(env):
"""Add Builders and construction variables for g77 to an Environment."""
add_all_to_env(env)
Expand All @@ -63,6 +62,7 @@ def generate(env):
env['INCF77PREFIX'] = "-I"
env['INCF77SUFFIX'] = ""


def exists(env):
return env.Detect(compilers)

Expand Down
29 changes: 15 additions & 14 deletions SCons/Tool/gfortran.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
"""SCons.Tool.gfortran

Tool-specific initialization for gfortran, the GNU Fortran 95/Fortran
2003 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
Expand All @@ -30,14 +20,24 @@
# 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 gfortran, the GNU Fortran 95/Fortran
2003 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


def generate(env):
"""Add Builders and construction variables for gfortran to an
Environment."""
Expand All @@ -56,6 +56,7 @@ def generate(env):

env['FORTRANMODDIRPREFIX'] = "-J"


def exists(env):
return env.Detect('gfortran')

Expand Down
29 changes: 15 additions & 14 deletions SCons/Tool/ifort.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
"""SCons.Tool.ifort

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.

"""

# 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
Expand All @@ -30,14 +20,24 @@
# 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 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


def generate(env):
"""Add Builders and construction variables for ifort to an Environment."""
# ifort supports Fortran 90 and Fortran 95
Expand Down Expand Up @@ -78,6 +78,7 @@ def generate(env):
else:
env['FORTRANMODDIRPREFIX'] = "-module "


def exists(env):
return env.Detect('ifort')

Expand Down
6 changes: 2 additions & 4 deletions test/Fortran/FORTRANPATH.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# 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
Expand All @@ -20,9 +21,6 @@
# 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

Expand Down