-
Notifications
You must be signed in to change notification settings - Fork 83
Description
I'm looking at updating the fairly complex petsc recipe, and one thing that's been super useful for simplifying the recipe is defining variables that reference variant/other context variables. I'll need this less in a v1 recipe with the nicer conditionals, but it would still be useful.
Is there any way to define a variable that references another variable in a v1 recipe?
For example, the build string prefix is cuda${{ cuda_major }}_mpi${{ mpi }}_
if cuda is used, and just mpi${{ mpi }}_
if not. This string needs to be computed more than once, because it also goes in run_exports. Further, cuda_major
is already a derivative value, since cuda_compiler_version
contains a minor version that we need to exclude.
If this worked:
context:
cuda_major: ${{ cuda_compiler_version | split('.') | first }}
build_prefix:
if: cuda_compiler_version != "None"
then: cuda${{ cuda_major }}_mpi${{ mpi }}
else: mpi${{ mpi }}
I think I could get pretty far. That would ideally mean templates in context vars where:
- context vars can be templates
- templates can reference variant values
- templates can reference context vars that are defined before them
I know I can recompute the whole thing every time it is used, but it is really a lot simpler and results in a clearer, more reliable, more likely correct recipe to compute these variables just once.
Is there any way to create variables that are derived from other context variables or variant values?