2025-05-14 01:01:47 -04:00
|
|
|
def __generate_wpilib_new_commands_impl(ctx):
|
|
|
|
|
"""
|
2025-11-07 19:55:39 -05:00
|
|
|
Custom rule used to create the commandsv2 pre-generated files. See `./README-Bazel.md` for the reasoning.
|
2025-05-14 01:01:47 -04:00
|
|
|
"""
|
|
|
|
|
output_dir = ctx.actions.declare_directory("_gendir")
|
|
|
|
|
|
|
|
|
|
args = ctx.actions.args()
|
|
|
|
|
args.add("--output_directory", output_dir.path)
|
2025-11-07 19:55:39 -05:00
|
|
|
args.add("--template_root", "commandsv2/src/generate")
|
2026-06-11 16:06:45 -07:00
|
|
|
args.add("--python_output_directory", "__none__")
|
2025-05-14 01:01:47 -04:00
|
|
|
|
|
|
|
|
ctx.actions.run(
|
|
|
|
|
inputs = ctx.attr._templates.files,
|
|
|
|
|
outputs = [output_dir],
|
|
|
|
|
executable = ctx.executable._tool,
|
|
|
|
|
arguments = [args],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return [DefaultInfo(files = depset([output_dir]))]
|
|
|
|
|
|
|
|
|
|
generate_wpilib_new_commands = rule(
|
|
|
|
|
implementation = __generate_wpilib_new_commands_impl,
|
|
|
|
|
attrs = {
|
|
|
|
|
"_templates": attr.label(
|
2025-11-07 19:55:39 -05:00
|
|
|
default = Label("//commandsv2:templates"),
|
2025-05-14 01:01:47 -04:00
|
|
|
),
|
|
|
|
|
"_tool": attr.label(
|
2025-11-07 19:55:39 -05:00
|
|
|
default = Label("//commandsv2:generate_hids"),
|
2025-05-14 01:01:47 -04:00
|
|
|
cfg = "exec",
|
|
|
|
|
executable = True,
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
)
|