forked from bytecodealliance/wasm-micro-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreparation.sh
More file actions
executable file
·131 lines (114 loc) · 2.95 KB
/
preparation.sh
File metadata and controls
executable file
·131 lines (114 loc) · 2.95 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
#
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
readonly BUILD_CONTENT="/tmp/build_content"
readonly WASI_SDK_VER=12
readonly WASI_SDK_FILE="wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz"
readonly WABT_VER=1.0.20
readonly WABT_FILE="wabt-${WABT_VER}-ubuntu.tar.gz"
readonly CMAKE_VER=3.16.2
readonly CMAKE_FILE="cmake-${CMAKE_VER}-Linux-x86_64.sh"
readonly BINARYEN_VER=version_97
readonly BINARYEN_FILE="binaryen-${BINARYEN_VER}-x86_64-linux.tar.gz"
readonly BAZEL_VER=3.7.0
readonly BAZEL_FILE=bazel-${BAZEL_VER}-installer-linux-x86_64.sh
function DEBUG() {
env | grep -q "\<DEBUG\>"
}
#
# install dependency
function install_deps() {
apt update
apt install -y lsb-release wget software-properties-common \
build-essential git tree zip unzip
}
#
# install clang
#function install_clang() {
# if [[ ! -f llvm.sh ]]; then
# wget https://apt.llvm.org/llvm.sh
# fi
#
# chmod a+x llvm.sh
# ./llvm.sh 11
#}
#
# install wasi-sdk
function install_wasi-sdk() {
if [[ ! -f ${WASI_SDK_FILE} ]]; then
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER}/${WASI_SDK_FILE}
fi
tar zxf ${WASI_SDK_FILE} -C /opt
ln -sf /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk
}
#
# install wabt
function install_wabt() {
if [[ ! -f ${WABT_FILE} ]]; then
wget https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/${WABT_FILE}
fi
tar zxf ${WABT_FILE} -C /opt
ln -sf /opt/wabt-${WABT_VER} /opt/wabt
}
#
# install cmake
function install_cmake() {
if [[ ! -f cmake-${CMAKE_VER}-Linux-x86_64.sh ]]; then
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/${CMAKE_FILE}
fi
chmod a+x ${CMAKE_FILE}
mkdir /opt/cmake
./${CMAKE_FILE} --prefix=/opt/cmake --skip-license
ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake
}
#
# install emsdk
function install_emsdk() {
cd /opt
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
echo "source /opt/emsdk/emsdk_env.sh" >> "${HOME}"/.bashrc
}
#
# install binaryen
function install_binaryen() {
if [[ ! -f ${BINARYEN_FILE} ]]; then
wget https://github.com/WebAssembly/binaryen/releases/download/${BINARYEN_VER}/${BINARYEN_FILE}
fi
tar zxf ${BINARYEN_FILE} -C /opt
ln -sf /opt/binaryen-${BINARYEN_VER} /opt/binaryen
}
#
# install bazel
function install_bazel() {
if [[ ! -f ${BAZEL_FILE} ]]; then
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/${BAZEL_FILE}
fi
chmod a+x ${BAZEL_FILE}
./${BAZEL_FILE}
}
#
# MAIN
DEBUG && set -xevu
if [[ ! -d ${BUILD_CONTENT} ]]; then
mkdir ${BUILD_CONTENT}
fi
cd ${BUILD_CONTENT} || exit
if DEBUG; then
"$@"
else
install_deps \
&& install_wasi-sdk \
&& install_wabt \
&& install_cmake \
&& install_emsdk \
&& install_binaryen \
&& install_bazel
fi
cd - > /dev/null || exit
DEBUG && set +xevu