Skip to content

Commit 50c3dee

Browse files
committed
Consolidate standard flag management for coverage
1 parent 9091549 commit 50c3dee

2 files changed

Lines changed: 10 additions & 26 deletions

File tree

HISTORY.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
History
33
=======
44

5-
1.8.4 (2023-01-25) Update CI to use mamba, improve dev utilities, & various bug fixes
5+
1.8.4 (2023-01-27) Update CI to use mamba, improve dev utilities, & various bug fixes
66
------------------
77
* Update utility scripts so that requirements can be maintained in a single file with pip requirements.txt file and conda recipe generated via utils/manage_requirements.py
88
* Consolidate CLI utilities for creating environments

yggdrasil/drivers/CPPModelDriver.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,20 @@ def find_standard_flag(cls, flags):
3434
return -1
3535

3636
@classmethod
37-
def add_standard_flag(cls, flags):
38-
r"""Add a standard flag to the list of flags.
37+
def handle_standard_flag(cls, flags, skip_standard_flag=False):
38+
r"""Add or remove standard flag from a list of flags.
3939
4040
Args:
4141
flags (list): Compilation flags.
42+
skip_standard_flag (bool, optional): If True, the C++
43+
standard flag will not be added. Defaults to False.
4244
4345
"""
4446
std_flag_idx = cls.find_standard_flag(flags)
45-
if std_flag_idx == -1:
46-
flags.append('-std=%s' % cls.cpp_std)
47-
return flags
48-
49-
@classmethod
50-
def remove_standard_flag(cls, flags):
51-
r"""Remove the standard flag from a list of flags if one is
52-
present.
53-
54-
Args:
55-
flags (list): Compilation flags.
56-
57-
"""
58-
std_flag_idx = cls.find_standard_flag(flags)
59-
if std_flag_idx != -1:
47+
if skip_standard_flag and (std_flag_idx != -1):
6048
del flags[std_flag_idx]
49+
elif (not skip_standard_flag) and (std_flag_idx == -1):
50+
flags.append('-std=%s' % cls.cpp_std)
6151
return flags
6252

6353

@@ -82,10 +72,7 @@ def get_flags(cls, skip_standard_flag=False, **kwargs):
8272
"""
8373
out = super(GPPCompiler, cls).get_flags(**kwargs)
8474
# Add/remove standard library flag
85-
if skip_standard_flag:
86-
out = cls.remove_standard_flag(out)
87-
else:
88-
out = cls.add_standard_flag(out)
75+
out = cls.handle_standard_flag(out, skip_standard_flag)
8976
return out
9077

9178

@@ -123,10 +110,7 @@ def get_flags(cls, skip_standard_flag=False, **kwargs):
123110
"""
124111
out = super(ClangPPCompiler, cls).get_flags(**kwargs)
125112
# Add/remove standard library flag
126-
if skip_standard_flag:
127-
out = cls.remove_standard_flag(out)
128-
else:
129-
out = cls.add_standard_flag(out)
113+
out = cls.handle_standard_flag(out, skip_standard_flag)
130114
return out
131115

132116
@classmethod

0 commit comments

Comments
 (0)