add mbedtls support and disable wolfssl

This commit is contained in:
ading2210 2025-01-22 12:47:34 -05:00
parent 885e83d2eb
commit 8b53625743
7 changed files with 34 additions and 9 deletions

View file

@ -37,7 +37,7 @@ EXPORTED_FUNCS="${EXPORTED_FUNCS:1}"
#compile options
RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL"
COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lwolfssl -lcjson -lz -lbrotlidec -lbrotlicommon -lnghttp2 -I $INCLUDE_DIR -L $LIB_DIR"
COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lmbedtls -lmbedcrypto -lmbedx509 -lcjson -lz -lbrotlidec -lbrotlicommon -lnghttp2 -I $INCLUDE_DIR -L $LIB_DIR"
EMSCRIPTEN_OPTIONS="-lwebsocket.js -sENVIRONMENT=worker,web -sASSERTIONS=1 -sLLD_REPORT_UNDEFINED -sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sNO_EXIT_RUNTIME -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS"
#clean output dir

View file

@ -2,7 +2,7 @@ const copyright_notice = `libcurl.js is licensed under the GNU AGPL v3. You can
Several C libraries are used, and their licenses are listed below:
- libcurl: curl License (https://curl.se/docs/copyright.html)
- wolfssl: GNU GPL v2 (https://github.com/wolfSSL/wolfssl/blob/master/COPYING)
- mbedtls: Apache License 2.0 (https://github.com/Mbed-TLS/mbedtls/blob/development/LICENSE)
- cjson: MIT License (https://github.com/DaveGamble/cJSON/blob/master/LICENSE)
- zlib: zlib License (https://www.zlib.net/zlib_license.html)
- brotli: MIT License (https://github.com/google/brotli/blob/master/LICENSE)

View file

@ -3,7 +3,6 @@
#publish libcurl.js as an npm package
./build.sh all
tests/run.sh
cp package.json out
cp ../README.md out

View file

@ -5,15 +5,15 @@
set -e
mkdir -p build
WOLFSSL_PREFIX=$(realpath build/wolfssl-wasm)
MBEDTLS_PREFIX=$(realpath build/mbedtls-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)
NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm)
if [ ! -d $WOLFSSL_PREFIX ]; then
tools/wolfssl.sh
if [ ! -d $MBEDTLS_PREFIX ]; then
tools/mbedtls.sh
fi
if [ ! -d $CJSON_PREFIX ]; then
tools/cjson.sh
@ -31,7 +31,7 @@ if [ ! -d $CURL_PREFIX ]; then
tools/curl.sh
fi
cp -r $WOLFSSL_PREFIX/* $CURL_PREFIX
cp -r $MBEDTLS_PREFIX/* $CURL_PREFIX
cp -r $CJSON_PREFIX/* $CURL_PREFIX
cp -r $ZLIB_PREFIX/* $CURL_PREFIX
cp -r $BROTLI_PREFIX/* $CURL_PREFIX

View file

@ -7,7 +7,7 @@ set -e
CORE_COUNT=$(nproc --all)
PREFIX=$(realpath build/curl-wasm)
WOLFSSL_PREFIX=$(realpath build/wolfssl-wasm)
MBEDTLS_PREFIX=$(realpath build/mbedtls-wasm)
ZLIB_PREFIX=$(realpath build/zlib-wasm)
BROTLI_PREFIX=$(realpath build/brotli-wasm)
NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm)
@ -24,7 +24,7 @@ emconfigure ./configure --host i686-linux \
--enable-websockets --disable-ftp --disable-file --disable-gopher \
--disable-imap --disable-mqtt --disable-pop3 --disable-rtsp \
--disable-smb --disable-smtp --disable-telnet --disable-dict \
--with-wolfssl=$WOLFSSL_PREFIX --with-zlib=$ZLIB_PREFIX \
--with-mbedtls=$MBEDTLS_PREFIX --with-zlib=$ZLIB_PREFIX \
--with-brotli=$BROTLI_PREFIX --with-nghttp2=$NGHTTP2_PREFIX
emmake make -j$CORE_COUNT CFLAGS="-Oz" LIBS="-lbrotlicommon"

26
client/tools/mbedtls.sh Executable file
View file

@ -0,0 +1,26 @@
#!/bin/bash
#compile mbedtls for use with emscripten
set -x
set -e
CORE_COUNT=$(nproc --all)
PREFIX=$(realpath build/mbedtls-wasm)
rm -rf $PREFIX
mkdir -p $PREFIX
cd build
rm -rf mbedtls
git clone -b mbedtls-3.6.2 --recursive --depth=1 https://github.com/Mbed-TLS/mbedtls mbedtls
cd mbedtls
emmake make CFLAGS="-Oz" no_test -j$CORE_COUNT
make DESTDIR="$PREFIX" install
rm -rf $PREFIX/bin
rm -rf $PREFIX/share
rm -rf $PREFIX/lib/pkgconfig
rm -rf $PREFIX/lib/*.la
cd ../../

0
client/tools/patch_js.py Normal file → Executable file
View file