Skip to content

Commit

Permalink
Add customization point for easyblocks to specify additional paramete…
Browse files Browse the repository at this point in the history
…rs for "sources"

Some easyblocks such as `Cargo` will use a custom EasyConfig parameters
to fill the `sources` list.
To avoid hard-coding them `inject_checksums` introduce a static method
`src_parameter_names` to return a list of parameters that contribute to
the final list of `sources` when parsing the EasyConfig.
  • Loading branch information
Flamefire committed Oct 9, 2024
1 parent 501c568 commit 459450c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ def extra_options(extra=None):

return extra

@staticmethod
def src_keys():
"""
Return list of EasyConfig parameter that contribute to the sources in the `src` member
(or equivalently to the `sources` parameter of a parsed EasyConfig)
"""
return ['sources']

#
# INIT
#
Expand Down Expand Up @@ -4752,7 +4760,7 @@ def make_checksum_lines(checksums, indent_level):
placeholder = '# PLACEHOLDER FOR SOURCES/PATCHES WITH CHECKSUMS'

# grab raw lines for the following params
keys = ['source_urls', 'sources', 'crates', 'patches']
keys = ['source_urls'] + app.src_keys() + ['patches']
raw = {}
for key in keys:
regex = re.compile(r'^(%s(?:.|\n)*?\])\s*$' % key, re.M)
Expand Down
4 changes: 4 additions & 0 deletions test/framework/sandbox/easybuild/easyblocks/generic/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def extra_options():
}
return EasyBlock.extra_options(extra_vars)

@staticmethod
def src_keys():
return super(Cargo, Cargo).src_keys() + ['crates']

def __init__(self, *args, **kwargs):
"""Constructor for Cargo easyblock."""
super(Cargo, self).__init__(*args, **kwargs)
Expand Down

0 comments on commit 459450c

Please sign in to comment.