Prepare asyncify support

This commit is contained in:
momo5502
2025-04-23 10:41:27 +02:00
parent b69027539a
commit 566deba033
2 changed files with 11 additions and 7 deletions

View File

@@ -103,7 +103,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Emscripten")
-sMAXIMUM_MEMORY=4gb
#-sEXCEPTION_CATCHING_ALLOWED=[..]
-sEXIT_RUNTIME
#-sASYNCIFY
-sASYNCIFY
)
if(MOMO_EMSCRIPTEN_SUPPORT_NODEJS)

View File

@@ -26,6 +26,12 @@ function logLine(text) {
}
}
function notifyExit(code) {
flushLines();
postMessage({ message: "end", data: code });
self.close();
}
function runEmulation(filesystem, file, options) {
globalThis.Module = {
arguments: [...options, "-e", "./root", file],
@@ -46,12 +52,10 @@ function runEmulation(filesystem, file, options) {
},
print: logLine,
printErr: logLine,
postRun: () => {
flushLines();
postMessage({ message: "end", data: null });
self.close();
},
onAbort: () => notifyExit(null),
onExit: notifyExit,
postRun: flushLines,
};
importScripts("./analyzer.js?1");
importScripts("./analyzer.js");
}