Skip to content

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Sep 30, 2025

Motivating examples for adding this type:

  • Packaging rules that bundle targets into substructures (e.g. subdirectories).
  • Providing hints to aspects via a well-known implicit attribute mapping the names of other attributes to a list of well-known targets representing the semantic meaning of an edge (e.g. "compile time dep", "runtime dep", "third party dep", ...) for use in SBOM generation and packaging.
  • rules_js and other rulesets have patches parameters on their module extensions that accept lists of patches to apply per external dependency. With WORKSPACE, they relied on attr.string_list_dict, but the lack of repo mapping means that there is no direct port. Users would need to migrate to individual tags per hub repo and dep to supply patches.

Adding this type doesn't incur a significant maintenance cost:

  • The native attribute type LABEL_LIST_DICT already exists (added for exec_group_compatible_with), so this only requires wiring it up in Starlark. In fact, some of the added logic (duplicate checking) is relevant for this existing use case, we just forgot to add it.
  • A Starlark type with equivalent BUILD syntax already exists (attr.string_list_dict), so there is no need for tooling to explicitly support the new type.

Fixes #7989

RELNOTES[NEW]: The new attr.label_list_dict type accepts a dict in which keys are strings and values are lists of labels.

@fmeum fmeum force-pushed the 7989-label-list-dict branch from 99587be to 86c6179 Compare September 30, 2025 10:27
Motivating examples for adding this type:
* Packaging rules that bundle targets into substructures (e.g. subdirectories).
* Providing hints to aspects via a well-known implicit attribute mapping the names of other attributes to a list of well-known targets representing the semantic meaning of an edge (e.g. "compile time dep", "runtime dep", "third party dep", ...) for use in SBOM generation and packaging.
* rules_js and other rulesets have `patches` parameters on their module extensions that accept lists of patches to apply per external dependency. With WORKSPACE, they relied on `attr.string_list_dict`, but the lack of repo mapping means that there is no direct port. Users would need to migrate to individual tags per hub repo and dep to supply patches.

Adding this type doesn't incur a significant maintenance cost:
* The native attribute type `LABEL_LIST_DICT` already exists (added for `exec_group_compatible_with`), so this only requires wiring it up in Starlark.
* A Starlark type with equivalent BUILD syntax already exists (`attr.string_list_dict`), so there is no need for tooling to explicitly support the new type.

RELNOTES[NEW]: The new `attr.label_list_dict` type accepts a dict in which keys are strings and values are lists of labels.
@fmeum fmeum force-pushed the 7989-label-list-dict branch from 138edea to 6146d60 Compare September 30, 2025 14:02
@fmeum fmeum requested a review from lberki September 30, 2025 14:34
@fmeum fmeum marked this pull request as ready for review September 30, 2025 14:34
@fmeum fmeum requested review from a team, Wyverald and meteorcloudy as code owners September 30, 2025 14:34
@fmeum fmeum requested review from gregestren and removed request for a team, Wyverald, gregestren and meteorcloudy September 30, 2025 14:34
@fmeum
Copy link
Collaborator Author

fmeum commented Sep 30, 2025

@lberki Choosing you as a reviewer based on #7989 (comment) :-)

@github-actions github-actions bot added team-Configurability platforms, toolchains, cquery, select(), config transitions team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Sep 30, 2025
@meteorcloudy
Copy link
Member

ping @lberki

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

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Configurability platforms, toolchains, cquery, select(), config transitions team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need string_keyed_label_list_dict

2 participants