Skip to content

Commit

Permalink
add support for %(rpath)s template value
Browse files Browse the repository at this point in the history
  • Loading branch information
boegel committed Oct 6, 2024
1 parent 9eb0e4a commit 8424686
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 @@ -103,6 +103,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': "String value indicating whether or not RPATH linking is used ('yes' or 'no')",
'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 specify by the --sysroot configuration option",
Expand Down Expand Up @@ -298,6 +300,9 @@ def template_constant_dict(config, ignore=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'] = 'yes' if build_option('rpath') else 'no'

# 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 @@ -1442,6 +1442,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)s'"
write_file(test_ec, test_ec_txt)

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

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

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

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

Expand Down Expand Up @@ -3483,6 +3507,8 @@ def test_template_constant_dict(self):

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

rpath = 'yes' if get_os_name() == 'Linux' else 'no'

expected = {
'bitbucket_account': 'gzip',
'github_account': 'gzip',
Expand All @@ -3492,6 +3518,7 @@ def test_template_constant_dict(self):
'nameletter': 'g',
'nameletterlower': 'g',
'parallel': None,
'rpath': rpath,
'software_commit': '',
'sysroot': '',
'toolchain_name': 'foss',
Expand Down Expand Up @@ -3576,6 +3603,7 @@ def test_template_constant_dict(self):
'pyminver': '7',
'pyshortver': '3.7',
'pyver': '3.7.2',
'rpath': rpath,
'software_commit': '',
'sysroot': '',
'version': '0.01',
Expand Down Expand Up @@ -3642,6 +3670,7 @@ def test_template_constant_dict(self):
'namelower': 'foo',
'nameletter': 'f',
'nameletterlower': 'f',
'rpath': rpath,
'software_commit': '',
'sysroot': '',
'version': '1.2.3',
Expand Down

0 comments on commit 8424686

Please sign in to comment.