diff --git a/client/build.sh b/client/build.sh index d1124e3..a894253 100755 --- a/client/build.sh +++ b/client/build.sh @@ -10,7 +10,7 @@ WRAPPER_SOURCE="main.js" EXPORTED_FUNCS="_load_certs,_perform_request" RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL" -COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lssl -lcrypto -lcjson -I $INCLUDE_DIR -L $LIB_DIR" +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" #ensure deps are compiled diff --git a/client/main.c b/client/main.c index e9baf71..c7e1036 100644 --- a/client/main.c +++ b/client/main.c @@ -46,6 +46,7 @@ void perform_request(const char* url, const char* json_params, DataCallback data //some default options curl_easy_setopt(http_handle, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(http_handle, CURLOPT_ACCEPT_ENCODING, ""); //parse json options cJSON* request_json = cJSON_Parse(json_params); diff --git a/client/tools/all_deps.sh b/client/tools/all_deps.sh index 33e53e5..e59f563 100755 --- a/client/tools/all_deps.sh +++ b/client/tools/all_deps.sh @@ -7,6 +7,8 @@ mkdir -p build OPENSSL_PREFIX=$(realpath build/openssl-wasm) CJSON_PREFIX=$(realpath build/cjson-wasm) CURL_PREFIX=$(realpath build/curl-wasm) +ZLIB_PREFIX=$(realpath build/zlib-wasm) +BROTLI_PREFIX=$(realpath build/brotli-wasm) if [ ! -d $OPENSSL_PREFIX ]; then tools/openssl.sh @@ -14,9 +16,17 @@ fi if [ ! -d $CJSON_PREFIX ]; then tools/cjson.sh fi +if [ ! -d $ZLIB_PREFIX ]; then + tools/zlib.sh +fi +if [ ! -d $BROTLI_PREFIX ]; then + tools/brotli.sh +fi if [ ! -d $CURL_PREFIX ]; then tools/curl.sh fi cp -r $OPENSSL_PREFIX/* $CURL_PREFIX -cp -r $CJSON_PREFIX/* $CURL_PREFIX \ No newline at end of file +cp -r $CJSON_PREFIX/* $CURL_PREFIX +cp -r $ZLIB_PREFIX/* $CURL_PREFIX +cp -r $BROTLI_PREFIX/* $CURL_PREFIX \ No newline at end of file diff --git a/client/tools/brotli.sh b/client/tools/brotli.sh new file mode 100755 index 0000000..1210f4b --- /dev/null +++ b/client/tools/brotli.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +#compile brotli for use with emscripten + +set -x +set -e + +CORE_COUNT=$(nproc --all) +PREFIX=$(realpath build/brotli-wasm) + +cd build +rm -rf brotli +git clone -b master --depth=1 https://github.com/google/brotli +cd brotli + +emcmake cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./installed +cmake --build . --config Release --target install + +rm -rf $PREFIX +mkdir -p $PREFIX +cp -r installed/* $PREFIX +rm -rf $PREFIX/bin +rm -rf $PREFIX/share +rm -rf $PREFIX/lib/pkgconfig + +cd ../../ \ No newline at end of file diff --git a/client/tools/curl.sh b/client/tools/curl.sh index d17358d..cd4e40e 100755 --- a/client/tools/curl.sh +++ b/client/tools/curl.sh @@ -8,7 +8,8 @@ set -e CORE_COUNT=$(nproc --all) PREFIX=$(realpath build/curl-wasm) OPENSSL_PREFIX=$(realpath build/openssl-wasm) -mkdir -p $PREFIX +ZLIB_PREFIX=$(realpath build/zlib-wasm) +BROTLI_PREFIX=$(realpath build/brotli-wasm) cd build rm -rf curl @@ -16,11 +17,10 @@ git clone -b master --depth=1 https://github.com/curl/curl cd curl autoreconf -fi -emconfigure ./configure --host i686-linux --prefix=$PREFIX --disable-shared --disable-threaded-resolver --without-libpsl --disable-netrc --disable-ipv6 --disable-tftp --disable-ntlm-wb --with-ssl=$OPENSSL_PREFIX -emmake make -j$CORE_COUNT CFLAGS="-pthread" +emconfigure ./configure --host i686-linux --disable-shared --disable-threaded-resolver --without-libpsl --disable-netrc --disable-ipv6 --disable-tftp --disable-ntlm-wb --with-ssl=$OPENSSL_PREFIX --with-zlib=$ZLIB_PREFIX --with-brotli=$BROTLI_PREFIX +emmake make -j$CORE_COUNT CFLAGS="-pthread" LIBS="-lbrotlicommon" -rm -rf $PREFIX/include/* -rm -rf $PREFIX/lib/* +rm -rf $PREFIX mkdir -p $PREFIX/include mkdir -p $PREFIX/lib cp -r include/curl $PREFIX/include diff --git a/client/tools/zlib.sh b/client/tools/zlib.sh new file mode 100755 index 0000000..624246e --- /dev/null +++ b/client/tools/zlib.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +#compile zlib for use with emscripten + +set -x +set -e + +CORE_COUNT=$(nproc --all) +PREFIX=$(realpath build/zlib-wasm) + +cd build +rm -rf zlib +git clone -b master --depth=1 https://github.com/madler/zlib +cd zlib + +emconfigure ./configure --static +emmake make -j$CORE_COUNT + +rm -rf $PREFIX +mkdir -p $PREFIX/include +mkdir -p $PREFIX/lib +cp -r *.h $PREFIX/include +cp -r *.a $PREFIX/lib + +cd ../../ \ No newline at end of file