herumi / bls

288 stars 132 forks source link

Inline wasm file for easier cross-platform setup #65

Closed dapplion closed 3 years ago

dapplion commented 3 years ago

Should be merged with https://github.com/herumi/bls-eth-wasm/pull/5


With MODULARIZE=1 set, we instead emit the code wrapped in a function that returns a promise. The promise is resolved with the module instance when it is safe to run the compiled code, similar to the onRuntimeInitialized callback. You do not need to use the onRuntimeInitialized callback when using MODULARIZE.

EMCC_OPT+=-s MODULARIZE=1

The default name of the function is Module, but can be changed using the EXPORT_NAME The factory function accepts 1 parameter, an object with default values the instance

EMCC_OPT+=-s EXPORT_NAME='createBlsModule'

STRICT_JS = 1, adds "use strict;" to generated JS

EMCC_OPT+=-s STRICT_JS=1

SINGLE_FILE=1, embeds all subresources in the emitted file as base64 string literals. Embedded subresources may include (but aren't limited to) wasm, asm.js, and static memory initialization code.

EMCC_OPT+=-s SINGLE_FILE=1

Pass -s MINIFY_HTML=0 to explicitly choose to disable HTML minification altogether

EMCC_OPT+=-s MINIFY_HTML=0

Do not minify target javascript file (only a +0.8% size increase)

EMCC_OPT+=--minify 0
herumi commented 3 years ago

Thank you for the useful patch. I've merged it.