Skip to content

Commit

Permalink
feat: import toolchains to use for copy actions
Browse files Browse the repository at this point in the history
Register the "coreutils" toolchains using definitions imported from
the "bazel_lib" Bazel repository in order to allow use of this module
with "bazel_lib" version 2 and later.
  • Loading branch information
seh authored and alexeagle committed Jan 31, 2024
1 parent 397da8c commit b981e98
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 12 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ http_archive(
EOF

awk 'f;/--SNIP--/{f=1}' e2e/smoke/WORKSPACE.bazel
echo "\`\`\`"
echo "\`\`\`"

cat << EOF
To use rules_webpack with bazel-lib 2.0, you must additionally register the coreutils toolchain.
\`\`\`starlark
load("@aspect_bazel_lib//lib:repositories.bzl", "register_coreutils_toolchains")
register_coreutils_toolchains()
\`\`\`
EOF
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module(
compatibility_level = 1,
)

bazel_dep(name = "aspect_bazel_lib", version = "1.32.0")
bazel_dep(name = "aspect_rules_js", version = "1.29.2")
bazel_dep(name = "aspect_bazel_lib", version = "1.38.1")
bazel_dep(name = "aspect_rules_js", version = "1.34.0")
bazel_dep(name = "bazel_skylib", version = "1.4.1")

bazel_dep(name = "gazelle", version = "0.29.0", dev_dependency = True, repo_name = "bazel_gazelle")
Expand Down
6 changes: 4 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "register_coreutils_toolchains")

aspect_bazel_lib_dependencies(override_local_config_platform = True)
aspect_bazel_lib_dependencies()

register_coreutils_toolchains()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")

Expand Down
4 changes: 4 additions & 0 deletions e2e/loaders/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ load("@aspect_rules_webpack//webpack:dependencies.bzl", "rules_webpack_dependenc

rules_webpack_dependencies()

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

# Fetch and register a nodejs interpreter, if you haven't already

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
Expand Down
4 changes: 4 additions & 0 deletions e2e/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ load("@aspect_rules_webpack//webpack:dependencies.bzl", "rules_webpack_dependenc

rules_webpack_dependencies()

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

# Fetch and register a nodejs interpreter, if you haven't already

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
Expand Down
4 changes: 4 additions & 0 deletions e2e/worker/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ load("@aspect_rules_webpack//webpack:dependencies.bzl", "rules_webpack_dependenc

rules_webpack_dependencies()

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

# Fetch and register a nodejs interpreter, if you haven't already

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
Expand Down
9 changes: 9 additions & 0 deletions internal_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ load("//webpack/private:maybe.bzl", http_archive = "maybe_http_archive")

def rules_webpack_internal_deps():
"Fetch repositories used for developing the rules"

# opt-in to 2.0 without forcing users to do so
http_archive(
name = "aspect_bazel_lib",
sha256 = "c858cc637db5370f6fd752478d1153955b4b4cbec7ffe95eb4a47a48499a79c3",
strip_prefix = "bazel-lib-2.0.3",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.0.3/bazel-lib-v2.0.3.tar.gz",
)

http_archive(
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
Expand Down
12 changes: 6 additions & 6 deletions webpack/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ def rules_webpack_dependencies():

http_archive(
name = "aspect_bazel_lib",
sha256 = "e3151d87910f69cf1fc88755392d7c878034a69d6499b287bcfc00b1cf9bb415",
strip_prefix = "bazel-lib-1.32.1",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.32.1/bazel-lib-v1.32.1.tar.gz",
sha256 = "262e3d6693cdc16dd43880785cdae13c64e6a3f63f75b1993c716295093d117f",
strip_prefix = "bazel-lib-1.38.1",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.38.1/bazel-lib-v1.38.1.tar.gz",
)

http_archive(
name = "aspect_rules_js",
sha256 = "7cb2d84b7d5220194627c9a0267ae599e357350e75ea4f28f337a25ca6219b83",
strip_prefix = "rules_js-1.29.2",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.29.2/rules_js-v1.29.2.tar.gz",
sha256 = "d9ceb89e97bb5ad53b278148e01a77a3e9100db272ce4ebdcd59889d26b9076e",
strip_prefix = "rules_js-1.34.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.34.0/rules_js-v1.34.0.tar.gz",
)

http_archive(
Expand Down
4 changes: 3 additions & 1 deletion webpack/private/webpack_bundle.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Webpack bundle producing rule definition."""

load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_files_to_bin_actions")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS", "copy_files_to_bin_actions")
load("@aspect_bazel_lib//lib:expand_make_vars.bzl", "expand_locations", "expand_variables")
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@aspect_rules_js//js:libs.bzl", "js_lib_helpers")
Expand Down Expand Up @@ -233,12 +233,14 @@ lib = struct(
implementation = _impl,
attrs = _attrs,
outputs = _outs,
toolchains = COPY_FILE_TO_BIN_TOOLCHAINS,
)

_webpack_bundle = rule(
implementation = lib.implementation,
attrs = lib.attrs,
outputs = lib.outputs,
toolchains = lib.toolchains,
doc = "",
)

Expand Down

0 comments on commit b981e98

Please sign in to comment.