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=\ ...@@ -31,7 +31,8 @@ LDFLAGS=\
-s USE_FREETYPE=1 \ -s USE_FREETYPE=1 \
-std=c++14 \ -std=c++14 \
-lstdc++ \ -lstdc++ \
--memory-init-file 0 --memory-init-file 0 \
--minify 0
SIX_ROOT=six/six-1.11.0/build/lib SIX_ROOT=six/six-1.11.0/build/lib
SIX_LIBS=$(SIX_ROOT)/six.py 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 ...@@ -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 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 uglifyjs build/pyodide.asm.data.js -o build/pyodide.asm.data.js
......
...@@ -71,22 +71,40 @@ var languagePluginLoader = new Promise((resolve, reject) => { ...@@ -71,22 +71,40 @@ var languagePluginLoader = new Promise((resolve, reject) => {
let Module = {}; let Module = {};
window.Module = Module; window.Module = Module;
Module.noImageDecoding = true;
Module.noAudioDecoding = true;
let wasm_promise = WebAssembly.compileStreaming(fetch(wasmURL)); let wasm_promise = WebAssembly.compileStreaming(fetch(wasmURL));
Module.instantiateWasm = (info, receiveInstance) => { Module.instantiateWasm = (info, receiveInstance) => {
wasm_promise.then(module => WebAssembly.instantiate(module, info)) wasm_promise
.then(instance => receiveInstance(instance)); .then(module => WebAssembly.instantiate(module, info))
.then(instance => receiveInstance(instance));
return {}; return {};
}; };
Module.filePackagePrefixURL = baseURL; Module.filePackagePrefixURL = baseURL;
Module.postRun = () => { var postRunPromise = new Promise((resolve, reject) => {
delete window.Module; Module.postRun = () => {
fetch(`${baseURL}packages.json`) delete window.Module;
fetch(`${baseURL}packages.json`)
.then((response) => response.json()) .then((response) => response.json())
.then((json) => { .then((json) => {
window.pyodide.packages = json; window.pyodide.packages = json;
resolve(); 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'); let data_script = document.createElement('script');
data_script.src = `${baseURL}pyodide.asm.data.js`; 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