bazel-lib icon indicating copy to clipboard operation
bazel-lib copied to clipboard

Feature request: genrule with directory output / run_binary with command input

Open barryam3 opened this issue 1 year ago • 3 comments

I'm interested in a rule that takes a shell command string as input like genrule but supports directories as outputs like run_binary. Would the maintainers of this library be receptive to a PR adding one?

My intuition would be to add a rule run_shell that shares a lot of the code of run_binary. But I can also imagine just adding a parameter to run_binary (incompatible with tool).

Yes, one can just use run_binary with sh_binary, but that requires to targets instead of one, plus a .sh file (or a third write_file target). If your script is more than a few lines, that's probably the better approach anyways, but it feels like a lot of boilerplate when I just want to do a simple transformation over an indeterminate number of files.

barryam3 avatar Apr 04 '25 17:04 barryam3

@fmeum any thoughts about this design shape? I can see the case for it, but also want to keep a minimal API surface.

alexeagle avatar Jun 20 '25 18:06 alexeagle

@alexeagle I tend to agree. genrule but with output directories would be useful, but the best way to get it would be to add this functionality to genrule.

@barryam3 Have you checked whether there is a Bazel issue about this? If not, could you file one?

fmeum avatar Jun 20 '25 18:06 fmeum

I think this is tracked in Bazel by https://github.com/bazelbuild/bazel/issues/19030

I'll go ahead and leave a comment on that issue.

barryam3 avatar Jun 21 '25 18:06 barryam3