mirror of https://github.com/pyodide/pyodide.git
Fix #28: Compile side modules asyncronously
Requires upstream changes to emscripten
This commit is contained in:
parent
d562ed9744
commit
a81603286b
5
Makefile
5
Makefile
|
@ -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`;
|
||||
|
|
Loading…
Reference in New Issue