Merge branch 'main' into wolfssl-testing

This commit is contained in:
ading2210 2024-02-27 12:13:18 -08:00
commit b49d677686
37 changed files with 1131 additions and 273 deletions

View file

@ -2,6 +2,7 @@
#build all deps
set -e
mkdir -p build
WOLFSSL_PREFIX=$(realpath build/wolfssl-wasm)
@ -9,6 +10,7 @@ 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/openssl.sh
@ -22,6 +24,9 @@ fi
if [ ! -d $BROTLI_PREFIX ]; then
tools/brotli.sh
fi
if [ ! -d $NGHTTP2_PREFIX ]; then
tools/nghttp2.sh
fi
if [ ! -d $CURL_PREFIX ]; then
tools/curl.sh
fi
@ -29,4 +34,5 @@ fi
cp -r $WOLFSSL_PREFIX/* $CURL_PREFIX
cp -r $CJSON_PREFIX/* $CURL_PREFIX
cp -r $ZLIB_PREFIX/* $CURL_PREFIX
cp -r $BROTLI_PREFIX/* $CURL_PREFIX
cp -r $BROTLI_PREFIX/* $CURL_PREFIX
cp -r $NGHTTP2_PREFIX/* $CURL_PREFIX

View file

@ -10,7 +10,7 @@ PREFIX=$(realpath build/brotli-wasm)
cd build
rm -rf brotli
git clone -b master --depth=1 https://github.com/google/brotli
git clone -b v1.1.0 --depth=1 https://github.com/google/brotli
cd brotli
emcmake cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./installed

View file

@ -11,7 +11,7 @@ mkdir -p $PREFIX
cd build
rm -rf cjson
git clone -b master --depth=1 https://github.com/DaveGamble/cJSON cjson
git clone -b v1.7.17 --depth=1 https://github.com/DaveGamble/cJSON cjson
cd cjson
sed -i 's/-fstack-protector-strong//' Makefile

View file

@ -10,14 +10,15 @@ PREFIX=$(realpath build/curl-wasm)
WOLFSSL_PREFIX=$(realpath build/wolfssl-wasm)
ZLIB_PREFIX=$(realpath build/zlib-wasm)
BROTLI_PREFIX=$(realpath build/brotli-wasm)
NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm)
cd build
rm -rf curl
git clone -b master --depth=1 https://github.com/curl/curl
git clone -b curl-8_6_0 --depth=1 https://github.com/curl/curl
cd curl
autoreconf -fi
emconfigure ./configure --host i686-linux --disable-shared --disable-threaded-resolver --without-libpsl --disable-netrc --disable-ipv6 --disable-tftp --disable-ntlm-wb --enable-websockets --with-wolfssl=$WOLFSSL_PREFIX --with-zlib=$ZLIB_PREFIX --with-brotli=$BROTLI_PREFIX
emconfigure ./configure --host i686-linux --disable-shared --disable-threaded-resolver --without-libpsl --disable-netrc --disable-ipv6 --disable-tftp --disable-ntlm-wb --enable-websockets --with-wolfssl=$WOLFSSL_PREFIX --with-zlib=$ZLIB_PREFIX --with-brotli=$BROTLI_PREFIX --with-nghttp2=$NGHTTP2_PREFIX
emmake make -j$CORE_COUNT CFLAGS="-Oz -pthread" LIBS="-lbrotlicommon"
rm -rf $PREFIX

24
client/tools/nghttp2.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
#compile nghttp2 for use with emscripten
set -x
set -e
CORE_COUNT=$(nproc --all)
PREFIX=$(realpath build/nghttp2-wasm)
cd build
rm -rf nghttp2
git clone -b v1.59.0 --depth=1 https://github.com/nghttp2/nghttp2
cd nghttp2
rm -rf $PREFIX
mkdir -p $PREFIX
autoreconf -fi
emconfigure ./configure --host i686-linux --enable-static --disable-shared --enable-lib-only --prefix=$PREFIX
emmake make -j$CORE_COUNT
make install
cd ../../

29
client/tools/patch_js.py Normal file
View file

@ -0,0 +1,29 @@
import re
import sys
import pathlib
match_regex = r'/\* (.+?)\n(.+?)\n\*/\n(.*?)(\n\n|$)'
fragments_dir = sys.argv[1]
target_dir = sys.argv[2]
fragments_path = pathlib.Path(fragments_dir)
target_path = pathlib.Path(target_dir)
target_text = target_path.read_text()
for fragment_file in fragments_path.iterdir():
print(f"applying patch from {fragment_file.name}")
fragment_text = fragment_file.read_text()
matches = re.findall(match_regex, fragment_text, re.S)
for mode, patch_regex, patch_text, _ in matches:
fragment_matches = re.findall(patch_regex, target_text)
if not fragment_matches:
print(f"warning: regex did not match anything for '{patch_regex}'");
if mode == "DELETE":
target_text = re.sub(patch_regex, "", target_text)
elif mode == "REPLACE":
target_text = re.sub(patch_regex, patch_text, target_text)
elif mode == "INSERT":
target_text = re.sub("("+patch_regex+")", r'\1'+patch_text, target_text)
target_path.write_text(target_text)

View file

@ -10,7 +10,7 @@ PREFIX=$(realpath build/zlib-wasm)
cd build
rm -rf zlib
git clone -b master --depth=1 https://github.com/madler/zlib
git clone -b v1.3.1 --depth=1 https://github.com/madler/zlib
cd zlib
emconfigure ./configure --static