From 7b68549c927fb689d8191246608be8c0acc81a22 Mon Sep 17 00:00:00 2001 From: John Cater Date: Fri, 29 May 2026 13:46:47 -0400 Subject: [PATCH 1/2] Update examples to use `ctx.actions.args()`. --- rules/actions_run/execute.bzl | 6 ++++-- rules/computed_dependencies/hash.bzl | 11 +++++++++-- rules/runfiles/tool.bzl | 4 +++- rules/shell_command/rules.bzl | 5 ++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/rules/actions_run/execute.bzl b/rules/actions_run/execute.bzl index 857c75100..e00fab09d 100644 --- a/rules/actions_run/execute.bzl +++ b/rules/actions_run/execute.bzl @@ -9,13 +9,15 @@ the attribute "merge_tool". def _impl(ctx): # The list of arguments we pass to the script. - args = [ctx.outputs.out.path] + [f.path for f in ctx.files.chunks] + args = ctx.actions.args() + args.add(ctx.outputs.out) + args.add_all(ctx.files.chunks) # Action to call the script. ctx.actions.run( inputs = ctx.files.chunks, outputs = [ctx.outputs.out], - arguments = args, + arguments = [args], progress_message = "Merging into %s" % ctx.outputs.out.short_path, executable = ctx.executable.merge_tool, ) diff --git a/rules/computed_dependencies/hash.bzl b/rules/computed_dependencies/hash.bzl index 5979cc312..77a439adc 100644 --- a/rules/computed_dependencies/hash.bzl +++ b/rules/computed_dependencies/hash.bzl @@ -34,11 +34,14 @@ def _impl(ctx): processed = ctx.actions.declare_file(ctx.label.name + "_processed") # Run the selected binary + args = ctx.actions.args() + args.add(ctx.file.src) + args.add(processed) ctx.actions.run( outputs = [processed], inputs = [ctx.file.src], progress_message = "Apply filter '%s'" % ctx.attr.filter, - arguments = [ctx.file.src.path, processed.path], + arguments = [args], executable = ctx.executable._filter_bin, ) @@ -60,11 +63,15 @@ with open(sys.argv[2], 'w') as f: """, ) + args = ctx.actions.args() + args.add(hasher) + args.add(processed) + args.add(out) ctx.actions.run( outputs = [out], inputs = [processed, hasher], executable = "python3", - arguments = [hasher.path, processed.path, out.path], + arguments = [args], mnemonic = "ComputeHash", ) diff --git a/rules/runfiles/tool.bzl b/rules/runfiles/tool.bzl index 797791aef..631022d45 100644 --- a/rules/runfiles/tool.bzl +++ b/rules/runfiles/tool.bzl @@ -74,10 +74,12 @@ def _tool_user_impl(ctx): # are automatically added to the action. tool = ctx.executable.tool + args = ctx.actions.args() + args.add(my_out) ctx.actions.run( outputs = [my_out], executable = tool, - arguments = [my_out.path], + arguments = [args], ) return [DefaultInfo(files = depset([my_out]))] diff --git a/rules/shell_command/rules.bzl b/rules/shell_command/rules.bzl index ac18d183c..e7b9ebea6 100644 --- a/rules/shell_command/rules.bzl +++ b/rules/shell_command/rules.bzl @@ -60,10 +60,13 @@ def _convert_to_uppercase_impl(ctx): # Both the input and output files are specified by the BUILD file. in_file = ctx.file.input out_file = ctx.outputs.output + args = ctx.actions.args() + args.add(in_file) + args.add(out_file) ctx.actions.run_shell( outputs = [out_file], inputs = [in_file], - arguments = [in_file.path, out_file.path], + arguments = [args], command = "tr '[:lower:]' '[:upper:]' < \"$1\" > \"$2\"", ) # No need to return anything telling Bazel to build `out_file` when From 30f15b9e9ae94ce2dc70882fc7d46ca7b9e9522a Mon Sep 17 00:00:00 2001 From: John Cater Date: Fri, 29 May 2026 13:49:31 -0400 Subject: [PATCH 2/2] Updates rust examples --- rust-examples/09-oci-container/README.md | 5 ++++- rust-examples/09-oci-container/build/container.bzl | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rust-examples/09-oci-container/README.md b/rust-examples/09-oci-container/README.md index 06686b0f5..18ab46d3c 100644 --- a/rust-examples/09-oci-container/README.md +++ b/rust-examples/09-oci-container/README.md @@ -133,6 +133,9 @@ def _build_sha265_tag_impl(ctx): # Both the input and output files are specified by the BUILD file. in_file = ctx.file.input out_file = ctx.outputs.output + args = ctx.actions.args() + args.add(in_file) + args.add(out_file) # No need to return anything telling Bazel to build `out_file` when # building this target -- It's implied because the output is declared @@ -140,7 +143,7 @@ def _build_sha265_tag_impl(ctx): ctx.actions.run_shell( inputs = [in_file], outputs = [out_file], - arguments = [in_file.path, out_file.path], + arguments = [args], command = "sed -n 's/.*sha256:\\([[:alnum:]]\\{7\\}\\).*/\\1/p' < \"$1\" > \"$2\"", ) diff --git a/rust-examples/09-oci-container/build/container.bzl b/rust-examples/09-oci-container/build/container.bzl index a358dd8c2..907ffc34c 100644 --- a/rust-examples/09-oci-container/build/container.bzl +++ b/rust-examples/09-oci-container/build/container.bzl @@ -29,6 +29,9 @@ def _build_sha265_tag_impl(ctx): # Both the input and output files are specified by the BUILD file. in_file = ctx.file.input out_file = ctx.outputs.output + args = ctx.actions.args() + args.add(in_file) + args.add(out_file) # No need to return anything telling Bazel to build `out_file` when # building this target -- It's implied because the output is declared @@ -36,7 +39,7 @@ def _build_sha265_tag_impl(ctx): ctx.actions.run_shell( inputs = [in_file], outputs = [out_file], - arguments = [in_file.path, out_file.path], + arguments = [args], command = "sed -n 's/.*sha256:\\([[:alnum:]]\\{7\\}\\).*/\\1/p' < \"$1\" > \"$2\"", )