Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion easybuild/framework/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import os

from easybuild.framework.easyconfig.easyconfig import resolve_template
from easybuild.framework.easyconfig.templates import template_constant_dict
from easybuild.framework.easyconfig.templates import TEMPLATE_NAMES_EASYBLOCK_RUN_STEP, template_constant_dict
from easybuild.tools.build_log import EasyBuildError, raise_nosupport
from easybuild.tools.filetools import change_dir
from easybuild.tools.run import run_cmd
Expand Down Expand Up @@ -111,6 +111,10 @@ def __init__(self, mself, ext, extra_params=None):
# construct dict with template values that can be used
self.cfg.template_values.update(template_constant_dict({'name': name, 'version': version}))

# Add install/builddir templates with values from master.
for name in TEMPLATE_NAMES_EASYBLOCK_RUN_STEP:
self.cfg.template_values[name[0]] = str(getattr(self.master, name[0], None))

# list of source/patch files: we use an empty list as default value like in EasyBlock
self.src = resolve_template(self.ext.get('src', []), self.cfg.template_values)
self.patches = resolve_template(self.ext.get('patches', []), self.cfg.template_values)
Expand Down
11 changes: 7 additions & 4 deletions test/framework/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ def test_extensions_templates(self):
' "source_tmpl": "%(name)s-%(version_major_minor)s-py%(pymajver)s%(versionsuffix)s.tar.gz",',
' "patches": ["%(name)s-%(version)s_fix-silly-typo-in-printf-statement.patch"],',
# use hacky prebuildopts that is picked up by 'EB_Toy' easyblock, to check whether templates are resolved
' "prebuildopts": "gcc -O2 %(name)s.c -o toy-%(version)s && mv toy-%(version)s toy #",',
' "prebuildopts": "gcc -O2 %(name)s.c -o toy-%(version)s &&' +
' mv toy-%(version)s toy # echo installdir is %(installdir)s #",',
' }),',
']',
])
Expand All @@ -489,9 +490,12 @@ def test_extensions_templates(self):
for patch in toy_ext.patches:
patches.append(patch['path'])
self.assertEqual(patches, [os.path.join(self.test_prefix, toy_patch_fn)])
# define actual installation dir
pi_installdir = os.path.join(self.test_installpath, 'software', 'pi', '3.14-test')
expected_prebuildopts = 'gcc -O2 toy.c -o toy-0.0 && mv toy-0.0 toy # echo installdir is %s #' % pi_installdir
expected = {
'patches': ['toy-0.0_fix-silly-typo-in-printf-statement.patch'],
'prebuildopts': 'gcc -O2 toy.c -o toy-0.0 && mv toy-0.0 toy #',
'prebuildopts': expected_prebuildopts,
'source_tmpl': 'toy-0.0-py3-test.tar.gz',
'source_urls': ['https://pypi.python.org/packages/source/t/toy'],
}
Expand All @@ -500,10 +504,9 @@ def test_extensions_templates(self):
# also .cfg of Extension instance was updated correctly
self.assertEqual(toy_ext.cfg['source_urls'], ['https://pypi.python.org/packages/source/t/toy'])
self.assertEqual(toy_ext.cfg['patches'], [toy_patch_fn])
self.assertEqual(toy_ext.cfg['prebuildopts'], "gcc -O2 toy.c -o toy-0.0 && mv toy-0.0 toy #")
self.assertEqual(toy_ext.cfg['prebuildopts'], expected_prebuildopts)

# check whether files expected to be installed for 'toy' extension are in place
pi_installdir = os.path.join(self.test_installpath, 'software', 'pi', '3.14-test')
self.assertTrue(os.path.exists(os.path.join(pi_installdir, 'bin', 'toy')))
self.assertTrue(os.path.exists(os.path.join(pi_installdir, 'lib', 'libtoy.a')))

Expand Down