Skip to content

Commit 3b01ba9

Browse files
authored
Merge pull request #4670 from boegel/rpath_template
add support for `%(rpath_enabled)s` template value
2 parents b9c70d8 + b0a95b2 commit 3b01ba9

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

easybuild/framework/easyconfig/templates.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
('cuda_sm_comma_sep', "Comma-separated list of sm_* values that correspond with CUDA compute capabilities"),
101101
('cuda_sm_space_sep', "Space-separated list of sm_* values that correspond with CUDA compute capabilities"),
102102
('mpi_cmd_prefix', "Prefix command for running MPI programs (with default number of ranks)"),
103+
# can't be a boolean (True/False), must be a string value since it's a string template
104+
('rpath_enabled', "String value indicating whether or not RPATH linking is used ('true' or 'false')"),
103105
('software_commit', "Git commit id to use for the software as specified by --software-commit command line option"),
104106
('sysroot', "Location root directory of system, prefix for standard paths like /usr/lib and /usr/include"
105107
"as specified by the --sysroot configuration option"),
@@ -208,6 +210,9 @@ def template_constant_dict(config, ignore=None, skip_lower=None, toolchain=None)
208210
# set 'arch' for system architecture based on 'machine' (4th) element of platform.uname() return value
209211
template_values['arch'] = platform.uname()[4]
210212

213+
# set 'rpath' template based on 'rpath' configuration option, using empty string as fallback
214+
template_values['rpath_enabled'] = 'true' if build_option('rpath') else 'false'
215+
211216
# set 'sysroot' template based on 'sysroot' configuration option, using empty string as fallback
212217
template_values['sysroot'] = build_option('sysroot') or ''
213218

test/framework/easyconfig.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,30 @@ def test_start_dir_template(self):
14231423
self.assertIn('start_dir in extension configure is %s &&' % ext_start_dir, logtxt)
14241424
self.assertIn('start_dir in extension build is %s &&' % ext_start_dir, logtxt)
14251425

1426+
def test_rpath_template(self):
1427+
"""Test the %(rpath)s template"""
1428+
test_easyconfigs = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs', 'test_ecs')
1429+
toy_ec = os.path.join(test_easyconfigs, 't', 'toy', 'toy-0.0.eb')
1430+
1431+
test_ec = os.path.join(self.test_prefix, 'test.eb')
1432+
test_ec_txt = read_file(toy_ec)
1433+
test_ec_txt += "configopts = '--with-rpath=%(rpath_enabled)s'"
1434+
write_file(test_ec, test_ec_txt)
1435+
1436+
ec = EasyConfig(test_ec)
1437+
expected = '--with-rpath=true' if get_os_name() == 'Linux' else '--with-rpath=false'
1438+
self.assertEqual(ec['configopts'], expected)
1439+
1440+
# force True
1441+
update_build_option('rpath', True)
1442+
ec = EasyConfig(test_ec)
1443+
self.assertEqual(ec['configopts'], "--with-rpath=true")
1444+
1445+
# force False
1446+
update_build_option('rpath', False)
1447+
ec = EasyConfig(test_ec)
1448+
self.assertEqual(ec['configopts'], "--with-rpath=false")
1449+
14261450
def test_sysroot_template(self):
14271451
"""Test the %(sysroot)s template"""
14281452

@@ -3365,6 +3389,8 @@ def test_template_constant_dict(self):
33653389

33663390
arch_regex = re.compile('^[a-z0-9_]+$')
33673391

3392+
rpath = 'true' if get_os_name() == 'Linux' else 'false'
3393+
33683394
expected = {
33693395
'bitbucket_account': 'gzip',
33703396
'github_account': 'gzip',
@@ -3374,6 +3400,7 @@ def test_template_constant_dict(self):
33743400
'nameletter': 'g',
33753401
'nameletterlower': 'g',
33763402
'parallel': None,
3403+
'rpath_enabled': rpath,
33773404
'software_commit': '',
33783405
'sysroot': '',
33793406
'toolchain_name': 'foss',
@@ -3457,6 +3484,7 @@ def test_template_constant_dict(self):
34573484
'pyminver': '7',
34583485
'pyshortver': '3.7',
34593486
'pyver': '3.7.2',
3487+
'rpath_enabled': rpath,
34603488
'software_commit': '',
34613489
'sysroot': '',
34623490
'version': '0.01',
@@ -3523,6 +3551,7 @@ def test_template_constant_dict(self):
35233551
'namelower': 'foo',
35243552
'nameletter': 'f',
35253553
'nameletterlower': 'f',
3554+
'rpath_enabled': rpath,
35263555
'software_commit': '',
35273556
'sysroot': '',
35283557
'version': '1.2.3',

0 commit comments

Comments
 (0)