-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_analysistoolsts.sh
executable file
·106 lines (74 loc) · 2.63 KB
/
install_analysistoolsts.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
#!/usr/bin/env bash
set -e
########################################################################################################################
########################################################################################################################
# this script must be run by root or sudo
if [[ "$UID" -ne "0" ]] ; then
echo "ERROR: This script must be run by root or sudo"
exit 1
fi
VARS="$(dirname "$0")"/submitty.sh
if [ $# -gt 0 ] && [ "$1" == "local" ]; then
VARS="$(dirname "$0")"/local.sh
fi
source "${VARS}"
echo -e "Installing AnalysisToolsTS... "
mkdir -p "${INSTALLATION_DIR}"
# Copy cloned files to AnalysisToolsTS directory
if [ $# -eq 0 ]; then
rsync -rtz "${REPO_DIR}/src" "${REPO_DIR}/CMakeLists.txt" "${INSTALLATION_DIR}"
fi
mkdir -p "${INCLUDE_DIR}"
########################################################################
# Clone the tree-sitter repos
repos=( tree-sitter tree-sitter-python tree-sitter-c tree-sitter-cpp tree-sitter-java)
for repo in "${repos[@]}"
do
dir="${INCLUDE_DIR}"/"${repo}"
echo "clone or update ${repo}... "
# TEMPORARY - workaround due to problem with the git repository
# just delete the directory and start over
echo "removing ${dir}"
rm -rf "${dir}"
# TEMPORARY
if [ -d "${dir}" ]; then
echo "pulling changes ..."
# IF THE REPO ALREADY EXISTS...
pushd "${dir}"
CURRENT_BRANCH=$(git branch --show-current)
# PULL CHANGES
git fetch
git reset --hard HEAD
git merge origin/"${CURRENT_BRANCH}"
popd
else
# THE REPO DID NOT EXIST
echo "the repository did not previously exist cloning... "
pushd "${INCLUDE_DIR}"
git clone --depth 1 "https://github.com/tree-sitter/${repo}"
popd
fi
done
# CHECKOUT & INSTALL THE NLOHMANN C++ JSON LIBRARY
# If we don't already have a copy of this repository, check it out, only for local development
if [ $# -gt 0 ] && [ ! -d "${NLOHMANN_DIR}" ]; then
git clone --depth 1 "https://github.com/nlohmann/json.git" "${NLOHMANN_DIR}"
fi
########################################################################
# build tree sitter library
pushd "${INCLUDE_DIR}"/tree-sitter
make
popd
echo "building submitty_count_ts ..."
# Compile the project
mkdir -p "${INSTALLATION_DIR}/build"
cmake -S "${INSTALLATION_DIR}" -B "${INSTALLATION_DIR}/build" -DJSONDIR="${NLOHMANN_INCLUDE_DIR}"
pushd "${INSTALLATION_DIR}/build"
make
popd
# # change permissions
if [ $# -eq 0 ]; then
chown -R root:root "${INSTALLATION_DIR}"
chmod -R 755 "${INSTALLATION_DIR}"
fi
echo "Done setting up AnalysisToolsTS"