Save libsodium.js (#605)
* revert wasm/asmjs split build changes * combined wasm + asm.js build * minor cleanup
This commit is contained in:
parent
2c73b8e3b5
commit
170661671d
@ -9,7 +9,6 @@ EXTRA_DIST = \
|
||||
android-x86.sh \
|
||||
android-x86_64.sh \
|
||||
emscripten.sh \
|
||||
emscripten-wasm.sh \
|
||||
ios.sh \
|
||||
msys2-win32.sh \
|
||||
msys2-win64.sh \
|
||||
|
File diff suppressed because one or more lines are too long
@ -6,7 +6,8 @@ export EXPORTED_FUNCTIONS_SUMO='["_crypto_aead_chacha20poly1305_abytes","_crypto
|
||||
export TOTAL_MEMORY=16777216
|
||||
export TOTAL_MEMORY_SUMO=67108864
|
||||
export LDFLAGS="-s RESERVED_FUNCTION_POINTERS=8"
|
||||
export LDFLAGS="${LDFLAGS} -s NO_DYNAMIC_EXECUTION=1 -s RUNNING_JS_OPTS=1 -s ASSERTIONS=0"
|
||||
export LDFLAGS="${LDFLAGS} -s SINGLE_FILE=1"
|
||||
export LDFLAGS="${LDFLAGS} -s NO_DYNAMIC_EXECUTION=1 -s ASSERTIONS=0"
|
||||
export LDFLAGS="${LDFLAGS} -s AGGRESSIVE_VARIABLE_ELIMINATION=1 -s ALIASING_FUNCTION_POINTERS=1"
|
||||
export LDFLAGS="${LDFLAGS} -s FUNCTION_POINTER_ALIGNMENT=1 -s DISABLE_EXCEPTION_CATCHING=1"
|
||||
export LDFLAGS="${LDFLAGS} -s ELIMINATE_DUPLICATE_FUNCTIONS=1"
|
||||
@ -62,9 +63,32 @@ emmake make clean
|
||||
[ $? = 0 ] || exit 1
|
||||
|
||||
if [ "$DIST" = yes ]; then
|
||||
emmake make $MAKE_FLAGS install && \
|
||||
emcc "$CFLAGS" --llvm-lto 1 --memory-init-file 0 $CPPFLAGS $LDFLAGS $JS_EXPORTS_FLAGS \
|
||||
"${PREFIX}/lib/libsodium.a" -o "${PREFIX}/lib/libsodium.js" || exit 1
|
||||
emccLibsodium () {
|
||||
outFile="${1}"
|
||||
shift
|
||||
emcc "$CFLAGS" --llvm-lto 1 $CPPFLAGS $LDFLAGS $JS_EXPORTS_FLAGS ${@} \
|
||||
"${PREFIX}/lib/libsodium.a" -o "${outFile}" || exit 1
|
||||
}
|
||||
emmake make $MAKE_FLAGS install || exit 1
|
||||
emccLibsodium "${PREFIX}/lib/libsodium.asm.tmp.js" -Oz -s RUNNING_JS_OPTS=1 -s NO_EXIT_RUNTIME=1
|
||||
emccLibsodium "${PREFIX}/lib/libsodium.wasm.tmp.js" -O3 -s WASM=1
|
||||
|
||||
cat > "${PREFIX}/lib/libsodium.js" <<- EOM
|
||||
if (typeof Module === 'undefined') {
|
||||
var Module = {};
|
||||
}
|
||||
Module.ready = new Promise(function (resolve, reject) {
|
||||
Module.onAbort = reject;
|
||||
Module.onRuntimeInitialized = function () { resolve(); };
|
||||
$(cat "${PREFIX}/lib/libsodium.wasm.tmp.js")
|
||||
}).catch(function () {
|
||||
Module.onAbort = undefined;
|
||||
Module.onRuntimeInitialized = undefined;
|
||||
$(cat "${PREFIX}/lib/libsodium.asm.tmp.js" | sed 's|use asm||g')
|
||||
});
|
||||
EOM
|
||||
|
||||
rm "${PREFIX}/lib/libsodium.asm.tmp.js" "${PREFIX}/lib/libsodium.wasm.tmp.js"
|
||||
touch -r "${PREFIX}/lib/libsodium.js" "$DONE_FILE"
|
||||
ls -l "${PREFIX}/lib/libsodium.js"
|
||||
exit 0
|
||||
|
@ -49,13 +49,9 @@ symbols() {
|
||||
out=$(symbols standard)
|
||||
sed s/EXPORTED_FUNCTIONS_STANDARD=\'.*\'/EXPORTED_FUNCTIONS_STANDARD=\'${out}\'/ < emscripten.sh > emscripten.sh.tmp && \
|
||||
mv -f emscripten.sh.tmp emscripten.sh
|
||||
sed s/EXPORTED_FUNCTIONS_STANDARD=\'.*\'/EXPORTED_FUNCTIONS_STANDARD=\'${out}\'/ < emscripten-wasm.sh > emscripten-wasm.sh.tmp && \
|
||||
mv -f emscripten-wasm.sh.tmp emscripten-wasm.sh
|
||||
|
||||
out=$(symbols sumo)
|
||||
sed s/EXPORTED_FUNCTIONS_SUMO=\'.*\'/EXPORTED_FUNCTIONS_SUMO=\'${out}\'/ < emscripten.sh > emscripten.sh.tmp && \
|
||||
mv -f emscripten.sh.tmp emscripten.sh
|
||||
sed s/EXPORTED_FUNCTIONS_SUMO=\'.*\'/EXPORTED_FUNCTIONS_SUMO=\'${out}\'/ < emscripten-wasm.sh > emscripten-wasm.sh.tmp && \
|
||||
mv -f emscripten-wasm.sh.tmp emscripten-wasm.sh
|
||||
|
||||
chmod +x emscripten.sh emscripten-wasm.sh
|
||||
chmod +x emscripten.sh
|
||||
|
Loading…
Reference in New Issue
Block a user