|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +echo "Building AnalysisToolsTS... " |
| 6 | + |
| 7 | +CUR_DIR=$(dirname "${0}") |
| 8 | +BUILD_DIR=${CUR_DIR}/build |
| 9 | +INCLUDE_DIR=${CUR_DIR}/include |
| 10 | + |
| 11 | +mkdir -p "${BUILD_DIR}" |
| 12 | +mkdir -p "${INCLUDE_DIR}" |
| 13 | + |
| 14 | +######################################################################## |
| 15 | + |
| 16 | +# Clone the tree-sitter repos |
| 17 | +repos=( tree-sitter tree-sitter-python tree-sitter-c tree-sitter-cpp tree-sitter-java) |
| 18 | + |
| 19 | +for repo in "${repos[@]}" |
| 20 | +do |
| 21 | + dir="${INCLUDE_DIR}/${repo}" |
| 22 | + |
| 23 | + echo "clone or update ${repo}... " |
| 24 | + |
| 25 | + if [ -d "${dir}" ]; then |
| 26 | + echo "pulling changes ..." |
| 27 | + # IF THE REPO ALREADY EXISTS... |
| 28 | + pushd "${dir}" |
| 29 | + |
| 30 | + CURRENT_BRANCH=$(git branch --show-current) |
| 31 | + |
| 32 | + # PULL CHANGES |
| 33 | + git fetch |
| 34 | + git reset --hard HEAD |
| 35 | + git merge "origin/${CURRENT_BRANCH}" |
| 36 | + |
| 37 | + popd |
| 38 | + else |
| 39 | + # THE REPO DID NOT EXIST |
| 40 | + echo "the repository did not previously exist cloning... " |
| 41 | + git clone --depth 1 "https://github.com/tree-sitter/${repo}" "${INCLUDE_DIR}/${repo}" |
| 42 | + fi |
| 43 | +done |
| 44 | + |
| 45 | +# CHECKOUT & INSTALL THE NLOHMANN C++ JSON LIBRARY |
| 46 | +echo "clone or update nlohmann" |
| 47 | +if [ -d "${INCLUDE_DIR}/json" ]; then |
| 48 | + echo "pulling changes ..." |
| 49 | + pushd "${INCLUDE_DIR}/json" |
| 50 | + |
| 51 | + CURRENT_BRANCH=$(git branch --show-current) |
| 52 | + git fetch |
| 53 | + git reset --hard HEAD |
| 54 | + git merge "origin/${CURRENT_BRANCH}" |
| 55 | + popd |
| 56 | +else |
| 57 | + git clone --depth 1 "https://github.com/nlohmann/json.git" "${INCLUDE_DIR}/json" |
| 58 | +fi |
| 59 | + |
| 60 | + |
| 61 | +######################################################################## |
| 62 | + |
| 63 | +# build tree sitter library |
| 64 | +pushd "${INCLUDE_DIR}/tree-sitter" |
| 65 | +make |
| 66 | +popd |
| 67 | + |
| 68 | +echo "building submitty_count_ts ..." |
| 69 | + |
| 70 | +# Compile the project |
| 71 | +cmake -S "${CUR_DIR}" -B "${BUILD_DIR}" -DJSONDIR="${INCLUDE_DIR}/json/include" |
| 72 | + |
| 73 | +pushd "${BUILD_DIR}" |
| 74 | +make |
| 75 | +popd |
| 76 | + |
| 77 | +echo "Done building AnalysisToolsTS" |
0 commit comments