-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
executable file
·82 lines (63 loc) · 2.54 KB
/
install.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
set -e
DISTRO_LIST="arch debian ubuntu fedora"
UNAME_S=`uname -s`
if [ $UNAME_S != "Darwin" ]; then
DISTRO=`grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"'`
if [ $DISTRO = "raspbian" ]; then
DISTRO="debian"
elif ! echo $DISTRO_LIST | grep -w -q $DISTRO; then
echo "🤖 Unknown distribution, defaulting to ubuntu"
DISTRO="ubuntu"
fi
fi
PLATFORM=`uname -s`-$DISTRO-`uname -m`
REPOSITORY="github.com/RainingComputers/ShnooTalk"
REPOSITORY_URL="https://$REPOSITORY"
TAGS=`git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' $REPOSITORY_URL`
VERSION=`echo ${TAGS##*/}`
COMPILER_SRC_TAR_DIR_NAME=`echo ShnooTalk-$VERSION`
COMPILER_SRC_TAR_NAME=`echo $COMPILER_SRC_TAR_DIR_NAME.tar.gz`
COMPILER_TAR_DIR_NAME=`echo "shtkc-$VERSION-$PLATFORM"`
COMPILER_TAR_NAME=`echo "$COMPILER_TAR_DIR_NAME.tar.gz"`
STDLIB_TAR_NAME=`echo shnootalk-stdlib-$VERSION.tar.gz`
COMPILER_SRC_RELEASE_LINK="$REPOSITORY/archive/refs/tags/$VERSION.tar.gz"
COMPILER_RELEASE_LINK="$REPOSITORY/releases/latest/download/$COMPILER_TAR_NAME"
COMPILER_BIN_DEST=`echo /usr/local/bin/shtkc-$VERSION`
COMPILER_BIN_SYMLINK_DEST=/usr/local/bin/shtkc
STDLIB_DEST=`echo /usr/local/lib/shnootalk-$VERSION/`
if [ $UNAME_S = "Darwin" ]; then
echo "🤖 Installing llvm@12 using brew"
brew install llvm@12
echo "Downloding $COMPILER_SRC_TAR_NAME"
curl -L $COMPILER_SRC_RELEASE_LINK > $COMPILER_SRC_TAR_NAME
echo "🤖 Extracting $COMPILER_SRC_TAR_NAME"
tar -xf $COMPILER_SRC_TAR_NAME
echo "🤖 Building compiler"
make -C $COMPILER_SRC_TAR_DIR_NAME build -j 4
echo "🤖 Installing compiler and stdlib (requires sudo)"
sudo make -C $COMPILER_SRC_TAR_DIR_NAME install
else
echo "🤖 Downloading $COMPILER_TAR_NAME"
curl -OL $COMPILER_RELEASE_LINK
echo "🤖 Extracting $COMPILER_TAR_NAME"
tar -xf $COMPILER_TAR_NAME
echo "🤖 Installing compiler"
rm -f $COMPILER_BIN_DEST
mv $COMPILER_TAR_DIR_NAME/shtkc $COMPILER_BIN_DEST
rm -f $COMPILER_BIN_SYMLINK_DEST
ln -s $COMPILER_BIN_DEST $COMPILER_BIN_SYMLINK_DEST
echo "🤖 Downloading $STDLIB_TAR_NAME"
STDLIB_RELEASE_LINK="$REPOSITORY/releases/latest/download/$STDLIB_TAR_NAME"
curl -OL $STDLIB_RELEASE_LINK
echo "🤖 Extracting $STDLIB_TAR_NAME"
tar -xf $STDLIB_TAR_NAME
echo "🤖 Installing stdlib"
rm -rf $STDLIB_DEST
mv stdlib/ $STDLIB_DEST
fi
echo "🤖 Removing temp files"
rm -rf $COMPILER_SRC_TAR_DIR_NAME
rm -rf $COMPILER_TAR_DIR_NAME
rm -f $COMPILER_SRC_TAR_NAME
rm -f $COMPILER_TAR_NAME
rm -f $STDLIB_TAR_NAME