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

Add toolchain param to affected actions #668

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion docs/copy_directory.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/private/copy_directory.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def copy_directory_bin_action(
dst,
copy_directory_bin,
hardlink = "auto",
verbose = False):
verbose = False,
toolchain_type = "@aspect_bazel_lib//lib:copy_directory_toolchain_type"):
"""Factory function that creates an action to copy a directory from src to dst using a tool binary.

The tool binary will typically be the `@aspect_bazel_lib//tools/copy_directory` `go_binary`
Expand Down Expand Up @@ -52,6 +53,7 @@ def copy_directory_bin_action(
inputs = [src],
outputs = [dst],
executable = copy_directory_bin,
toolchain = toolchain_type,
arguments = args,
mnemonic = "CopyDirectory",
progress_message = "Copying directory %s" % _progress_path(src),
Expand Down
1 change: 1 addition & 0 deletions lib/private/copy_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def copy_file_action(ctx, src, dst, dir_path = None):

ctx.actions.run(
executable = coreutils.bin,
toolchain = _COREUTILS_TOOLCHAIN,
arguments = ["cp", src_path, dst.path],
inputs = [src],
outputs = [dst],
Expand Down
1 change: 1 addition & 0 deletions lib/private/copy_to_directory.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ def copy_to_directory_bin_action(
inputs = file_inputs + [config_file],
outputs = [dst],
executable = copy_to_directory_bin,
toolchain = "@aspect_bazel_lib//lib:copy_to_directory_toolchain_type",
arguments = [config_file.path, ctx.label.workspace_name],
mnemonic = "CopyToDirectory",
progress_message = "Copying files to directory %s" % _progress_path(dst),
Expand Down
1 change: 1 addition & 0 deletions lib/private/expand_template.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def _expand_template_impl(ctx):
outputs = [output],
inputs = inputs,
executable = expand_template_info.bin,
toolchain = "@aspect_bazel_lib//lib:expand_template_toolchain_type",
)
else:
ctx.actions.expand_template(
Expand Down
2 changes: 2 additions & 0 deletions lib/private/jq.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _jq_impl(ctx):
stamp_json = ctx.actions.declare_file("_%s_stamp.json" % ctx.label.name)
ctx.actions.run_shell(
tools = [jq_bin],
toolchain = "@aspect_bazel_lib//lib:jq_toolchain_type",
inputs = [stamp.stable_status_file, stamp.volatile_status_file, ctx.file._parse_status_file_filter],
outputs = [stamp_json],
command = "{jq} -s -R -f {filter} {stable} {volatile} > {out}".format(
Expand All @@ -69,6 +70,7 @@ def _jq_impl(ctx):

ctx.actions.run_shell(
tools = [jq_bin],
toolchain = "@aspect_bazel_lib//lib:jq_toolchain_type",
inputs = inputs,
outputs = [out],
command = cmd,
Expand Down
1 change: 1 addition & 0 deletions lib/private/run_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Possible fixes:
use_default_shell_env = False,
env = dicts.add(ctx.configuration.default_shell_env, envs),
input_manifests = tool_input_mfs,
toolchain = None,
)
return DefaultInfo(
files = depset(outputs),
Expand Down
1 change: 1 addition & 0 deletions lib/private/tar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def _tar_impl(ctx):

ctx.actions.run(
executable = bsdtar.tarinfo.binary,
toolchain = "@aspect_bazel_lib//lib:tar_toolchain_type",
inputs = depset(direct = inputs, transitive = [bsdtar.default.files] + [
src[DefaultInfo].default_runfiles.files
for src in ctx.attr.srcs
Expand Down
2 changes: 2 additions & 0 deletions lib/private/yq.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def _yq_impl(ctx):
# create an action that gives a YAML representation of the stamp keys
ctx.actions.run_shell(
tools = [yq_bin],
toolchain = "@aspect_bazel_lib//lib:yq_toolchain_type",
inputs = [stamp.stable_status_file, stamp.volatile_status_file, ctx.file._parse_status_file_expression],
outputs = [stamp_yaml],
command = "{yq} --from-file {expression} {stable} {volatile} > {out}".format(
Expand Down Expand Up @@ -86,6 +87,7 @@ def _yq_impl(ctx):

ctx.actions.run_shell(
tools = [yq_bin],
toolchain = "@aspect_bazel_lib//lib:yq_toolchain_type",
inputs = inputs,
outputs = outs,
command = cmd,
Expand Down
1 change: 1 addition & 0 deletions lib/tests/copy_directory_bin_action/pkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def _pkg_impl(ctx):
copy_directory_bin = ctx.executable._tool,
hardlink = "auto",
verbose = True,
toolchain_type = None,
)

return [
Expand Down