Skip to content

Commit 2818b5a

Browse files
committed
Fix error handling
1 parent 4856c76 commit 2818b5a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

bazel/emscripten_cache.bzl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,18 @@ def get_binaryen_root(repository_ctx):
2727
elif 'aarch64' in repository_ctx.os.arch:
2828
return repository_ctx.path(Label("@emscripten_bin_linux_arm64//:all")).dirname
2929
else:
30-
repository_ctx.fail('Unsupported architecture for Linux')
30+
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:
3333
return repository_ctx.path(Label("@emscripten_bin_mac//:all")).dirname
3434
elif 'aarch64' in repository_ctx.os.arch:
3535
return repository_ctx.path(Label("@emscripten_bin_mac_arm64//:all")).dirname
3636
else:
37-
repository_ctx.fail('Unsupported architecture for MacOS')
37+
fail('Unsupported architecture for MacOS')
3838
elif repository_ctx.os.name.startswith('windows'):
3939
return repository_ctx.path(Label("@emscripten_bin_win//:all")).dirname
4040
else:
41-
repository_ctx.fail('Unsupported operating system')
42-
return ''
41+
fail('Unsupported operating system')
4342

4443
def _emscripten_cache_impl(repository_ctx):
4544
# Read the default emscripten configuration file
@@ -71,7 +70,9 @@ def _emscripten_cache_impl(repository_ctx):
7170
embuilder_args = [embuilder_path] + flags + ["build"] + libraries
7271
# Run embuilder
7372
repository_ctx.report_progress("Building secondary cache")
74-
repository_ctx.execute(embuilder_args, quiet=False)
73+
result = repository_ctx.execute(embuilder_args, quiet=False)
74+
if result != 0:
75+
fail("Embuilder exited with a non-zero return code")
7576
# Override Emscripten's cache with the secondary cache
7677
default_config += "CACHE = '{}'\n".format(repository_ctx.path('cache'))
7778

0 commit comments

Comments
 (0)