bazelbuild / bazel-skylib

Common useful functions and rules for Bazel
https://bazel.build/
Apache License 2.0
387 stars 180 forks source link

Variation of `run_binary` to capture `stdout` and/or `stderr` #441

Open kriswuollett opened 1 year ago

kriswuollett commented 1 year ago

The run_binary rule assumes that the output to be captured is written to file(s) by the binary either in implied or through args location(s). This does not completely replace the usage of genrule because the use case of capturing output from a stdout-only binary is not supported. Is it possible to capture output in Bazel, or does this use case still have to be done through genrule?

tetromino commented 1 year ago

Currently, ctx.actions.run as far as I can tell cannot redirect output without using bash (or cmd.exe on Windows), and using bash would defeat the point of run_binary - you may as well use genrule :)

So while this feature may be desirable, it first needs Bazel support to be added.

kriswuollett commented 1 year ago

Thanks for the quick response, I was able to then search the Bazel repo and found the request for it in bazelbuild/bazel#5511.