-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·77 lines (60 loc) · 1.73 KB
/
build.sh
File metadata and controls
executable file
·77 lines (60 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
OPENSSL_VERSION="openssl-3.6.0"
FILENAME="$OPENSSL_VERSION.tar.gz"
DOWNLOAD_PATH="https://github.com/openssl/openssl/releases/download/$OPENSSL_VERSION/$FILENAME"
OPENSSL_DIR="src"
if [ -d ${OPENSSL_DIR} ]; then
rm -rf ${OPENSSL_DIR}
fi
if [ ! -f ${FILENAME} ]; then
echo Downloading from ${DOWNLOAD_PATH} $'\n'
curl -L -O ${DOWNLOAD_PATH}
fi
mkdir ${OPENSSL_DIR}
echo Extracting tar archive ${FILENAME} $'\n'
tar xf ${FILENAME} --strip-components=1 --directory=${OPENSSL_DIR}
cd ${OPENSSL_DIR} || exit 1
echo Apply patches $'\n'
patch -p1 -i ../speed_sched.patch
echo ''
echo Copying OpenSSL config $'\n'
mkdir -p usr/local/ssl/
cp ../openssl.cnf usr/local/ssl/openssl.cnf
LDFLAGS="\
-s ENVIRONMENT='web'\
-s FILESYSTEM=1\
-s MODULARIZE=1\
-s EXPORTED_RUNTIME_METHODS=\"['callMain', 'FS', 'TTY']\"\
-s INVOKE_RUN=0\
-s EXIT_RUNTIME=1\
-s EXPORT_ES6=0\
-s EXPORT_NAME='EmscrJSR_openssl'\
-s ALLOW_MEMORY_GROWTH=1\
--embed-file usr/local/ssl/openssl.cnf"
if [[ $1 == "debug" ]]; then
LDFLAGS="$LDFLAGS -s ASSERTIONS=1" # For logging purposes.
fi
export LDFLAGS
export CC=emcc
export CXX=emcc
echo Running Emscripten $'\n'
emconfigure ./Configure \
no-shared \
no-asm \
no-threads \
no-ssl3 \
no-dtls \
no-engine \
no-dso \
linux-x32 \
-static\
sed -i 's/$(CROSS_COMPILE)//' Makefile
emmake make -j 16 build_generated libssl.a libcrypto.a apps/openssl
mv apps/openssl apps/openssl.js
echo Copying OpenSSL binary into emscr/binary folder
# import wasm build
cp apps/openssl.js ../../../binary/openssl.js || exit 1
cp apps/openssl.wasm ../../../binary/openssl.wasm || exit 1
sed -i '1s;^;\/* eslint-disable *\/;' ../../../binary/openssl.js
# clean up directory
cd .. && rm -rf ${OPENSSL_DIR} ${FILENAME}