Skip to content

Commit

Permalink
feat(run_binary): add resource_set attribute (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard authored Jan 9, 2025
1 parent d042d56 commit 38aa731
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ bzl_library(
deps = [
":expand_variables",
":strings",
"//lib:resource_sets",
"//lib:stamping",
"@bazel_skylib//lib:dicts",
],
Expand Down
6 changes: 4 additions & 2 deletions lib/private/run_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""run_binary implementation"""

load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("//lib:resource_sets.bzl", "resource_set", "resource_set_attr")
load("//lib:stamping.bzl", "STAMP_ATTRS", "maybe_stamp")
load(":expand_variables.bzl", "expand_variables")
load(":strings.bzl", "split_args")
Expand Down Expand Up @@ -66,6 +67,7 @@ Possible fixes:
inputs = inputs,
executable = ctx.executable.tool,
arguments = [args],
resource_set = resource_set(ctx.attr),
mnemonic = ctx.attr.mnemonic if ctx.attr.mnemonic else None,
progress_message = ctx.attr.progress_message if ctx.attr.progress_message else None,
execution_requirements = ctx.attr.execution_requirements if ctx.attr.execution_requirements else None,
Expand All @@ -79,7 +81,7 @@ Possible fixes:

_run_binary = rule(
implementation = _run_binary_impl,
attrs = dict({
attrs = dicts.add({
"tool": attr.label(
executable = True,
allow_files = True,
Expand All @@ -97,7 +99,7 @@ _run_binary = rule(
"progress_message": attr.string(),
"execution_requirements": attr.string_dict(),
"use_default_shell_env": attr.bool(),
}, **STAMP_ATTRS),
}, resource_set_attr, STAMP_ATTRS),
)

def run_binary(
Expand Down
2 changes: 2 additions & 0 deletions lib/tests/run_binary/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ run_binary(
mnemonic = "SomeAction",
out_dirs = ["dir_a_out"],
progress_message = "doing some work to make %{output}",
# Tell Bazel to reserve more than the default 250MB of RAM
resource_set = "mem_512m",
tool = ":make_dir_a",
)

Expand Down

0 comments on commit 38aa731

Please sign in to comment.