Skip to content

Commit

Permalink
Merge pull request #4670 from boegel/rpath_template
Browse files Browse the repository at this point in the history
add support for `%(rpath_enabled)s` template value
  • Loading branch information
jfgrimm authored Oct 10, 2024
2 parents b9c70d8 + b0a95b2 commit 3b01ba9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions easybuild/framework/easyconfig/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
('cuda_sm_comma_sep', "Comma-separated list of sm_* values that correspond with CUDA compute capabilities"),
('cuda_sm_space_sep', "Space-separated list of sm_* values that correspond with CUDA compute capabilities"),
('mpi_cmd_prefix', "Prefix command for running MPI programs (with default number of ranks)"),
# can't be a boolean (True/False), must be a string value since it's a string template
('rpath_enabled', "String value indicating whether or not RPATH linking is used ('true' or 'false')"),
('software_commit', "Git commit id to use for the software as specified by --software-commit command line option"),
('sysroot', "Location root directory of system, prefix for standard paths like /usr/lib and /usr/include"
"as specified by the --sysroot configuration option"),
Expand Down Expand Up @@ -208,6 +210,9 @@ def template_constant_dict(config, ignore=None, skip_lower=None, toolchain=None)
# set 'arch' for system architecture based on 'machine' (4th) element of platform.uname() return value
template_values['arch'] = platform.uname()[4]

# set 'rpath' template based on 'rpath' configuration option, using empty string as fallback
template_values['rpath_enabled'] = 'true' if build_option('rpath') else 'false'

# set 'sysroot' template based on 'sysroot' configuration option, using empty string as fallback
template_values['sysroot'] = build_option('sysroot') or ''

Expand Down
29 changes: 29 additions & 0 deletions test/framework/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,30 @@ def test_start_dir_template(self):
self.assertIn('start_dir in extension configure is %s &&' % ext_start_dir, logtxt)
self.assertIn('start_dir in extension build is %s &&' % ext_start_dir, logtxt)

def test_rpath_template(self):
"""Test the %(rpath)s template"""
test_easyconfigs = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs', 'test_ecs')
toy_ec = os.path.join(test_easyconfigs, 't', 'toy', 'toy-0.0.eb')

test_ec = os.path.join(self.test_prefix, 'test.eb')
test_ec_txt = read_file(toy_ec)
test_ec_txt += "configopts = '--with-rpath=%(rpath_enabled)s'"
write_file(test_ec, test_ec_txt)

ec = EasyConfig(test_ec)
expected = '--with-rpath=true' if get_os_name() == 'Linux' else '--with-rpath=false'
self.assertEqual(ec['configopts'], expected)

# force True
update_build_option('rpath', True)
ec = EasyConfig(test_ec)
self.assertEqual(ec['configopts'], "--with-rpath=true")

# force False
update_build_option('rpath', False)
ec = EasyConfig(test_ec)
self.assertEqual(ec['configopts'], "--with-rpath=false")

def test_sysroot_template(self):
"""Test the %(sysroot)s template"""

Expand Down Expand Up @@ -3365,6 +3389,8 @@ def test_template_constant_dict(self):

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

rpath = 'true' if get_os_name() == 'Linux' else 'false'

expected = {
'bitbucket_account': 'gzip',
'github_account': 'gzip',
Expand All @@ -3374,6 +3400,7 @@ def test_template_constant_dict(self):
'nameletter': 'g',
'nameletterlower': 'g',
'parallel': None,
'rpath_enabled': rpath,
'software_commit': '',
'sysroot': '',
'toolchain_name': 'foss',
Expand Down Expand Up @@ -3457,6 +3484,7 @@ def test_template_constant_dict(self):
'pyminver': '7',
'pyshortver': '3.7',
'pyver': '3.7.2',
'rpath_enabled': rpath,
'software_commit': '',
'sysroot': '',
'version': '0.01',
Expand Down Expand Up @@ -3523,6 +3551,7 @@ def test_template_constant_dict(self):
'namelower': 'foo',
'nameletter': 'f',
'nameletterlower': 'f',
'rpath_enabled': rpath,
'software_commit': '',
'sysroot': '',
'version': '1.2.3',
Expand Down

0 comments on commit 3b01ba9

Please sign in to comment.