2021-06-20 15:14:43 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-11-02 17:42:43 +00:00
|
|
|
WASI_ROOT=${HOME}/Downloads/wasi
|
|
|
|
WASI_MAJOR=16
|
|
|
|
WASI_VERSION=${WASI_MAJOR}.0
|
|
|
|
|
|
|
|
export WASI_SDK=${WASI_ROOT}/wasi-sdk-${WASI_VERSION}
|
|
|
|
export WASI_SYSROOT=${WASI_ROOT}/wasi-sysroot-${WASI_VERSION}
|
2021-06-20 15:14:43 +00:00
|
|
|
|
|
|
|
if [ ! -d "$WASI_SDK" ]; then
|
|
|
|
#OS=linux,macos,mingw
|
|
|
|
OS=`uname`
|
|
|
|
case "$OS" in
|
|
|
|
linux|Linux) OS=linux ; ;;
|
|
|
|
darwin|Darwin) OS=macos ; ;;
|
|
|
|
windows|Windows) OS=mingw ; ;;
|
|
|
|
esac
|
|
|
|
mkdir -p ~/Downloads/wasi
|
2022-11-02 17:42:43 +00:00
|
|
|
rm -f ~/Downloads/wasi/wasi-sdk.tar.gz
|
|
|
|
wget -c -O ~/Downloads/wasi/wasi-sdk.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_MAJOR}/wasi-sdk-${WASI_VERSION}-$OS.tar.gz || exit 1
|
|
|
|
rm -f ~/Downloads/wasi/wasi-sysroot.tar.gz
|
|
|
|
wget -c -O ~/Downloads/wasi/wasi-root.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_MAJOR}/wasi-sysroot-${WASI_VERSION}.tar.gz || exit 1
|
2021-06-20 15:14:43 +00:00
|
|
|
(
|
|
|
|
cd ~/Downloads/wasi
|
|
|
|
tar xzvf wasi-sdk.tar.gz
|
|
|
|
tar xzvf wasi-root.tar.gz
|
2022-11-02 17:42:43 +00:00
|
|
|
mv wasi-sysroot wasi-sysroot-${WASI_VERSION}
|
2021-06-20 15:14:43 +00:00
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
2022-11-02 17:42:43 +00:00
|
|
|
export CFLAGS="-D_WASI_EMULATED_SIGNAL -O2 -D__wasi__=1"
|
2022-11-02 20:17:17 +00:00
|
|
|
export CFLAGS="${CFLAGS} -D_WASI_EMULATED_PROCESS_CLOCKS=1"
|
2022-11-02 17:42:43 +00:00
|
|
|
|
|
|
|
cp -f dist/plugins-cfg/plugins.wasi.cfg plugins.cfg
|
2021-06-20 15:14:43 +00:00
|
|
|
|
2022-11-02 17:42:43 +00:00
|
|
|
echo "WASI_SDK=$WASI_SDK"
|
2021-06-20 15:14:43 +00:00
|
|
|
|
|
|
|
# export CC="${WASI_SDK}/bin/clang -D
|
2021-07-21 10:24:17 +00:00
|
|
|
ERR=0
|
2022-11-02 16:38:54 +00:00
|
|
|
./configure --with-static-themes --without-gperf --with-compiler=wasi --disable-debugger --without-fork --with-ostype=wasi --with-checks-level=0 --disable-threads --without-dylink --with-libr --without-gpl
|
2021-06-20 15:14:43 +00:00
|
|
|
make -j
|
2021-06-21 11:51:31 +00:00
|
|
|
R2V=`./configure -qV`
|
|
|
|
D="radare2-$R2V-wasi"
|
|
|
|
mkdir -p $D
|
2021-06-20 15:14:43 +00:00
|
|
|
for a in rax2 radare2 rasm2 rabin2 rafind2 ; do
|
|
|
|
make -C binr/$a
|
2021-07-21 10:24:17 +00:00
|
|
|
cp -f binr/$a/$a.wasm $D || ERR=1
|
2021-06-20 15:14:43 +00:00
|
|
|
done
|
2022-11-02 17:42:43 +00:00
|
|
|
# for a in $D/*.wasm ; do
|
|
|
|
# echo "Optimizing $a ..."
|
|
|
|
# wasm-opt -o $a.o3.wasm -O3 $a
|
|
|
|
# done
|
2021-06-21 11:51:31 +00:00
|
|
|
zip -r "$D".zip $D
|
2021-07-21 10:24:17 +00:00
|
|
|
exit $ERR
|