@@ -3,7 +3,7 @@ package(default_visibility = ['//visibility:public'])
3
3
exports_files(['emscripten_config'])
4
4
"""
5
5
6
- def get_binaryen_root (repository_ctx ):
6
+ def get_root_and_binext (repository_ctx ):
7
7
"""
8
8
Retrieve the path to the Emscripten binary directory
9
9
@@ -23,20 +23,20 @@ def get_binaryen_root(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
39
+ return ( repository_ctx .path (Label ("@emscripten_bin_win//:BUILD.bazel" )).dirname , '.exe' )
40
40
else :
41
41
fail ('Unsupported operating system' )
42
42
@@ -49,16 +49,16 @@ def _emscripten_cache_impl(repository_ctx):
49
49
)
50
50
51
51
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" )
55
55
embuilder_path = emscripten_root .get_child ("embuilder" )
56
56
cache_path = repository_ctx .path ('cache' )
57
57
nodejs = repository_ctx .path (Label ("@nodejs//:BUILD.bazel" )).dirname .get_child ("bin" ).get_child ("node" )
58
58
# Create configuration file
59
- embuilder_config_content = "NODE_JS = '{}'\n " .format (nodejs )
59
+ embuilder_config_content = "NODE_JS = '{}{} '\n " .format (nodejs , binext )
60
60
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 )
62
62
embuilder_config_content += "EMSCRIPTEN_ROOT = '{}'\n " .format (emscripten_root )
63
63
embuilder_config_content += "CACHE = '{}'\n " .format (cache_path )
64
64
repository_ctx .file ("embuilder_config" , embuilder_config_content )
0 commit comments