Skip to content

Conversation

@Wyverald
Copy link
Member

@Wyverald Wyverald commented Jul 8, 2025

Apologies for the size of this PR, but I couldn't really see a way to do this in incremental steps while actually exercising the new logic.

  • When in the context of repos, Rule is replaced with RepoDefinition and RuleClass is replaced with RepoRule.
    • In a follow-up, we can remove all repo-related logic from Rule and Package.
  • BzlmodRepoRuleFunction/Value are moved into the lib/bazel/repository package and renamed to RepoDefinitionFunction/Value.
  • The logic to type-check attribute values is now shared between TypeCheckedTag and RepoRule, and extracted into an AttributeUtils class.
    • The label-validation logic that used to live in AttributeValues is also moved into AttributeUtils.
  • AttributeValues now explicitly requires all attribute values to be valid Starlark values, instead of performing another transformation on construction. IMO this improves clarity.
  • bazel mod show_repo now uses its own "repo definition printer", which also does away with a lot of useless information (like the call stack of repo rules -- the location suffices).

Work towards #26131.

@Wyverald Wyverald requested a review from fmeum July 8, 2025 04:15
@Wyverald Wyverald requested a review from meteorcloudy as a code owner July 8, 2025 04:15
@github-actions github-actions bot added team-Performance Issues for Performance teams team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Jul 8, 2025
Apologies for the size of this CL, but I couldn't really see a way to do this in incremental steps while actually exercising the new logic.

- When in the context of repos, `Rule` is replaced with `RepoDefinition` and `RuleClass` is replaced with `RepoRule`.
  - In a follow-up, we can remove all repo-related logic from `Rule` and `Package`.
- `BzlmodRepoRuleFunction`/`Value` are moved into the `lib/bazel/repository` package and renamed to `RepoDefinitionFunction`/`Value`.
- The logic to type-check attribute values is now shared between `TypeCheckedTag` and `RepoRule`, and extracted into an `AttributeUtils` class.
  - The label-validation logic that used to live in `AttributeValues` is also moved into `AttributeUtils`.
- `AttributeValues` now explicitly requires all attribute values to be valid Starlark values, instead of performing another transformation on construction. IMO this improves clarity.
- `bazel mod show_repo` now uses its own "repo definition printer", which also does away with a lot of useless information (like the call stack of repo rules -- the location suffices).

Work towards #26131.

Closes #26493.

PiperOrigin-RevId: 778681107
Change-Id: I7b66720e8bbe5a756bc216fd07fd1b7e6c21ab3c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Performance Issues for Performance teams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants