Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get node binary via @nodejs//:node #1151

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bazel/emscripten_toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ emscripten_cc_toolchain_config_rule(
"@bazel_tools//src/conditions:host_windows": "bat",
"//conditions:default": "sh",
}),
node_binary = "@nodejs//:node",
)

cc_toolchain(
Expand Down
10 changes: 2 additions & 8 deletions bazel/emscripten_toolchain/emscripten_config
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ EMSCRIPTEN_ROOT = os.environ["EMSCRIPTEN"]
BINARYEN_ROOT = os.path.join(ROOT_DIR, os.environ["EM_BIN_PATH"])
LLVM_ROOT = os.path.join(BINARYEN_ROOT, "bin")
FROZEN_CACHE = True

system = platform.system()

machine = "arm64" if platform.machine() == "arm64" else "amd64"
nodejs_binary = "bin/nodejs/node.exe" if(system =="Windows") else "bin/node"
NODE_JS = ROOT_DIR + "/external/nodejs_{}_{}/{}".format(system.lower(), machine, nodejs_binary)

NODE_JS = os.path.join(ROOT_DIR, os.environ["NODE_JS"])

# This works around an issue with Bazel RBE where the symlinks in node_modules/.bin
# are uploaded as the linked files, which means the cli.js cannot load its
# dependencies from the expected locations.
# See https://github.com/emscripten-core/emscripten/pull/16640 for more
if system != "Windows":
if platform.system() != "Windows":
CLOSURE_COMPILER = [NODE_JS, os.path.join(EMSCRIPTEN_ROOT, "node_modules",
"google-closure-compiler", "cli.js")]
5 changes: 5 additions & 0 deletions bazel/emscripten_toolchain/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,10 @@ def _impl(ctx):
key = "EM_CONFIG_PATH",
value = ctx.file.em_config.path,
),
env_entry(
key = "NODE_JS",
value = ctx.file.node_binary.path,
)
],
),
# Use llvm backend. Off by default, enabled via --features=llvm_backend
Expand Down Expand Up @@ -1115,6 +1119,7 @@ emscripten_cc_toolchain_config_rule = rule(
"em_config": attr.label(mandatory = True, allow_single_file = True),
"emscripten_binaries": attr.label(mandatory = True, cfg = "exec"),
"script_extension": attr.string(mandatory = True, values = ["sh", "bat"]),
"node_binary": attr.label(mandatory = True, allow_single_file = True, cfg = "exec"),
},
provides = [CcToolchainConfigInfo],
)