Runs a binary as a build action. This rule does not require Bash (unlike native.genrule()).

This fork of bazel-skylib's run_binary adds directory output support and better makevar expansions.

Rules

run_binary

Runs a binary as a build action.

This rule does not require Bash (unlike native.genrule).

Example usage (generated)

load("@aspect_bazel_lib//lib:run_binary.bzl", "run_binary")

run_binary(
    # A unique name for this target.
    name = "",
    # The tool to run in the action.
    tool = "",
)

name

A unique name for this target.

args

Command line arguments of the binary.

Subject to$(location) expansion.

env

Environment variables of the action.

Subject to $(location) expansion.

output_dir

Set to True if you want the output to be a directory. Exactly one of outs, output_dir may be used. If you output a directory, there can only be one output, which will be a directory named the same as the target.

outs

Output files generated by the action.

These labels are available for $(location) expansion in args and env.

srcs

Additional inputs of the action.

These labels are available for $(location) expansion in args and env.

tool

The tool to run in the action.

Must be the label of a *_binary rule, of a rule that generates an executable file, or of a file that can be executed as a subprocess (e.g. an .exe or .bat file on Windows or a binary with executable permission on Linux). This label is available for $(location) expansion in args and env.