Skip to content

Commit 38aa731

Browse files
authored
feat(run_binary): add resource_set attribute (#1024)
Ref aspect-build/rules_js#2015
1 parent d042d56 commit 38aa731

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/private/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ bzl_library(
211211
deps = [
212212
":expand_variables",
213213
":strings",
214+
"//lib:resource_sets",
214215
"//lib:stamping",
215216
"@bazel_skylib//lib:dicts",
216217
],

lib/private/run_binary.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""run_binary implementation"""
1616

1717
load("@bazel_skylib//lib:dicts.bzl", "dicts")
18+
load("//lib:resource_sets.bzl", "resource_set", "resource_set_attr")
1819
load("//lib:stamping.bzl", "STAMP_ATTRS", "maybe_stamp")
1920
load(":expand_variables.bzl", "expand_variables")
2021
load(":strings.bzl", "split_args")
@@ -66,6 +67,7 @@ Possible fixes:
6667
inputs = inputs,
6768
executable = ctx.executable.tool,
6869
arguments = [args],
70+
resource_set = resource_set(ctx.attr),
6971
mnemonic = ctx.attr.mnemonic if ctx.attr.mnemonic else None,
7072
progress_message = ctx.attr.progress_message if ctx.attr.progress_message else None,
7173
execution_requirements = ctx.attr.execution_requirements if ctx.attr.execution_requirements else None,
@@ -79,7 +81,7 @@ Possible fixes:
7981

8082
_run_binary = rule(
8183
implementation = _run_binary_impl,
82-
attrs = dict({
84+
attrs = dicts.add({
8385
"tool": attr.label(
8486
executable = True,
8587
allow_files = True,
@@ -97,7 +99,7 @@ _run_binary = rule(
9799
"progress_message": attr.string(),
98100
"execution_requirements": attr.string_dict(),
99101
"use_default_shell_env": attr.bool(),
100-
}, **STAMP_ATTRS),
102+
}, resource_set_attr, STAMP_ATTRS),
101103
)
102104

103105
def run_binary(

lib/tests/run_binary/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ run_binary(
3535
mnemonic = "SomeAction",
3636
out_dirs = ["dir_a_out"],
3737
progress_message = "doing some work to make %{output}",
38+
# Tell Bazel to reserve more than the default 250MB of RAM
39+
resource_set = "mem_512m",
3840
tool = ":make_dir_a",
3941
)
4042

0 commit comments

Comments
 (0)