forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect rule class digest when creating rules through macros.
In bazelbuild@9f2cab5, I made a change of how we are getting th digest for rule classes. We used to get them from a `StarlarkThread` and we are getting them from the inner Starlark function on the call stack. In a simple case, that is correct since that inner call is the call to the `rule` function, however when we have a rule class created thrugh a macro, it will not account for `.bzl` files which pass values to it. Please consider an example of: `def.bzl`: ``` def create_rule_class(function): return rule(implementation=function) ``` We will include the transitive digest of `def.bzl`, but not of the callers to `create_rule_class`. This means that if `function` is defined outside of the transitively loaded moduesl of `def.bzl`, the rule class definition environment digest will not account for changes to `function` itself. As a result of this, the hash is incorrect since it will produce the same value for different implementations. Change the digest collection to be based on the outermost Starlark function call instead. This will take the callers into the macros into account and, consequently, include `.bzl` file with passed `function` implementation in the digest. Please note that for the simple case of declaring a rule, the innermost and outermost frame is the same, hence that case has the same semanticss. PiperOrigin-RevId: 331231462
- Loading branch information
Showing
2 changed files
with
150 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters