forked from jprendes/emception
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-quicknode.sh
executable file
·51 lines (42 loc) · 1.39 KB
/
build-quicknode.sh
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
#!/bin/bash
set -e
export $(cat .env | xargs)
SRC=$(dirname $0)
BUILD="$1"
QUICKNODE_SRC="$2"
if [ "$QUICKNODE_SRC" == "" ]; then
QUICKNODE_SRC="$SRC"/quicknode
fi
if [ "$BUILD" == "" ]; then
BUILD=$(pwd)/build
fi
SRC=$(realpath "$SRC")
BUILD=$(realpath "$BUILD")
QUICKNODE_BUILD=$BUILD/quicknode
# todo: create a way to reconfigure if the folder exists
if [ ! -d $QUICKNODE_BUILD/ ]; then
CXXFLAGS="
-fexceptions \
-s DISABLE_EXCEPTION_CATCHING=0 \
" \
LDFLAGS="\
-fexceptions \
-s DISABLE_EXCEPTION_CATCHING=0 \
-s ALLOW_MEMORY_GROWTH=1 \
-s EXPORTED_FUNCTIONS=_main,_free,_malloc \
-s EXPORTED_RUNTIME_METHODS=FS,PROXYFS,ERRNO_CODES,allocateUTF8 \
-lproxyfs.js \
--js-library=$SRC/emlib/fsroot.js \
" emcmake cmake -G Ninja \
-S $QUICKNODE_SRC/ \
-B $QUICKNODE_BUILD/ \
-DCMAKE_BUILD_TYPE=Release
# Make sure we build js modules (.mjs).
# The patch-ninja.sh script assumes that.
sed -E 's/quicknode\.js/quicknode\.mjs/g' $QUICKNODE_BUILD/build.ninja > /tmp/build.ninja
mv /tmp/build.ninja $QUICKNODE_BUILD/build.ninja
# The mjs patching is over zealous, and patches some source JS files rather than just output files.
# Undo that.
# sed -i -E 's/(pre|post|proxyfs|fsroot)\.mjs/\1.js/g' $QUICKNODE_BUILD/build.ninja
fi
cmake --build $QUICKNODE_BUILD/ -- quicknode