From 8c18999a18515d69bbdeb8a93cf5f5baf03a9cdb Mon Sep 17 00:00:00 2001 From: Miguel Dias Costa Date: Wed, 3 Jan 2018 17:38:42 +0800 Subject: [PATCH 1/3] initial support for injecting additional toolchainopts --- easybuild/framework/easyconfig/tweak.py | 9 ++++++++- easybuild/tools/options.py | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/easybuild/framework/easyconfig/tweak.py b/easybuild/framework/easyconfig/tweak.py index f91b695116..c92a0ed1ef 100644 --- a/easybuild/framework/easyconfig/tweak.py +++ b/easybuild/framework/easyconfig/tweak.py @@ -168,6 +168,13 @@ def __repr__(self): tweaks.update({'toolchain': TcDict({'name': toolchain['name'], 'version': toolchain['version']})}) _log.debug("New toolchain constructed: %s" % tweaks['toolchain']) + if 'toolchainopts' in keys: + tco_regexp = re.compile(r"^\s*toolchainopts\s*=\s*(.*)$", re.M) + res = tco_regexp.search(ectxt) + toolchainopts = eval(res.group(1)) + toolchainopts.update(tweaks['toolchainopts']) + tweaks.update({'toolchainopts': toolchainopts}) + additions = [] # automagically clear out list of checksums if software version is being tweaked @@ -176,7 +183,7 @@ def __repr__(self): _log.warning("Tweaking version: checksums cleared, verification disabled.") # we need to treat list values seperately, i.e. we prepend to the current value (if any) - for (key, val) in tweaks.items(): + for (key, val) in tweaks.items(): if isinstance(val, list): # use non-greedy matching for list value using '*?' to avoid including other parameters in match, diff --git a/easybuild/tools/options.py b/easybuild/tools/options.py index 5cf66c93e8..931135aaf0 100644 --- a/easybuild/tools/options.py +++ b/easybuild/tools/options.py @@ -321,6 +321,7 @@ def override_options(self): opts = OrderedDict({ 'add-dummy-to-minimal-toolchains': ("Include dummy in minimal toolchain searches", None, 'store_true', False), + 'additional-toolchain-opts': ("List of toolchain options to add", 'strlist', 'store', []), 'allow-loaded-modules': ("List of software names for which to allow loaded modules in initial environment", 'strlist', 'store', DEFAULT_ALLOW_LOADED_MODULES), 'allow-modules-tool-mismatch': ("Allow mismatch of modules tool and definition of 'module' function", @@ -1178,6 +1179,16 @@ def process_software_build_specs(options): value = value.split(',') build_specs.update({param: value}) + # process --additional-toolchain-opts + if options.additional_toolchain_opts: + try_to_generate = True + + toolchainopts = {} + for spec in options.additional_toolchain_opts: + param, value = spec.split('=') + toolchainopts.update({param: value}) + build_specs.update({'toolchainopts': toolchainopts}) + return (try_to_generate, build_specs) From f0c286713ded11a16b684e3750477b2ac42cd4e9 Mon Sep 17 00:00:00 2001 From: Miguel Dias Costa Date: Wed, 3 Jan 2018 17:59:58 +0800 Subject: [PATCH 2/3] cleanup whitespace --- easybuild/framework/easyconfig/tweak.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/framework/easyconfig/tweak.py b/easybuild/framework/easyconfig/tweak.py index c92a0ed1ef..f7587099e9 100644 --- a/easybuild/framework/easyconfig/tweak.py +++ b/easybuild/framework/easyconfig/tweak.py @@ -183,7 +183,7 @@ def __repr__(self): _log.warning("Tweaking version: checksums cleared, verification disabled.") # we need to treat list values seperately, i.e. we prepend to the current value (if any) - for (key, val) in tweaks.items(): + for (key, val) in tweaks.items(): if isinstance(val, list): # use non-greedy matching for list value using '*?' to avoid including other parameters in match, From 569a20eb3e42d397dd5a288d2ba75d612985bd8c Mon Sep 17 00:00:00 2001 From: Miguel Dias Costa Date: Thu, 4 Jan 2018 09:48:25 +0800 Subject: [PATCH 3/3] rename option and handle case of no toolchainopts in easyconfig --- easybuild/framework/easyconfig/tweak.py | 6 ++++-- easybuild/tools/options.py | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/easybuild/framework/easyconfig/tweak.py b/easybuild/framework/easyconfig/tweak.py index f7587099e9..24f9cd4932 100644 --- a/easybuild/framework/easyconfig/tweak.py +++ b/easybuild/framework/easyconfig/tweak.py @@ -169,10 +169,12 @@ def __repr__(self): _log.debug("New toolchain constructed: %s" % tweaks['toolchain']) if 'toolchainopts' in keys: + extra_toolchainopts = tweaks['toolchainopts'] tco_regexp = re.compile(r"^\s*toolchainopts\s*=\s*(.*)$", re.M) res = tco_regexp.search(ectxt) - toolchainopts = eval(res.group(1)) - toolchainopts.update(tweaks['toolchainopts']) + toolchainopts = {} if not res else eval(res.group(1)) + _log.debug("Appending %s toolchainopts to %s" % (extra_toolchainopts, toolchainopts)) + toolchainopts.update(extra_toolchainopts) tweaks.update({'toolchainopts': toolchainopts}) additions = [] diff --git a/easybuild/tools/options.py b/easybuild/tools/options.py index 931135aaf0..f33f32cfca 100644 --- a/easybuild/tools/options.py +++ b/easybuild/tools/options.py @@ -321,7 +321,6 @@ def override_options(self): opts = OrderedDict({ 'add-dummy-to-minimal-toolchains': ("Include dummy in minimal toolchain searches", None, 'store_true', False), - 'additional-toolchain-opts': ("List of toolchain options to add", 'strlist', 'store', []), 'allow-loaded-modules': ("List of software names for which to allow loaded modules in initial environment", 'strlist', 'store', DEFAULT_ALLOW_LOADED_MODULES), 'allow-modules-tool-mismatch': ("Allow mismatch of modules tool and definition of 'module' function", @@ -356,6 +355,7 @@ def override_options(self): None, 'store_true', False), 'extra-modules': ("List of extra modules to load after setting up the build environment", 'strlist', 'extend', None), + 'extra-toolchainopts': ("List of toolchain options to add", 'strlist', 'store', []), 'filter-deps': ("List of dependencies that you do *not* want to install with EasyBuild, " "because equivalent OS packages are installed. (e.g. --filter-deps=zlib,ncurses)", 'strlist', 'extend', None), @@ -1179,12 +1179,12 @@ def process_software_build_specs(options): value = value.split(',') build_specs.update({param: value}) - # process --additional-toolchain-opts - if options.additional_toolchain_opts: + # process --extra-toolchainopts + if options.extra_toolchainopts: try_to_generate = True toolchainopts = {} - for spec in options.additional_toolchain_opts: + for spec in options.extra_toolchainopts: param, value = spec.split('=') toolchainopts.update({param: value}) build_specs.update({'toolchainopts': toolchainopts})