-
Notifications
You must be signed in to change notification settings - Fork 17
/
js_build.sh
executable file
·60 lines (52 loc) · 2.95 KB
/
js_build.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
#!/bin/bash
OS=`uname | tr 'A-Z' 'a-z'`
if [ "$OS" != "darwin" -a "$OS" != "linux" ]
then
echo "not support for $OS"
exit 1
fi
BINARYENVERSION="105"
if [ "$OS" == "linux" ] && [ ! -f target/binaryen-version_$BINARYENVERSION/bin/wasm2js ]
then
rm -f target/binaryen-version_$BINARYENVERSION-x86_64-linux.tar.gz
wget https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYENVERSION/binaryen-version_$BINARYENVERSION-x86_64-linux.tar.gz -P target/
tar zxf target/binaryen-version_$BINARYENVERSION-x86_64-linux.tar.gz -C target/
rm -f target/binaryen-version_$BINARYENVERSION-x86_64-linux.tar.gz
fi
if [ "$OS" == "darwin" ] && [ ! -f target/binaryen-version_$BINARYENVERSION/bin/wasm2js ]
then
CPU=`uname -a | awk '{print $NF}'`
if [ "$CPU" == "x86_64" ]
then
rm -f target/binaryen-version_$BINARYENVERSION-x86_64-macos.tar.gz
wget https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYENVERSION/binaryen-version_$BINARYENVERSION-x86_64-macos.tar.gz -P target/
tar zxf target/binaryen-version_$BINARYENVERSION-x86_64-macos.tar.gz -C target/
rm -f target/binaryen-version_$BINARYENVERSION-x86_64-macos.tar.gz
elif [ "$CPU" == "arm64" ] && [ ! -f target/binaryen-version_$BINARYENVERSION/bin/wasm2js ]
then
rm -f target/binaryen-version_$BINARYENVERSION-arm64-macos.tar.gz
wget https://github.com/WebAssembly/binaryen/releases/download/version_$BINARYENVERSION/binaryen-version_$BINARYENVERSION-arm64-macos.tar.gz -P target/
tar zxf target/binaryen-version_$BINARYENVERSION-arm64-macos.tar.gz -C target/
rm -f target/binaryen-version_$BINARYENVERSION-arm64-macos.tar.gz
else
echo "not support for $CPU"
exit 1
fi
fi
target/binaryen-version_$BINARYENVERSION/bin/wasm2js bindings/wasm/pkg/defi_wallet_core_wasm_bg.wasm -o bindings/wasm/pkg/defi_wallet_core_wasm_bg.wasm.js
if [ "$OS" == "linux" ];then
sed -i 's/defi_wallet_core_wasm_bg.wasm/defi_wallet_core_wasm_bg.wasm.js/' bindings/wasm/pkg/defi_wallet_core_wasm_bg.js
sed -i 's/defi_wallet_core_wasm_bg.wasm/defi_wallet_core_wasm_bg.wasm.js/' bindings/wasm/pkg/defi_wallet_core_wasm.js
sed -i '5i\ "defi_wallet_core_wasm_bg.wasm.js",' bindings/wasm/pkg/package.json
sed -i '5i\ "snippets",' bindings/wasm/pkg/package.json
elif [ "$OS" == "darwin" ];then
sed -i '' -e $'s/defi_wallet_core_wasm_bg.wasm/defi_wallet_core_wasm_bg.wasm.js/' bindings/wasm/pkg/defi_wallet_core_wasm_bg.js
sed -i '' -e $'s/defi_wallet_core_wasm_bg.wasm/defi_wallet_core_wasm_bg.wasm.js/' bindings/wasm/pkg/defi_wallet_core_wasm.js
sed -i '' '5i\'$'\n'' "defi_wallet_core_wasm_bg.wasm.js",' bindings/wasm/pkg/package.json
sed -i '' '5i\'$'\n'' "snippet",' bindings/wasm/pkg/package.json
else
echo "not support for $OS"
exit 1
fi
echo "export var __wbindgen_export_2 = retasmFunc.__wbindgen_export_2;" >> bindings/wasm/pkg/defi_wallet_core_wasm_bg.wasm.js
echo "finish"