forked from jprendes/emception
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-emception.sh
executable file
·86 lines (70 loc) · 2.37 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/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
if [ "$EMCEPTION_NO_COMPRESS" == "1" ]; then
# Do not use brotli compressed root.pack
MD5="$(md5sum "$BUILD/packs/root.pack")"
MD5="${MD5%% *}"
SIZE="$(stat --printf="%s" "$BUILD/packs/root.pack")"
{
echo "import root_pack_url from \"./root.pack\";"
echo -n 'export default ['
echo -n "\"/root.pack\""
echo -n ','
echo -n "$SIZE"
echo -n ','
echo -n "$MD5" | jq -sR | tr -d '\n'
echo -n ','
echo -n "root_pack_url"
echo '];'
} > "$BUILD/packs/root_pack.mjs"
else
# Use brotli compressed root.pack
brotli --best --keep $BUILD/packs/root.pack
MD5="$(md5sum "$BUILD/packs/root.pack.br")"
MD5="${MD5%% *}"
SIZE="$(stat --printf="%s" "$BUILD/packs/root.pack.br")"
{
echo "import root_pack_url from \"./root.pack.br\";"
echo -n 'export default ['
echo -n "\"/root.pack.br\""
echo -n ','
echo -n "$SIZE"
echo -n ','
echo -n "$MD5" | jq -sR | tr -d '\n'
echo -n ','
echo -n "root_pack_url"
echo '];'
} > "$BUILD/packs/root_pack.mjs"
fi
cp -f "$BUILD/packs/root.pack" "$BUILD/emception/"
cp -f "$BUILD/packs/root.pack.br" "$BUILD/emception/"
cp -f "$BUILD/packs/root_pack.mjs" "$BUILD/emception/"
cp -f -R "$BUILD/packs/emscripten/emscripten/lazy-cache" "$BUILD/emception/"
{
echo 'import lazy_cache from "./lazy-cache/index.mjs";'
echo 'export default lazy_cache;'
} > "$BUILD/emception/lazy-cache.mjs"