Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to include runfiles during run_binary #934

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/private/run_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Possible fixes:
inputs = ctx.files.srcs + [stamp.volatile_status_file, stamp.stable_status_file]
envs["BAZEL_STABLE_STATUS_FILE"] = stamp.stable_status_file.path
envs["BAZEL_VOLATILE_STATUS_FILE"] = stamp.volatile_status_file.path
elif ctx.attr.include_runfiles:
inputs = ctx.files.srcs + depset(transitive = [src[DefaultInfo].default_runfiles.files for src in ctx.attr.srcs]).to_list()
else:
inputs = ctx.files.srcs

Expand Down Expand Up @@ -90,6 +92,7 @@ _run_binary = rule(
"srcs": attr.label_list(
allow_files = True,
),
"include_runfiles": attr.bool(),
"out_dirs": attr.string_list(),
"outs": attr.output_list(),
"args": attr.string_list(),
Expand All @@ -109,6 +112,7 @@ def run_binary(
outs = [],
out_dirs = [],
mnemonic = "RunBinary",
include_runfiles = False,
progress_message = None,
execution_requirements = None,
use_default_shell_env = False,
Expand Down Expand Up @@ -177,6 +181,11 @@ def run_binary(

See https://docs.bazel.build/versions/main/be/common-definitions.html#common.tags for useful keys.

include_runfiles: Whether to include runfiles in the action's inputs.

If True, the runfiles of all sources are included in the action's inputs. This is useful
for bundlers that need to access the runfiles of their dependencies.

use_default_shell_env: Passed to the underlying ctx.actions.run.

May introduce non-determinism when True; use with care!
Expand Down Expand Up @@ -217,6 +226,7 @@ def run_binary(
outs = outs,
out_dirs = out_dirs,
mnemonic = mnemonic,
include_runfiles = include_runfiles,
progress_message = progress_message,
execution_requirements = execution_requirements,
use_default_shell_env = use_default_shell_env,
Expand Down
Loading