|
2 | 2 | from typing import Any, cast |
3 | 3 | from ._binaryen_cffi import ffi |
4 | 4 |
|
| 5 | +__macos_error = """You either do not have the binaryen library installed, or it is not in your standard C library path. |
| 6 | +
|
| 7 | +Recommended: Using the brew package manager (https://brew.sh/) run brew install binaryen |
| 8 | +
|
| 9 | +Alternatively add the precompiled libbinaryen.dylib from https://github.com/WebAssembly/binaryen/releases to your path. |
| 10 | +""" |
| 11 | + |
| 12 | +__windows_error = """You either do not have the binaryen library installed, or it is not in your standard C library path. |
| 13 | +
|
| 14 | +Add the precompiled libbinaryen.dll from https://github.com/WebAssembly/binaryen/releases to your path. |
| 15 | +""" |
| 16 | + |
| 17 | +__linux_error = """You either do not have the binaryen library installed, or it is not in your standard C library path. |
| 18 | +
|
| 19 | +Recommended: Use your distributions package manager to install binaryen. |
| 20 | +
|
| 21 | +Alternatively add the precompiled libbinaryen.so from https://github.com/WebAssembly/binaryen/releases to your path. |
| 22 | +""" |
| 23 | + |
5 | 24 | __lib_string = "" |
| 25 | +__error_message = "" |
6 | 26 | if platform.system() == "Linux": |
| 27 | + __error_message = __linux_error |
7 | 28 | __lib_string = "libbinaryen.so" |
8 | 29 | if platform.system() == "Windows": |
| 30 | + __error_message = __windows_error |
9 | 31 | __lib_string = "libbinaryen.dll" |
10 | 32 | if platform.system() == "Darwin": |
| 33 | + __error_message = __macos_error |
11 | 34 | __lib_string = "libbinaryen.dylib" |
12 | | -lib = cast(Any, ffi.dlopen(__lib_string)) |
| 35 | + |
| 36 | +try: |
| 37 | + lib = cast(Any, ffi.dlopen(__lib_string)) |
| 38 | +except OSError as error: |
| 39 | + raise OSError(__error_message) from error |
0 commit comments