Skip to content

Commit

Permalink
Error out on unknown configure args
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Jun 6, 2024
1 parent 4533001 commit 0306aca
Showing 1 changed file with 27 additions and 3 deletions.
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,
"Action to do when unrecognized arguments 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']
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

0 comments on commit 0306aca

Please sign in to comment.