From 0306aca0c82b547d1a120bd958d176f7caff6784 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 25 Oct 2023 11:33:07 +0200 Subject: [PATCH] Error out on unknown configure args --- easybuild/easyblocks/generic/configuremake.py | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/easybuild/easyblocks/generic/configuremake.py b/easybuild/easyblocks/generic/configuremake.py index f84f4dad45..33fbea7b5b 100644 --- a/easybuild/easyblocks/generic/configuremake.py +++ b/easybuild/easyblocks/generic/configuremake.py @@ -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 @@ -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 @@ -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):