Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variable substitution for depens #317

Closed
mahaase opened this issue Feb 27, 2020 · 6 comments
Closed

variable substitution for depens #317

mahaase opened this issue Feb 27, 2020 · 6 comments

Comments

@mahaase
Copy link
Contributor

mahaase commented Feb 27, 2020

Hi,

feature request: variable substitution for depens area, like:

depends:
    -"${VAR}"
@mahaase
Copy link
Contributor Author

mahaase commented Jun 10, 2020

no idea if that makes a difference, but we need especially this:

depends:
    - name: foo::bar
      rename: something-${VAR}

@rhubert
Copy link
Contributor

rhubert commented Jul 9, 2021

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?

@jkloetzke
Copy link
Member

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...

@rhubert
Copy link
Contributor

rhubert commented Jul 9, 2021

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.

@jkloetzke
Copy link
Member

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...

@jkloetzke
Copy link
Member

Fixed by #510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants