Skip to content

Commit dd89482

Browse files
committed
Get extensions for both binaries and scripts
1 parent 4c1dd2b commit dd89482

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

bazel/emscripten_cache.bzl

Lines changed: 12 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_root_and_binext(repository_ctx):
6+
def get_root_and_extensions(repository_ctx):
77
"""
88
Retrieve the path to the Emscripten binary directory
99
@@ -23,20 +23,20 @@ def get_root_and_binext(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, '.exe')
39+
return (repository_ctx.path(Label("@emscripten_bin_win//:BUILD.bazel")).dirname, '.exe', '.bat')
4040
else:
4141
fail('Unsupported operating system')
4242

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

5151
if repository_ctx.attr.libraries or repository_ctx.attr.flags:
52-
root, binext = get_root_and_binext(repository_ctx)
52+
root, binary_ext, script_ext = get_root_and_extensions(repository_ctx)
5353
llvm_root = root.get_child("bin")
5454
emscripten_root = root.get_child("emscripten")
55-
embuilder_path = emscripten_root.get_child("embuilder")
56-
cache_path = repository_ctx.path('cache')
57-
nodejs = repository_ctx.path(Label("@nodejs//:BUILD.bazel")).dirname.get_child("bin").get_child("node")
55+
nodejs_root = repository_ctx.path(Label("@nodejs//:BUILD.bazel")).dirname
56+
cache_path = repository_ctx.path("cache")
57+
embuilder_path = "{}{}".format(emscripten_root.get_child("embuilder"), script_ext)
58+
nodejs_path = "{}{}".format(nodejs_root.get_child("bin").get_child("node"), binary_ext)
5859
# Create configuration file
59-
embuilder_config_content = "NODE_JS = '{}{}'\n".format(nodejs, binext)
60+
embuilder_config_content = "NODE_JS = '{}'\n".format(nodejs_path)
6061
embuilder_config_content += "LLVM_ROOT = '{}'\n".format(llvm_root)
6162
embuilder_config_content += "BINARYEN_ROOT = '{}'\n".format(root)
6263
embuilder_config_content += "EMSCRIPTEN_ROOT = '{}'\n".format(emscripten_root)

0 commit comments

Comments
 (0)