-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·82 lines (63 loc) · 1.98 KB
/
build.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
#!/usr/bin/env bash
set -e
echo "Building AnalysisToolsTS... "
CUR_DIR=$(dirname "${0}")
BUILD_DIR=${CUR_DIR}/build
INCLUDE_DIR=${CUR_DIR}/include
mkdir -p "${BUILD_DIR}"
mkdir -p "${INCLUDE_DIR}"
########################################################################
# These variables specify the minimum version necessary for
# dependencies between versions.
source "${CUR_DIR}"/versions.sh
########################################################################
# 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}... "
LOCKED_BRANCH="${repo//-/_}"_hash
cd "${CUR_DIR}"
if [ -d "${dir}" ]; then
echo "pulling changes ..."
# IF THE REPO ALREADY EXISTS...
pushd "${dir}"
# PULL CHANGES
git fetch
git reset --hard "${!LOCKED_BRANCH}"
popd
else
# THE REPO DID NOT EXIST
echo "the repository did not previously exist cloning... "
git clone "https://github.com/tree-sitter/${repo}" "${INCLUDE_DIR}/${repo}"
pushd "${dir}"
git reset --hard "${!LOCKED_BRANCH}"
popd
fi
done
# CHECKOUT & INSTALL THE NLOHMANN C++ JSON LIBRARY
echo "clone or update nlohmann"
if [ -d "${INCLUDE_DIR}/json" ]; then
echo "pulling changes ..."
pushd "${INCLUDE_DIR}/json"
CURRENT_BRANCH=$(git branch --show-current)
git fetch
git reset --hard HEAD
git merge "origin/${CURRENT_BRANCH}"
popd
else
git clone --depth 1 "https://github.com/nlohmann/json.git" "${INCLUDE_DIR}/json"
fi
########################################################################
# build tree sitter library
pushd "${INCLUDE_DIR}/tree-sitter"
make
popd
echo "building submitty_count_ts ..."
# Compile the project
cmake -S "${CUR_DIR}" -B "${BUILD_DIR}" -DJSONDIR="${INCLUDE_DIR}/json/include"
pushd "${BUILD_DIR}"
make
popd
echo "Done building AnalysisToolsTS"