Skip to content

Commit e6420f3

Browse files
authored
feat: expand the usefulness of resource_sets (#1235)
This adds a new public function, `resource_set_for`, which takes a cpu and memory value and returns an appropriate `resource_set` function for those values, adding some support for the cross-product [mentioned in the previous pass](#792 (comment)). The bazel resource_set API isn't very easy to work with, and this hides the ugliness here, rather than expecting every module to implement something like [rules_rust did](https://github.com/bazelbuild/rules_rust/blob/f29a63cb3c473bd0158c8c9d3e0793a33187d505/rust/private/rustc_resource_set.bzl). The ugliness of the implementation is mitigated slightly by using a helper script to generate it, and I reason that people attempting to use the `resource_set` API would be better off with additional abstraction, so if/when this gets fixed in bazel, most people don't need to notice.
1 parent 8a8fcd6 commit e6420f3

File tree

7 files changed

+2424
-46
lines changed

7 files changed

+2424
-46
lines changed

lib/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,5 @@ bzl_library(
276276
bzl_library(
277277
name = "resource_sets",
278278
srcs = ["resource_sets.bzl"],
279+
deps = ["//lib/private:resource_sets"],
279280
)

lib/private/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ bzl_library(
289289
visibility = ["//lib:__subpackages__"],
290290
)
291291

292+
bzl_library(
293+
name = "resource_sets",
294+
srcs = ["resource_sets.bzl"],
295+
visibility = ["//lib:__subpackages__"],
296+
)
297+
292298
bzl_library(
293299
name = "source_toolchains_repo",
294300
srcs = ["source_toolchains_repo.bzl"],

0 commit comments

Comments
 (0)