Skip to content

Commit d31b4df

Browse files
author
S·c
authored
Update to support multi-platform native module
1 parent 4e9316d commit d31b4df

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

quickjs-libc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,19 @@ int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
618618
return 0;
619619
}
620620

621+
#if defined(_WIN32)
622+
#define NATIVE_LIBRARY_SUFFIX ".dll"
623+
#elif defined(__APPLE__)
624+
#define NATIVE_LIBRARY_SUFFIX ".dylib"
625+
#elif defined(__linux__)
626+
#define NATIVE_LIBRARY_SUFFIX ".so"
627+
#endif
621628
JSModuleDef *js_module_loader(JSContext *ctx,
622629
const char *module_name, void *opaque)
623630
{
624631
JSModuleDef *m;
625632

626-
if (has_suffix(module_name, ".so")) {
633+
if (has_suffix(module_name, NATIVE_LIBRARY_SUFFIX) || has_suffix(module_name, ".module")) {
627634
m = js_module_loader_so(ctx, module_name);
628635
} else {
629636
size_t buf_len;

0 commit comments

Comments
 (0)