Skip to content

Commit

Permalink
Merge pull request devitocodes#1263 from devitocodes/smarter-custom-c…
Browse files Browse the repository at this point in the history
…ompiler

jit: Smarter CustomCompiler
  • Loading branch information
mloubout authored Apr 30, 2020
2 parents 3baa214 + 6eb53ac commit cf8a96a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions devito/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,12 @@ def __init__(self, *args, **kwargs):


class CustomCompiler(Compiler):

"""
Custom compiler based on standard environment flags.
If no environment flags are found, defaults to the GNUCompiler.
Notes
-----
Currently honours CC, CFLAGS and LDFLAGS, with defaults similar to the
Expand All @@ -500,6 +503,14 @@ class CustomCompiler(Compiler):
or otherwise default to ``-fopenmp``.
"""

def __new__(cls, *args, **kwargs):
if any(i in environ for i in ['CC', 'CXX', 'CFLAGS', 'LDFLAGS']):
obj = super().__new__(cls, *args, **kwargs)
obj.__init__(*args, **kwargs)
return obj
else:
return GNUCompiler(*args, **kwargs)

def __init__(self, *args, **kwargs):
super(CustomCompiler, self).__init__(*args, **kwargs)

Expand Down

0 comments on commit cf8a96a

Please sign in to comment.