mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
The framework fundamentally relies on the continuation API added in Java 21 (which is currently internal to the JDK). Continuations allow for call stacks to be saved to the heap and resumed later. The async framework allows command bodies to be written in an imperative style. However, an async command will need to be actively cooperative and periodically call coroutine.yield() in loops to yield control back to the command scheduler to let it process other commands. There are also some other additions like priority levels (as opposed to a blanket yes/no for ignoring incoming commands), factories requiring names be provided for commands, and the scheduler tracking all running commands and not just the highest-level groups. However, those changes aren't unique to an async framework, and could just as easily be used in a traditional command framework.
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
def __generate_commandsv3_impl(ctx):
|
|
"""
|
|
Custom rule used to create the commandsv3 pre-generated files. See `./README-Bazel.md` for the reasoning.
|
|
"""
|
|
output_dir = ctx.actions.declare_directory("_gendir")
|
|
|
|
args = ctx.actions.args()
|
|
args.add("--output_directory", output_dir.path)
|
|
args.add("--template_root", "commandsv3/src/generate")
|
|
args.add("--protoc", ctx.executable._protoc)
|
|
args.add("--quickbuf_plugin", ctx.executable._quickbuf)
|
|
|
|
ctx.actions.run(
|
|
inputs = ctx.attr._templates.files,
|
|
outputs = [output_dir],
|
|
executable = ctx.executable._tool,
|
|
arguments = [args],
|
|
tools = [ctx.executable._protoc, ctx.executable._quickbuf],
|
|
)
|
|
|
|
return [DefaultInfo(files = depset([output_dir]))]
|
|
|
|
generate_commandsv3 = rule(
|
|
implementation = __generate_commandsv3_impl,
|
|
attrs = {
|
|
"_protoc": attr.label(
|
|
default = Label("@com_google_protobuf//:protoc"),
|
|
cfg = "exec",
|
|
executable = True,
|
|
),
|
|
"_quickbuf": attr.label(
|
|
default = Label("//:quickbuf_protoc"),
|
|
cfg = "exec",
|
|
executable = True,
|
|
),
|
|
"_templates": attr.label(
|
|
default = Label("//commandsv3:templates"),
|
|
),
|
|
"_tool": attr.label(
|
|
default = Label("//commandsv3:generate_files"),
|
|
cfg = "exec",
|
|
executable = True,
|
|
),
|
|
},
|
|
)
|