<#19730 Introduce call-by-name syntax for `@rules`...
# github-notifications
q
#19730 Introduce call-by-name syntax for `@rules` Issue created by stuhood (as motivated in #18905) Implementation: 1.
rule_graph
crate changes: • adjust the definition of
Get
(
DependencyKey
) for rule-graph solving to accept a fixed name/identifier for the rule to use, and some/all of its positional arguments • adjust graph solving to use the explicitly specified arguments to skip solving 2. syntax changes: • adjust the rule visitor (
AwaitableCollector
) to support extracting directly called
@rules
, in addition to the existing support for "rule helpers" • introduce an
implicitly(..)
builtin, which takes arguments similar to
Get(TypeName, ..)
• add support for positional arguments to
@rule
calls • implement support for call-by-name in
MultiGet
syntax • expose intrinsics as call-by-name (#20874) • determine new
@union
-usage syntax (or keep it type driven) 3. runtime changes: • adjust the
@rule
decorator such that when it has been called directly (i.e., not called with some secret-handshake), it trampolines back out to fill the additional positional arguments and to begin memoization • applies to both
async def
and
def
@rules
, since the act of memoizing can potentially mean blocking to wait for a result computed by another task • Use the
@rule
ids introduced in #19755 to drive
@rule
solving 4. deployment: • #20572 - add a
pants
-builtin goal which will execute a rewrite of one or more specified plugins or files from
await Get(TypeName, ..)
->
await rule_name(.., **implicitly(..))
• this requires rule-graph solving first (to select the
@rule
to use at each
Get
callsite), so the rewritten file must actually have been loaded • #21065 - migrate pants' code • Audit and change
@rule
names that are widely used in plugins/in-repo-backends in cases where they are not sufficiently descriptive. • Update docs for new syntax pantsbuild/pants