Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance ConfigureMake easyblock to error out on unknown configure options #3025

Merged
Merged
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
30 changes: 27 additions & 3 deletions easybuild/easyblocks/generic/configuremake.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@
from easybuild.easyblocks import VERSION as EASYBLOCKS_VERSION
from easybuild.framework.easyblock import EasyBlock
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import print_warning
from easybuild.tools.config import source_paths, build_option
from easybuild.tools.build_log import print_warning, EasyBuildError
from easybuild.tools.config import source_paths, build_option, ERROR, IGNORE, WARN
from easybuild.tools.filetools import CHECKSUM_TYPE_SHA256, adjust_permissions, compute_checksum, download_file
from easybuild.tools.filetools import read_file, remove_file
from easybuild.tools.run import run_shell_cmd
from easybuild.tools.run import extract_errors_from_log, run_shell_cmd
from easybuild.tools.utilities import nub

# string that indicates that a configure script was generated by Autoconf
# note: bytes string since this constant is used to check the contents of 'configure' which is read as bytes
Expand Down Expand Up @@ -195,6 +196,11 @@ def extra_options(extra_vars=None):
'tar_config_opts': [False, "Override tar settings as determined by configure.", CUSTOM],
'test_cmd': [None, "Test command to use ('runtest' value is appended, default: '%s')" % DEFAULT_TEST_CMD,
CUSTOM],
'unrecognized_configure_options': [ERROR,
Flamefire marked this conversation as resolved.
Show resolved Hide resolved
"Action to do when unrecognized options passed to ./configure are"
" detected, defaults to aborting the build. Can be set to '" + WARN +
"' or '" + IGNORE + "' (NOT RECOMMENDED! It might hide actual errors"
" e.g. misspelling of intended or changed options)", CUSTOM],
})
return extra_vars

Expand Down Expand Up @@ -325,6 +331,24 @@ def configure_step(self, cmd_prefix=''):

res = run_shell_cmd(cmd)

action = self.cfg['unrecognized_configure_options']
boegel marked this conversation as resolved.
Show resolved Hide resolved
valid_actions = (ERROR, WARN, IGNORE)
# Always verify the EC param
if action not in valid_actions:
raise EasyBuildError('Invalid value for `unrecognized_configure_options`: %s. Must be one of: ',
action, ', '.join(valid_actions))
if action != IGNORE:
unrecognized_options_str = 'configure: WARNING: unrecognized options:'
unrecognized_options = extract_errors_from_log(res.output, unrecognized_options_str)[1]
# Keep only unique options (remove the warning string and strip whitespace)
unrecognized_options = nub(x.split(unrecognized_options_str)[-1].strip() for x in unrecognized_options)
if unrecognized_options:
msg = 'Found unrecognized configure options: ' + '; '.join(unrecognized_options)
if action == WARN:
print_warning(msg)
else:
raise EasyBuildError(msg)

return res.output

def build_step(self, verbose=None, path=None):
Expand Down