mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-12 14:00:01 -04:00
add gzip and brotli support
This commit is contained in:
parent
7472c899db
commit
e4c064401e
6 changed files with 69 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
cp -r $CJSON_PREFIX/* $CURL_PREFIX
|
||||
cp -r $ZLIB_PREFIX/* $CURL_PREFIX
|
||||
cp -r $BROTLI_PREFIX/* $CURL_PREFIX
|
26
client/tools/brotli.sh
Executable file
26
client/tools/brotli.sh
Executable file
|
@ -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 ../../
|
|
@ -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
|
||||
|
|
25
client/tools/zlib.sh
Executable file
25
client/tools/zlib.sh
Executable file
|
@ -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 ../../
|
Loading…
Add table
Add a link
Reference in a new issue