Delegate alias generation to macro #176
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To support the multi-arch proposal #166, the extension requires more sophisticated logic for the alias repository, particularly when a single package resolves to multiple RPMs (e.g. for different architectures).
Previously, the repository rule was responsible for the textual construction of alias target in the generated BUILD file. This approach is rigid and scales poorly when complex logic to handle more aliases is required. By extracting this logic into a dedicated macro, the repository rule is responsible only for providing structured metadata about RPMs. The logic determining how to expose that data (as an alias, a null rule, or perhaps a
selectin the future) is deferred to the macro. This decouples data resolution from target generation and allows utilizing more the expressiveness of Starlark.This implementation tries to provide the equivalent logic as before. Minor changes include:
registered_rpmsshared dict);null_rpm_repositoryas alias generator macro can callnull_rpm_ruledirectly.This structure allows for future customisation, where users could potentially provide their own alias generation strategies if the default one doesn't fit their needs.