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

input: add support for package aliases #609

Merged
merged 5 commits into from
Jan 29, 2025

Conversation

jkloetzke
Copy link
Member

Virtual packages transparently create an alias for a recipe. They are configured by yaml files in the newly defined virtual directory. For example, the file virtual/libs/libegl.yaml

multiPackage:
    "":  ${CONFIG_SELECT_LIBEGL:-libs::mesa3d}
    dev: ${CONFIG_SELECT_LIBEGL:-libs::mesa3d}-dev
    tgt: ${CONFIG_SELECT_LIBEGL:-libs::mesa3d}-tgt

would create packages libs::libegl, libs::libegl-dev and libs::libegl-tgt whose underlying recipe is selected by CONFIG_SELECT_LIBEGL.

If there is only one package, the yaml file can be a simple string containing just the target name.

Copy link

codecov bot commented Jan 19, 2025

Codecov Report

Attention: Patch coverage is 90.38462% with 10 lines in your changes missing coverage. Please review.

Project coverage is 88.86%. Comparing base (3909513) to head (dc7f3ad).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
pym/bob/input.py 90.09% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #609      +/-   ##
==========================================
- Coverage   88.87%   88.86%   -0.01%     
==========================================
  Files          48       48              
  Lines       15551    15629      +78     
==========================================
+ Hits        13821    13889      +68     
- Misses       1730     1740      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jkloetzke
Copy link
Member Author

@sixtyfourktec @rhubert It would be nice to get you feedback here. Given the "virtual" packages in basement-gnu-linux, I figured some native support should be provided. Especially since it's not possible to virtualize tools at all at the moment.

This PR is the bare minimum feature set that I could think of. Is this enough from your POV or do we need something more for proper virtual packages..?

@rhubert
Copy link
Contributor

rhubert commented Jan 20, 2025

👍 Look good + sufficient to me.

Only a quick idea: What about virtual classes? I'm thinking of the the integration clang, where something like a virtual::clang class could solve the issue of using clang or not without touching the recipes...maybe... not thought to the end...

@jkloetzke
Copy link
Member Author

Thanks for looking into it. I'm currently leaning to name this alias instead of virtual. Because it's creating an alias for an existing package. There is also #314 which requires the same underlying mechanism to create multiple dependencies to the same recipe by giving them distinct names:

depends:
    - name: bar
      alias: bar-one
      environment:
        CONFIG_BAR: "one"
    - name: bar
      alias: bar-two
      environment:
        CONFIG_BAR: "two"

As for classes I'm not sure if this will work. The aliases are created after all classes have been resolved already. But I have to think about this too...

@jkloetzke jkloetzke changed the title input: add support for virtual packages input: add support for package aliases Jan 26, 2025
@jkloetzke
Copy link
Member Author

Ok, so I renamed everything consistently to "alias". There are now global aliases that are configured in the aliases directory as YAML files. And then there are local aliases where each dependency in the depends list can get a different (but still locally unique) name.

@daxcore you might want to try out the local aliases. Any feedback if this fits your needs is highly appreciated. :)

More tests and the documentation are still missing, though...

So far, Bob supports string substitution of dependency names. This lets
recipes decide the actual dependency at recipe parsing time. That is a
local decision of the recipe, though. Sometimes, a common indirection
for many dependencies is required.

Global recipe aliases provide such an indirection. They are configured
in the newly recognized "aliases" directory. The alias name is derived
from the YAML file name, just like for recipes and classes. If it is
just a single alias, the file only contains the target recipe name.
Optionally, several aliases can be defined by using a "multiPackage" in
the file.

The alias target is subject to string substitution.
With the advent of aliases, the package name may no longer resemble the
underlying recipe. This will be confusing to the user when trying to
find the workspaces for a particular recipe. Hence we should always use
the original package name based on the recipe instead of the possibly
aliased package name.
Each dependency of a recipe has to have a unique name. This is a problem
if two distinct variants of the same dependency need to be used, though.
To enable that feature, every dependency can optionally get an alias
name. Multiple references to the same dependency can be created, given
that each gets its own unique alias.

If the dependency is provided via 'provideDeps', the alias name will be
used for matching and in the downstream package dependencies. On the
other hand, the alias is ignored for recipe cycle analysis. This means
that aliases cannot be used to break cyclic recipe dependencies.

Fixes BobBuildTool#314.
@jkloetzke jkloetzke marked this pull request as ready for review January 28, 2025 20:11
@jkloetzke jkloetzke merged commit aa23765 into BobBuildTool:master Jan 29, 2025
11 checks passed
@jkloetzke jkloetzke deleted the virtual-packages branch January 29, 2025 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants