-
Notifications
You must be signed in to change notification settings - Fork 4.4k
existing_rule and rule.outputs use different Starlark representations for attributes #2883
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)This is either out of scope or we don't have bandwidth to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)Issues or PRs that are stale (no activity for 30 days)team-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactsAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: feature requestuntriaged
Description
(this issue originally reported by @alandonovan)
Observe the output of the program below:
$ cat t/BUILD
load(":inc.bzl", "r")
r(
name = "myrule",
src = "a",
)
print(type(native.existing_rule("myrule")["src"])) # "string"
$ cat t/inc.bzl
def _implicit_outputs(src):
return {"": "%s" % type(src)} # "Label"
def _implementation():
pass
r = rule(
outputs = _implicit_outputs,
implementation = _implementation,
attrs = {
"src": attr.label(),
},
)
$ blaze query t:*
WARNING: /google/src/cloud/adonovan/gbuild/google3/t/BUILD:8:1: string.
//t:Label
//t:myrule
//t:a
//t:BUILD
The existing_rule function converts a rule's attribute dictionary back into Skylark form. Similarly, the rule.outputs function converts some rule attributes into Skylark form. However, they use different conversion logic. For example, existing_rule converts labels to strings whereas rule.outputs preserves labels as labels.
This is confusing to users, since it requires twice as much documentation to specify (or would do, if either conversion were actually documented), and confusing to implementors, since it requires twice as much logic to implement.
They should use the same logic.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P4This is either out of scope or we don't have bandwidth to review a PR. (No assignee)This is either out of scope or we don't have bandwidth to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)Issues or PRs that are stale (no activity for 30 days)team-Rules-APIAPI for writing rules/aspects: providers, runfiles, actions, artifactsAPI for writing rules/aspects: providers, runfiles, actions, artifactstype: feature requestuntriaged