wasm/sandbox: try .dylib/.so/.dll when loading libjerboa_native
ober
e9c3951a02f2a77bca89febbb1c791eeb0123097
--- a/lib/std/wasm/sandbox.sls +++ b/lib/std/wasm/sandbox.sls @@ -56,11 +56,23 @@ (import (chezscheme)) - ;; Load the Rust native library + ;; Load the Rust native library. Try each platform's conventional + ;; extension — .dylib on macOS, .so on Linux/BSD, .dll on Windows — + ;; in case the library was built under a different platform name. (define _native-loaded - (or (guard (e [#t #f]) (load-shared-object "libjerboa_native.so") #t) - (guard (e [#t #f]) (load-shared-object "lib/libjerboa_native.so") #t) - #f)) + (let loop ([candidates '("libjerboa_native.dylib" + "lib/libjerboa_native.dylib" + "libjerboa_native.so" + "lib/libjerboa_native.so" + "libjerboa_native.dll" + "lib/libjerboa_native.dll")]) + (cond + [(null? candidates) #f] + [(guard (e [#t #f]) + (load-shared-object (car candidates)) + #t) + #t] + [else (loop (cdr candidates))]))) ;; --- FFI bindings ---