diff --git a/shell/private/sh_executable.bzl b/shell/private/sh_executable.bzl
index 105484e..e55f5a5 100644
--- a/shell/private/sh_executable.bzl
+++ b/shell/private/sh_executable.bzl
@@ -32,6 +32,8 @@ def _sh_executable_impl(ctx):
direct_files = [src]
transitive_files = []
runfiles = ctx.runfiles(collect_default = True)
+ for target in ctx.attr.tools:
+ runfiles = runfiles.merge(target[DefaultInfo].default_runfiles)
entrypoint = ctx.actions.declare_file(ctx.label.name)
if ctx.attr.use_bash_launcher:
@@ -89,14 +91,16 @@ exec "$(rlocation "{src}")" "$@"
instrumented_files_info = coverage_common.instrumented_files_info(
ctx,
source_attributes = ["srcs"],
- dependency_attributes = ["deps", "_runfiles_dep", "data"],
+ dependency_attributes = ["deps", "_runfiles_dep", "data", "tools"],
)
+ locations = ctx.attr.data + ctx.attr.tools
+
run_environment_info = RunEnvironmentInfo(
environment = {
key: ctx.expand_make_variables(
"env",
- ctx.expand_location(value, ctx.attr.data, short_paths = True),
+ ctx.expand_location(value, locations, short_paths = True),
{},
)
for key, value in ctx.attr.env.items()
@@ -209,6 +213,15 @@ most build rules.
),
"env": attr.string_dict(),
"env_inherit": attr.string_list(),
+ "tools": attr.label_list(
+ cfg = config.exec(),
+ allow_files = True,
+ doc = """
+The list of tool dependencies, similar to genrule's equivalent. You can use
+this to ensure that any helper binaries your scripts need are built in the exec
+configuration.
+""",
+ ),
"use_bash_launcher": attr.bool(
doc = "Use a bash launcher initializing the runfiles library",
),
diff --git a/shell/private/sh_library.bzl b/shell/private/sh_library.bzl
index 2f3613c..49d3161 100644
--- a/shell/private/sh_library.bzl
+++ b/shell/private/sh_library.bzl
@@ -25,6 +25,8 @@ def _sh_library_impl(ctx):
transitive_files.append(target[DefaultInfo].files)
for target in ctx.attr.data:
transitive_files.append(target[DefaultInfo].files)
+ for target in ctx.attr.tools:
+ transitive_files.append(target[DefaultInfo].files)
files = depset(transitive = transitive_files)
runfiles = ctx.runfiles(transitive_files = files, collect_default = True)
@@ -32,7 +34,7 @@ def _sh_library_impl(ctx):
instrumented_files_info = coverage_common.instrumented_files_info(
ctx,
source_attributes = ["srcs"],
- dependency_attributes = ["deps", "data"],
+ dependency_attributes = ["deps", "data", "tools"],
)
return [
@@ -112,6 +114,15 @@ most build rules.
interpreted program source code depended on by the code in srcs. The files
provided by these rules will be present among the runfiles of this target.