-
Notifications
You must be signed in to change notification settings - Fork 6
/
dev.sh
executable file
·93 lines (67 loc) · 2.32 KB
/
dev.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
#!/usr/bin/env bash
set -euo pipefail
WORKDIR=$(pwd)
ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
export NICKEL_IMPORT_PATH="$WORKDIR/.vorpal/packages:$WORKDIR"
export PATH="$WORKDIR/deps/nickel/bin:$WORKDIR/deps/openssl/bin:$WORKDIR/deps/protoc/bin:$HOME/.cargo/bin:$PATH"
rustup show active-toolchain
if ! command -v cargo &> /dev/null || [[ ! -x "$(command -v cargo)" ]]; then
echo "cargo is not installed or not executable"
exit 1
fi
if ! command -v rustc &> /dev/null || [[ ! -x "$(command -v rustc)" ]]; then
echo "rustc is not installed or not executable"
exit 1
fi
mkdir -p ./deps
cd "${WORKDIR}"
if [[ ! -d "$PWD/deps/nickel/bin" ]]; then
NICKEL_ARCH=$ARCH
if [ "$ARCH" = "aarch64" ]; then
NICKEL_ARCH="arm64";
fi
mkdir -p deps/nickel/bin
if [ "$OS" == "darwin" ]; then
cargo install nickel-lang-cli
cp "$(which nickel)" deps/nickel/bin/nickel
fi
if [ "$OS" == "linux" ]; then
curl -fsSL \
"https://github.com/tweag/nickel/releases/download/1.7.0/nickel-${NICKEL_ARCH}-linux" \
-o deps/nickel/bin/nickel
chmod +x deps/nickel/bin/nickel
fi
fi
cd "${WORKDIR}"
if [[ ! -d "$PWD/deps/protoc/bin" ]]; then
PROTOC_SYSTEM=""
PROTOC_VERSION="28.0"
if [[ "${OS}" == "darwin" ]]; then
PROTOC_SYSTEM="osx"
elif [[ "${OS}" == "linux" ]]; then
PROTOC_SYSTEM="linux"
else
echo "Unsupported OS: ${OS}"
exit 1
fi
if [[ "${ARCH}" == "x86_64" ]]; then
PROTOC_SYSTEM="${PROTOC_SYSTEM}-x86_64"
elif [[ "${ARCH}" == "arm64" || "${ARCH}" == "aarch64" ]]; then
PROTOC_SYSTEM="${PROTOC_SYSTEM}-aarch_64"
else
echo "Unsupported ARCH: ${ARCH}"
exit 1
fi
if [[ "$PROTOC_SYSTEM" == "" ]]; then
echo "PROTOC_SYSTEM is empty"
exit 1
fi
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_SYSTEM}.zip"
mkdir -p deps/protoc
curl -L "${PROTOC_URL}" -o deps/protoc-${PROTOC_VERSION}-${PROTOC_SYSTEM}.zip
unzip deps/protoc-${PROTOC_VERSION}-${PROTOC_SYSTEM}.zip -d deps/protoc
rm -rf deps/protoc-${PROTOC_VERSION}-${PROTOC_SYSTEM}.zip
# TODO: support hash checking for downloads
fi
"$@"