Skip to content

feat: add tools parameter to run_binary()#1252

Merged
jbedard merged 2 commits intobazel-contrib:mainfrom
acozzette:tools
Apr 28, 2026
Merged

feat: add tools parameter to run_binary()#1252
jbedard merged 2 commits intobazel-contrib:mainfrom
acozzette:tools

Conversation

@acozzette
Copy link
Copy Markdown
Contributor

@acozzette acozzette commented Apr 21, 2026

One missing feature in run_binary() is that it does not support a way to provide any additional dependencies for the execution platform. All inputs other than the tool binary itself are built for the target platform. This means that, for example, there is no reliable way to provide another binary for the tool to invoke during the build action. If the execution and target platforms are sufficiently different then this will fail.

This change remedies the problem by introducing a new tools parameter analogous to the one on
genrule. This parameter works similarly to srcs except that it builds the dependencies in the exec configuration.

Fixes #676.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@acozzette acozzette force-pushed the tools branch 2 times, most recently from e5aec35 to ee5429d Compare April 24, 2026 15:45
@jbedard jbedard requested review from alexeagle and jbedard April 24, 2026 21:15
@jbedard jbedard requested a review from fmeum April 27, 2026 23:22
@jbedard
Copy link
Copy Markdown
Collaborator

jbedard commented Apr 27, 2026

LGTM but I'd like at least one more reviewer to take a look before adding a new param like this. @alexeagle or @fmeum?

@jbedard
Copy link
Copy Markdown
Collaborator

jbedard commented Apr 28, 2026

or @kormide?

Comment thread lib/private/run_binary.bzl Outdated
One missing feature in `run_binary()` is that it does not support a way to
provide any additional dependencies for the execution platform. All inputs
other than the `tool` binary itself are built for the target platform. This
means that, for example, there is no reliable way to provide another binary for
the tool to invoke during the build action. If the execution and target
platforms are sufficiently different then this will fail.

This change remedies the problem by introducing a new `tools` parameter
analogous to the one on
[genrule](https://bazel.build/reference/be/general#genrule.tools). This
parameter works similarly to `srcs` except that it builds the dependencies in
the `exec` configuration.

Fixes bazel-contrib#676.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@kormide kormide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I appreciate the thorough and clever testing.

Comment thread lib/tests/run_binary/BUILD.bazel Outdated
Comment thread lib/tests/run_binary/BUILD.bazel
Comment thread lib/tests/run_binary/BUILD.bazel Outdated
@jbedard jbedard merged commit dd01826 into bazel-contrib:main Apr 28, 2026
19 checks passed
@acozzette acozzette deleted the tools branch April 28, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR]: Allow additional tools to be passed to run_binary

4 participants