Skip to content

Commit

Permalink
refactor: remove legacy node toolchain
Browse files Browse the repository at this point in the history
At this point everything should be using the new one
  • Loading branch information
alexeagle committed Dec 23, 2021
1 parent f050354 commit f2eb60f
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 385 deletions.
1 change: 0 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ pkg_npm(
"//third_party/npm/node_modules/named-amd:package_contents",
"//toolchains/cypress:package_contents",
"//toolchains/esbuild:package_contents",
"//toolchains/node:package_contents",
],
)

Expand Down
70 changes: 0 additions & 70 deletions docs/Toolchains.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,76 +52,6 @@ Defaults to `""`
Defaults to `None`


## node_toolchain

**USAGE**

<pre>
node_toolchain(<a href="#node_toolchain-name">name</a>, <a href="#node_toolchain-target_tool">target_tool</a>, <a href="#node_toolchain-target_tool_path">target_tool_path</a>)
</pre>

Defines a node toolchain.

For usage see https://docs.bazel.build/versions/main/toolchains.html#defining-toolchains.


**ATTRIBUTES**


<h4 id="node_toolchain-name">name</h4>

(*<a href="https://bazel.build/docs/build-ref.html#name">Name</a>, mandatory*): A unique name for this target.


<h4 id="node_toolchain-target_tool">target_tool</h4>

(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): A hermetically downloaded nodejs executable target for the target platform.

Defaults to `None`

<h4 id="node_toolchain-target_tool_path">target_tool_path</h4>

(*String*): Path to an existing nodejs executable for the target platform.

Defaults to `""`


## node_toolchain_configure

**USAGE**

<pre>
node_toolchain_configure(<a href="#node_toolchain_configure-name">name</a>, <a href="#node_toolchain_configure-repo_mapping">repo_mapping</a>, <a href="#node_toolchain_configure-target_tool">target_tool</a>, <a href="#node_toolchain_configure-target_tool_path">target_tool_path</a>)
</pre>

Creates an external repository with a node_toolchain //:toolchain target properly configured.

**ATTRIBUTES**


<h4 id="node_toolchain_configure-name">name</h4>

(*<a href="https://bazel.build/docs/build-ref.html#name">Name</a>, mandatory*): A unique name for this repository.


<h4 id="node_toolchain_configure-repo_mapping">repo_mapping</h4>

(*<a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a>, mandatory*): A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).


<h4 id="node_toolchain_configure-target_tool">target_tool</h4>

(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): Target for a downloaded nodejs binary for the target os.

Defaults to `None`

<h4 id="node_toolchain_configure-target_tool_path">target_tool_path</h4>

(*String*): Absolute path to a pre-installed nodejs binary for the target os.

Defaults to `""`


## configure_esbuild_toolchains

**USAGE**
Expand Down
2 changes: 1 addition & 1 deletion e2e/nodejs_image/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nodejs_binary(
entry_point = "main.js",
)

# bazel run --platforms=@build_bazel_rules_nodejs//toolchains/node:linux_amd64 //:nodejs_image
# bazel run --platforms=@rules_nodejs//:linux_amd64 //:nodejs_image
nodejs_image(
name = "nodejs_image",
binary = ":main",
Expand Down
1 change: 0 additions & 1 deletion internal/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ bzl_library(
"//internal/npm_install:bzl",
"//nodejs:bzl",
"//third_party/github.com/bazelbuild/bazel-skylib:bzl",
"//toolchains/node:bzl",
"@rules_nodejs//nodejs:bzl",
],
)
Expand Down
7 changes: 0 additions & 7 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//internal/common:check_bazel_version.bzl", "check_bazel_version")
load("//nodejs/private:os_name.bzl", "OS_ARCH_NAMES", "node_exists_for_os", "os_name")
load("//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", node_repositories_rule = "node_repositories")
load("//toolchains/node:node_toolchain_configure.bzl", "node_toolchain_configure")
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")

def node_repositories(**kwargs):
Expand Down Expand Up @@ -57,12 +56,6 @@ def node_repositories(**kwargs):
name = node_repository_name,
**kwargs
)
target_tool = "@%s//:node_bin" % node_repository_name
native.register_toolchains("@build_bazel_rules_nodejs//toolchains/node:node_%s_toolchain" % os_name)
node_toolchain_configure(
name = "%s_config" % node_repository_name,
target_tool = target_tool,
)

# Install new toolchain under "nodejs" repository name prefix
nodejs_register_toolchains(name = "nodejs")
6 changes: 3 additions & 3 deletions internal/node/test/nodejs_toolchain_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
This test verifies that if --platforms=@rules_nodejs//nodejs:<platform> is set then
the correct node path is available to rules via
ctx.toolchains["@build_bazel_rules_nodejs//toolchains/node:toolchain_type"].nodeinfo.tool_files[0].path
ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo.tool_files[0].path
"""

load("//nodejs:repositories.bzl", "NODE_EXTRACT_DIR")
Expand Down Expand Up @@ -46,7 +46,7 @@ def _nodejs_toolchain_test(ctx):
script,
_SCRIPT_TEMPLATE.format(
expected_node_path = expected_node_path,
toolchain_node_path = ctx.toolchains["@build_bazel_rules_nodejs//toolchains/node:toolchain_type"].nodeinfo.tool_files[0].path,
toolchain_node_path = ctx.toolchains["@rules_nodejs//nodejs:toolchain_type"].nodeinfo.tool_files[0].path,
),
is_executable = True,
)
Expand All @@ -57,7 +57,7 @@ nodejs_toolchain_test = rule(
attrs = _ATTRS,
test = True,
toolchains = [
"@build_bazel_rules_nodejs//toolchains/node:toolchain_type",
"@rules_nodejs//nodejs:toolchain_type",
"@bazel_tools//tools/sh:toolchain_type",
],
)
1 change: 0 additions & 1 deletion toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ stardoc(
deps = [
"//toolchains/cypress:bzl",
"//toolchains/esbuild:bzl",
"//toolchains/node:bzl",
],
)
4 changes: 0 additions & 4 deletions toolchains/index.for_docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ load("//toolchains/cypress:cypress_repositories.bzl", _cypress_repositories = "c
load("//toolchains/cypress:cypress_toolchain.bzl", _cypress_toolchain = "cypress_toolchain")
load("//toolchains/esbuild:esbuild_repositories.bzl", _esbuild_repositories = "esbuild_repositories")
load("//toolchains/esbuild:toolchain.bzl", _configure_esbuild_toolchains = "configure_esbuild_toolchains")
load("//toolchains/node:node_toolchain_configure.bzl", _node_toolchain_configure = "node_toolchain_configure")
load("//toolchains/node:node_toolchain.bzl", _node_toolchain = "node_toolchain")

cypress_repositories = _cypress_repositories
cypress_toolchain = _cypress_toolchain
esbuild_repositories = _esbuild_repositories
configure_esbuild_toolchains = _configure_esbuild_toolchains
node_toolchain_configure = _node_toolchain_configure
node_toolchain = _node_toolchain
139 changes: 0 additions & 139 deletions toolchains/node/BUILD.bazel

This file was deleted.

25 changes: 0 additions & 25 deletions toolchains/node/BUILD.tpl

This file was deleted.

Loading

0 comments on commit f2eb60f

Please sign in to comment.