2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-27 17:43:27 +00:00
bazel-lib/docs/wrap_binary.md
2022-09-20 08:05:18 -07:00

1.7 KiB
Generated

Wraps binary rules to make them more compatible with Bazel.

Currently supports only Bash as the wrapper language, not cmd.exe.

Future additions might include:

  • wrap a binary such that it sees a tty on stdin
  • manipulate arguments or environment variables
  • redirect stdout/stderr, e.g. to silence buildspam on success
  • intercept exit code, e.g. to make an "expect_fail"
  • change user, e.g. to deal with containerized build running as root, but tool requires non-root
  • intercept signals, e.g. to make a tool behave as a Bazel persistent worker

chdir_binary

chdir_binary(name, binary, chdir, kwargs)

Wrap a *_binary to be executed under a given working directory.

Note: under bazel run, this is similar to the --run_under "cd $PWD &&" trick, but is hidden from the user so they don't need to know about that flag.

PARAMETERS

Name Description Default Value
name Name of the rule. none
binary Label of an executable target to wrap. none
chdir Argument for the cd command, the default is commonly used with bazel run to run the program in the root of the Bazel workspace, in the source tree. "$BUILD_WORKSPACE_DIRECTORY"
kwargs Additional named arguments for the resulting sh_binary rule. none