mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-12 14:00:01 -04:00
fix error handling, allow building an es6 module
This commit is contained in:
parent
e4c064401e
commit
bb31ef120f
4 changed files with 26 additions and 4 deletions
|
@ -5,7 +5,8 @@ set -e
|
|||
INCLUDE_DIR="build/curl-wasm/include/"
|
||||
LIB_DIR="build/curl-wasm/lib/"
|
||||
OUT_FILE="out/libcurl.js"
|
||||
MODULE_FILE="out/libcurl_module.js"
|
||||
ES6_FILE="out/libcurl_module.mjs"
|
||||
MODULE_FILE="out/emscripten_compiled.js"
|
||||
WRAPPER_SOURCE="main.js"
|
||||
|
||||
EXPORTED_FUNCS="_load_certs,_perform_request"
|
||||
|
@ -13,6 +14,10 @@ RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL"
|
|||
COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lssl -lcrypto -lcjson -lz -lbrotlidec -lbrotlicommon -I $INCLUDE_DIR -L $LIB_DIR"
|
||||
EMSCRIPTEN_OPTIONS="-lwebsocket.js -sSINGLE_FILE -sASYNCIFY -sALLOW_TABLE_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS"
|
||||
|
||||
if [ "$1" = "release" ]; then
|
||||
COMPILER_OPTIONS="-O3 $COMPILER_OPTIONS"
|
||||
fi
|
||||
|
||||
#ensure deps are compiled
|
||||
tools/all_deps.sh
|
||||
tools/generate_cert.sh
|
||||
|
@ -32,4 +37,9 @@ sed -i 's/function _emscripten_console_error(str) {/& if(UTF8ToString(str).endsW
|
|||
|
||||
#merge compiled emscripten module and wrapper code
|
||||
cp $WRAPPER_SOURCE $OUT_FILE
|
||||
sed -i "/__emscripten_output__/r $MODULE_FILE" $OUT_FILE
|
||||
sed -i "/__emscripten_output__/r $MODULE_FILE" $OUT_FILE
|
||||
rm $MODULE_FILE
|
||||
|
||||
#generate es6 module
|
||||
cp $OUT_FILE $ES6_FILE
|
||||
sed -i 's/window.libcurl/export const libcurl/' $ES6_FILE
|
Loading…
Add table
Add a link
Reference in a new issue