From a738dec403fcb390c0c66b0798fee1fee7a90bdc Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 7 Apr 2021 14:03:06 +1000 Subject: [PATCH] feat: make node toolchain_type public so new toolchains can be added Enables rules_nodejs to be used in cross-compilation contexts, where the target architecture is not supported by rules_nodejs. rules_nodejs's default toolchains are limited via target_compatible_with, which means they will not work when cross-compiling to Android or iOS with --platforms for example. With this change, users can define their own toolchain that is limited by execution platform instead of target platform. For example, if you're targeting an unsupported platform, but building on a Mac, you can place the following in the local WORKSPACE: register_toolchains("//ts/node_toolchain") And the following in ts/node_toolchain/BUILD.bazel: toolchain( name = "node_toolchain", exec_compatible_with = [ "@platforms//os:osx", "@platforms//cpu:x86_64", ], toolchain = "@nodejs_darwin_amd64_config//:toolchain", toolchain_type = "@build_bazel_rules_nodejs//toolchains/node:toolchain_type", ) Closes #2565 --- toolchains/node/BUILD.bazel | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/toolchains/node/BUILD.bazel b/toolchains/node/BUILD.bazel index 342e530342..224bcf6fd2 100644 --- a/toolchains/node/BUILD.bazel +++ b/toolchains/node/BUILD.bazel @@ -70,7 +70,10 @@ filegroup( ) # node toolchain type -toolchain_type(name = "toolchain_type") +toolchain_type( + name = "toolchain_type", + visibility = ["//visibility:public"], +) # Allow targets to use a toolchains attribute, such as sh_binary and genrule # This way they can reference the NODE_PATH make variable.