forked from scrtlabs/SecretNetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-wasm-tools.sh
executable file
·114 lines (98 loc) · 3.64 KB
/
install-wasm-tools.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
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
#! /bin/bash
if [[ "$OSTYPE" == "linux-gnu" ]]; then
set -e
if [[ `whoami` == "root" ]]; then
MAKE_ME_ROOT=
else
MAKE_ME_ROOT=sudo
fi
if [ -f /etc/redhat-release ]; then
echo "Redhat Linux detected."
echo "This OS is not supported with this script at present. Sorry."
echo "Please refer to https://github.com/paritytech/substrate for setup information."
exit 1;
elif [ -f /etc/SuSE-release ]; then
echo "Suse Linux detected."
echo "This OS is not supported with this script at present. Sorry."
echo "Please refer to https://github.com/paritytech/substrate for setup information."
exit 1;
elif [ -f /etc/arch-release ]; then
echo "Arch Linux detected."
$MAKE_ME_ROOT pacman -Syu --needed --noconfirm curl jq tar cmake gcc clang
elif [ -f /etc/mandrake-release ]; then
echo "Mandrake Linux detected."
echo "This OS is not supported with this script at present. Sorry."
echo "Please refer to https://github.com/paritytech/substrate for setup information."
exit 1;
elif [ -f /etc/debian_version ]; then
echo "Ubuntu/Debian Linux detected."
$MAKE_ME_ROOT apt update
$MAKE_ME_ROOT apt install -y curl jq tar build-essential clang libclang-dev
else
echo "Unknown Linux distribution."
echo "This OS is not supported with this script at present. Sorry."
echo "Please refer to https://github.com/paritytech/substrate for setup information."
exit 1;
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Mac OS (Darwin) detected."
set -e
if ! which brew >/dev/null 2>&1; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew update
brew install binaryen wabt curl cmake llvm
elif [[ "$OSTYPE" == "freebsd"* ]]; then
echo "FreeBSD detected."
echo "This OS is not supported with this script at present. Sorry."
echo "Please refer to https://github.com/paritytech/substrate for setup information."
exit 1;
else
echo "Unknown operating system."
echo "This OS is not supported with this script at present. Sorry."
echo "Please refer to https://github.com/paritytech/substrate for setup information."
exit 1;
fi
if ! which rustup >/dev/null 2>&1; then
curl https://sh.rustup.rs -sSf | sh -s -- -y
source ~/.cargo/env
fi
rustup update stable
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain stable
rustup target add wasm32-unknown-unknown --toolchain nightly
# While ink! is pinned to a specific nightly version of the Rust compiler you will need to explicitly install that toolchain.
rustup install nightly-2019-05-21
rustup target add wasm32-unknown-unknown --toolchain nightly-2019-05-21
echo "Installing wasm-prune into ~/.cargo/bin"
cargo install pwasm-utils-cli --bin wasm-prune --force
# Copy WASM binaries after successful rust/cargo install.
if [[ "$OSTYPE" == "linux-gnu" ]]; then
set -e
BUILD_NUM=`curl -s https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | jq -r '.build'`
if [ -z ${BUILD_NUM+x} ]; then
echo "Could not fetch the latest build number.";
exit 1;
fi
tmp=`mktemp -d`
pushd $tmp > /dev/null
echo "Downloading wasm-binaries.tbz2";
curl -L -o wasm-binaries.tbz2 https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD_NUM/wasm-binaries.tbz2
declare -a binaries=("wasm2wat" "wat2wasm") # Default binaries
if [ "$#" -ne 0 ]; then
echo "Installing selected binaries.";
binaries=("$@");
else
echo "Installing default binaries.";
fi
for bin in "${binaries[@]}"
do
echo "Installing $bin into ~/.cargo/bin"
tar -xvjf wasm-binaries.tbz2 wasm-install/bin/$bin > /dev/null
cp -f wasm-install/bin/$bin ~/.cargo/bin/
done
popd > /dev/null
fi
echo ""
echo "Run source ~/.cargo/env now to update environment."
echo ""