@@ -3,7 +3,7 @@ package(default_visibility = ['//visibility:public'])
3
3
exports_files(['emscripten_config'])
4
4
"""
5
5
6
- def get_root_and_binext (repository_ctx ):
6
+ def get_root_and_extensions (repository_ctx ):
7
7
"""
8
8
Retrieve the path to the Emscripten binary directory
9
9
@@ -23,20 +23,20 @@ def get_root_and_binext(repository_ctx):
23
23
"""
24
24
if repository_ctx .os .name .startswith ('linux' ):
25
25
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 , '' , '' )
27
27
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 , '' , '' )
29
29
else :
30
30
fail ('Unsupported architecture for Linux' )
31
31
elif repository_ctx .os .name .startswith ('mac' ):
32
32
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 , '' , '' )
34
34
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 , '' , '' )
36
36
else :
37
37
fail ('Unsupported architecture for MacOS' )
38
38
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' )
40
40
else :
41
41
fail ('Unsupported operating system' )
42
42
@@ -49,14 +49,15 @@ def _emscripten_cache_impl(repository_ctx):
49
49
)
50
50
51
51
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 )
53
53
llvm_root = root .get_child ("bin" )
54
54
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 )
58
59
# Create configuration file
59
- embuilder_config_content = "NODE_JS = '{}{} '\n " .format (nodejs , binext )
60
+ embuilder_config_content = "NODE_JS = '{}'\n " .format (nodejs_path )
60
61
embuilder_config_content += "LLVM_ROOT = '{}'\n " .format (llvm_root )
61
62
embuilder_config_content += "BINARYEN_ROOT = '{}'\n " .format (root )
62
63
embuilder_config_content += "EMSCRIPTEN_ROOT = '{}'\n " .format (emscripten_root )
0 commit comments