-
Notifications
You must be signed in to change notification settings - Fork 36
/
build-emception.sh
executable file
·68 lines (53 loc) · 1.71 KB
/
build-emception.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
SRC=$(dirname $0)
BUILD="$1"
if [ "$BUILD" == "" ]; then
BUILD=$(pwd)/build
fi
SRC=$(realpath "$SRC")
BUILD=$(realpath "$BUILD")
if [ ! -d $BUILD/emception/ ]; then
mkdir -p $BUILD/emception/
fi
cp $SRC/src/* $BUILD/emception/
cp $SRC/src/* $BUILD/emception/
mkdir -p $BUILD/emception/llvm/
cp $BUILD/llvm/bin/llvm-box.mjs $BUILD/emception/llvm/
mkdir -p $BUILD/emception/binaryen/
cp $BUILD/binaryen/bin/binaryen-box.mjs $BUILD/emception/binaryen/
mkdir -p $BUILD/emception/quicknode/
cp $BUILD/quicknode/quicknode.mjs $BUILD/emception/quicknode/
mkdir -p $BUILD/emception/cpython/
cp $BUILD/cpython/python.mjs $BUILD/emception/cpython/
mkdir -p $BUILD/emception/brotli/
cp $BUILD/brotli/brotli.{mjs,wasm} $BUILD/emception/brotli/
mkdir -p $BUILD/emception/wasm-package/
cp $BUILD/wasm-package/wasm-package.{mjs,wasm} $BUILD/emception/wasm-package/
$SRC/build-packs.sh $BUILD
mkdir -p $BUILD/emception/packages
cp $BUILD/packs/*.pack $BUILD/emception/packages
EXT=".pack"
if [ "$EMCEPTION_NO_COMPRESS" != "1" ]; then
# Use brotli compressed packages
EXT=".pack.br"
for PACK in $BUILD/emception/packages/*.pack; do
PACK=$(basename $PACK .pack)
brotli --best --keep $BUILD/emception/packages/$PACK.pack &
done
wait
fi
IMPORTS=""
EXPORTS=""
for PACK in $BUILD/emception/packages/*.pack; do
PACK=$(basename $PACK .pack)
NAME=$(echo $PACK | sed 's/[^a-zA-Z0-9_]/_/g')
IMPORTS=$(printf \
"%s\nimport %s from \"./packages/%s\";" \
"$IMPORTS" "$NAME" "$PACK$EXT" \
)
EXPORTS=$(printf \
"%s\n \"%s\": %s," \
"$EXPORTS" "$PACK" "$NAME" \
)
done
printf '%s\nexport default {%s\n};' "$IMPORTS" "$EXPORTS" > "$BUILD/emception/packs.mjs"