Commit a8160328 authored by Michael Droettboom's avatar Michael Droettboom

Fix #28: Compile side modules asyncronously

Requires upstream changes to emscripten
parent d562ed97
......@@ -31,7 +31,8 @@ LDFLAGS=\
-s USE_FREETYPE=1 \
-std=c++14 \
-lstdc++ \
--memory-init-file 0
--memory-init-file 0 \
--minify 0
SIX_ROOT=six/six-1.11.0/build/lib
SIX_LIBS=$(SIX_ROOT)/six.py
......@@ -62,7 +63,7 @@ build/pyodide.asm.js: src/main.bc src/jsimport.bc src/jsproxy.bc src/js2python.b
build/pyodide.asm.data: root/.built
python2 $(FILEPACKAGER) build/pyodide.asm.data --preload root/lib@lib --js-output=build/pyodide.asm.data.js
python2 $(FILEPACKAGER) build/pyodide.asm.data --preload root/lib@lib --js-output=build/pyodide.asm.data.js --use-preload-plugins
uglifyjs build/pyodide.asm.data.js -o build/pyodide.asm.data.js
......
......@@ -71,22 +71,40 @@ var languagePluginLoader = new Promise((resolve, reject) => {
let Module = {};
window.Module = Module;
Module.noImageDecoding = true;
Module.noAudioDecoding = true;
let wasm_promise = WebAssembly.compileStreaming(fetch(wasmURL));
Module.instantiateWasm = (info, receiveInstance) => {
wasm_promise.then(module => WebAssembly.instantiate(module, info))
.then(instance => receiveInstance(instance));
wasm_promise
.then(module => WebAssembly.instantiate(module, info))
.then(instance => receiveInstance(instance));
return {};
};
Module.filePackagePrefixURL = baseURL;
Module.postRun = () => {
delete window.Module;
fetch(`${baseURL}packages.json`)
var postRunPromise = new Promise((resolve, reject) => {
Module.postRun = () => {
delete window.Module;
fetch(`${baseURL}packages.json`)
.then((response) => response.json())
.then((json) => {
window.pyodide.packages = json;
resolve();
});
};
};
});
var dataLoadPromise = new Promise((resolve, reject) => {
Module.monitorRunDependencies = (n) => {
if (n === 0) {
delete Module.monitorRunDependencies;
resolve();
}
}
});
Promise.all([postRunPromise, dataLoadPromise]).then(() => resolve());
let data_script = document.createElement('script');
data_script.src = `${baseURL}pyodide.asm.data.js`;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment