Skip to content

Commit

Permalink
refactor: also register bazel-lib coreutils toolchain now that we dep…
Browse files Browse the repository at this point in the history
…end on a mininum bazel-lib 2.6.1 (#1582)
  • Loading branch information
gregmagolan committed May 20, 2024
1 parent 04fdac9 commit 6712a19
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 23 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,3 @@ EOF

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

cat <<EOF
To use rules_js with bazel-lib 2.x, you must additionally register the coreutils toolchain.
\`\`\`starlark
load("@aspect_bazel_lib//lib:repositories.bzl", "register_coreutils_toolchains")
register_coreutils_toolchains()
\`\`\`
EOF
4 changes: 1 addition & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ load("//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

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

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

register_expand_template_toolchains()

Expand Down
5 changes: 3 additions & 2 deletions docs/npm_translate_lock.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions e2e/pnpm_workspace/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

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

aspect_bazel_lib_dependencies()

register_coreutils_toolchains()

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

nodejs_register_toolchains(
Expand Down
4 changes: 1 addition & 3 deletions e2e/pnpm_workspace_deps/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

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

aspect_bazel_lib_dependencies()

register_coreutils_toolchains()

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

nodejs_register_toolchains(
Expand Down
1 change: 1 addition & 0 deletions npm/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def _npm_translate_lock_bzlmod(attr):
quiet = attr.quiet,
register_copy_directory_toolchains = False, # this registration is handled elsewhere with bzlmod
register_copy_to_directory_toolchains = False, # this registration is handled elsewhere with bzlmod
register_coreutils_toolchains = False, # this registration is handled elsewhere with bzlmod
register_yq_toolchains = False, # this registration is handled elsewhere with bzlmod
register_tar_toolchains = False, # this registration is handled elsewhere with bzlmod
replace_packages = attr.replace_packages,
Expand Down
14 changes: 13 additions & 1 deletion npm/private/npm_translate_lock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ Advanced users may want to directly fetch a package from npm rather than start f
"""

load("@bazel_skylib//lib:paths.bzl", "paths")
load("@aspect_bazel_lib//lib:repositories.bzl", _register_copy_directory_toolchains = "register_copy_directory_toolchains", _register_copy_to_directory_toolchains = "register_copy_to_directory_toolchains", _register_tar_toolchains = "register_tar_toolchains", _register_yq_toolchains = "register_yq_toolchains")
load(
"@aspect_bazel_lib//lib:repositories.bzl",
_register_copy_directory_toolchains = "register_copy_directory_toolchains",
_register_copy_to_directory_toolchains = "register_copy_to_directory_toolchains",
_register_coreutils_toolchains = "register_coreutils_toolchains",
_register_tar_toolchains = "register_tar_toolchains",
_register_yq_toolchains = "register_yq_toolchains",
)
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
load(":list_sources.bzl", "list_sources")
load(":npm_translate_lock_generate.bzl", "generate_repository_files")
Expand Down Expand Up @@ -188,6 +195,7 @@ def npm_translate_lock(
use_pnpm = None,
register_copy_directory_toolchains = True,
register_copy_to_directory_toolchains = True,
register_coreutils_toolchains = True,
register_yq_toolchains = True,
register_tar_toolchains = True,
npm_package_target_name = "{dirname}",
Expand Down Expand Up @@ -508,6 +516,8 @@ def npm_translate_lock(
register_copy_to_directory_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_copy_to_directory_toolchains()` is called if the toolchain is not already registered
register_coreutils_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_coreutils_toolchains()` is called if the toolchain is not already registered
register_yq_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_yq_toolchains()` is called if the toolchain is not already registered
register_tar_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_tar_toolchains()` is called if the toolchain is not already registered
Expand Down Expand Up @@ -554,6 +564,8 @@ def npm_translate_lock(
_register_copy_directory_toolchains()
if register_copy_to_directory_toolchains and not native.existing_rule("copy_to_directory_toolchains"):
_register_copy_to_directory_toolchains()
if register_coreutils_toolchains and not native.existing_rule("register_coreutils_toolchains"):
_register_coreutils_toolchains()
if register_yq_toolchains and not native.existing_rule("yq_toolchains"):
_register_yq_toolchains()
if register_tar_toolchains and not native.existing_rule("tar_toolchains"):
Expand Down

0 comments on commit 6712a19

Please sign in to comment.