Skip to content

Commit 311c587

Browse files
committed
Include the .exe extension on Windows for Node.js
1 parent abfa9ce commit 311c587

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

bazel/emscripten_cache.bzl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package(default_visibility = ['//visibility:public'])
33
exports_files(['emscripten_config'])
44
"""
55

6-
def get_binaryen_root(repository_ctx):
6+
def get_root_and_binext(repository_ctx):
77
"""
88
Retrieve the path to the Emscripten binary directory
99
@@ -23,20 +23,20 @@ def get_binaryen_root(repository_ctx):
2323
"""
2424
if repository_ctx.os.name.startswith('linux'):
2525
if 'amd64' in repository_ctx.os.arch or 'x86_64' in repository_ctx.os.arch:
26-
return repository_ctx.path(Label("@emscripten_bin_linux//:BUILD.bazel")).dirname
26+
return (repository_ctx.path(Label("@emscripten_bin_linux//:BUILD.bazel")).dirname, '')
2727
elif 'aarch64' in repository_ctx.os.arch:
28-
return repository_ctx.path(Label("@emscripten_bin_linux_arm64//:BUILD.bazel")).dirname
28+
return (repository_ctx.path(Label("@emscripten_bin_linux_arm64//:BUILD.bazel")).dirname, '')
2929
else:
3030
fail('Unsupported architecture for Linux')
3131
elif repository_ctx.os.name.startswith('mac'):
3232
if 'amd64' in repository_ctx.os.arch or 'x86_64' in repository_ctx.os.arch:
33-
return repository_ctx.path(Label("@emscripten_bin_mac//:BUILD.bazel")).dirname
33+
return (repository_ctx.path(Label("@emscripten_bin_mac//:BUILD.bazel")).dirname, '')
3434
elif 'aarch64' in repository_ctx.os.arch:
35-
return repository_ctx.path(Label("@emscripten_bin_mac_arm64//:BUILD.bazel")).dirname
35+
return (repository_ctx.path(Label("@emscripten_bin_mac_arm64//:BUILD.bazel")).dirname, '')
3636
else:
3737
fail('Unsupported architecture for MacOS')
3838
elif repository_ctx.os.name.startswith('windows'):
39-
return repository_ctx.path(Label("@emscripten_bin_win//:BUILD.bazel")).dirname
39+
return (repository_ctx.path(Label("@emscripten_bin_win//:BUILD.bazel")).dirname, '.exe')
4040
else:
4141
fail('Unsupported operating system')
4242

@@ -49,16 +49,16 @@ def _emscripten_cache_impl(repository_ctx):
4949
)
5050

5151
if repository_ctx.attr.libraries or repository_ctx.attr.flags:
52-
binaryen_root = get_binaryen_root(repository_ctx)
53-
llvm_root = binaryen_root.get_child("bin")
54-
emscripten_root = binaryen_root.get_child("emscripten")
52+
root, binext = get_root_and_binext(repository_ctx)
53+
llvm_root = root.get_child("bin")
54+
emscripten_root = root.get_child("emscripten")
5555
embuilder_path = emscripten_root.get_child("embuilder")
5656
cache_path = repository_ctx.path('cache')
5757
nodejs = repository_ctx.path(Label("@nodejs//:BUILD.bazel")).dirname.get_child("bin").get_child("node")
5858
# Create configuration file
59-
embuilder_config_content = "NODE_JS = '{}'\n".format(nodejs)
59+
embuilder_config_content = "NODE_JS = '{}{}'\n".format(nodejs, binext)
6060
embuilder_config_content += "LLVM_ROOT = '{}'\n".format(llvm_root)
61-
embuilder_config_content += "BINARYEN_ROOT = '{}'\n".format(binaryen_root)
61+
embuilder_config_content += "BINARYEN_ROOT = '{}'\n".format(root)
6262
embuilder_config_content += "EMSCRIPTEN_ROOT = '{}'\n".format(emscripten_root)
6363
embuilder_config_content += "CACHE = '{}'\n".format(cache_path)
6464
repository_ctx.file("embuilder_config", embuilder_config_content)

0 commit comments

Comments
 (0)