diff --git a/client/build.sh b/client/build.sh index 4c1d452..8056530 100755 --- a/client/build.sh +++ b/client/build.sh @@ -14,11 +14,17 @@ FRAGMENTS_DIR="fragments" WRAPPER_SOURCE="main.js" WISP_CLIENT="wisp_client" +#read exported functions +EXPORTED_FUNCS="" +for func in $(cat exported_funcs.txt); do + EXPORTED_FUNCS="$EXPORTED_FUNCS,_$func" +done +EXPORTED_FUNCS="${EXPORTED_FUNCS:1}" + #compile options -EXPORTED_FUNCS="_init_curl,_start_request,_tick_request,_active_requests,_free" RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL" COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lssl -lcrypto -lcjson -lz -lbrotlidec -lbrotlicommon -lnghttp2 -I $INCLUDE_DIR -L $LIB_DIR" -EMSCRIPTEN_OPTIONS="-lwebsocket.js -sASSERTIONS=1 -sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS" +EMSCRIPTEN_OPTIONS="-lwebsocket.js -sASSERTIONS=1 -sLLD_REPORT_UNDEFINED -sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS" if [[ "$*" == *"release"* ]]; then COMPILER_OPTIONS="-Oz -flto $COMPILER_OPTIONS" @@ -41,7 +47,7 @@ rm -rf out mkdir -p out #compile the main c file - but only if the source has been modified -COMPILE_CMD="emcc main.c $COMPILER_OPTIONS $EMSCRIPTEN_OPTIONS" +COMPILE_CMD="emcc *.c $COMPILER_OPTIONS $EMSCRIPTEN_OPTIONS" echo $COMPILE_CMD $COMPILE_CMD mv $COMPILED_FILE $WASM_FILE || true @@ -51,10 +57,11 @@ cp $WRAPPER_SOURCE $OUT_FILE sed -i "/__emscripten_output__/r $MODULE_FILE" $OUT_FILE rm $MODULE_FILE -#add wisp libraries +#add extra libraries sed -i "/__extra_libraries__/r $WISP_CLIENT/polyfill.js" $OUT_FILE sed -i "/__extra_libraries__/r $WISP_CLIENT/wisp.js" $OUT_FILE sed -i "/__extra_libraries__/r ./messages.js" $OUT_FILE +sed -i "/__extra_libraries__/r ./websocket.js" $OUT_FILE #apply patches python3 scripts/patcher.py $FRAGMENTS_DIR $OUT_FILE diff --git a/client/exported_funcs.txt b/client/exported_funcs.txt new file mode 100644 index 0000000..a0f588a --- /dev/null +++ b/client/exported_funcs.txt @@ -0,0 +1,15 @@ +init_curl +start_request +tick_request +active_requests + +recv_from_websocket +send_to_websocket +close_websocket +cleanup_websocket +get_result_size +get_result_buffer +get_result_code +get_result_closed + +free \ No newline at end of file diff --git a/client/index.html b/client/index.html index f77030f..a52feab 100644 --- a/client/index.html +++ b/client/index.html @@ -3,7 +3,7 @@
- +