bob
bob copied to clipboard
variable substitution for depens
Hi,
feature request: variable substitution for depens area, like:
depends:
-"${VAR}"
no idea if that makes a difference, but we need especially this:
depends:
- name: foo::bar
rename: something-${VAR}
I've a similar problem. A solution might be a custom yaml tag. Something like this
depends:
- !rename [ foo::bar, something-${VAR} ]
These tags should be extendable using the plugin interface. What do you think? Any objections?
The renaming of dependencies is actually tracked in #314. What would be the purpose of having it extendable via the plugin interface? If we offer string substitution in the rename section you could do something like this:
depends:
- name: foo::bar
rename: "$(call-my-plugin)"
Actually thinking more about the syntax I would prefer something like this:
depends:
- name: "$(call-my-plugin)"
recipe: foo::bar
By default the source recipe name equals the desired dependency package name as it is today...
The usecase I've in mind is to substitute all dependencies from a reference to build a additional multiPackage
which needs all the existings dependencies + the a additional package from the same deps. So instead of writing this:
depends:
- foo-dev
- bar-dev
- use: []
depends:
- foo-tgt
- bar-tgt
multiPackage:
magic:
depends:
- foo-magic
- bar-magic
I'd like to write this:
depends: &deps
- foo-dev
- bar-dev
- use: []
depends:
- foo-tgt
- bar-tgt
multiPackage:
magic:
depends:
- !magic_substitution_function_removing_tgt_deps_and_filter_others[*deps,"-dev","-magic"]
This way I do not have to have the dependencies list twice.
Oh, this is then a whole different story. The renaming and variable substitution does not change the number of dependencies. What you want is to have a hook for a plugin to rewrite the dependency list as a whole. (also note that your example would not work because the dependencies were defined already in the common section)
I did think about having some template support built into bob to solve the tedious -dev
v.s -tgt
dependency list problem. The trivial package steps in most recipes are another copy'n'paste thing that could be replaced with recipe template. Some template language could certainly help with your problem too. BUT: I havn't thought deeply about this and I see the problem that the recipes are even less readable then...
Fixed by #510