forked from semgrep/ocaml-tree-sitter-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-tree-sitter-lib
executable file
·64 lines (54 loc) · 1.11 KB
/
install-tree-sitter-lib
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
#! /usr/bin/env bash
#
# Install the libtree-sitter runtime library.
#
set -eu -o pipefail
prog_name=$(basename "$0")
# Installation root for the tree-sitter executable and runtime library
default_prefix=$(pwd)/tree-sitter
error() {
echo "Current directory: $(pwd)" >&2
echo "Error: $@" >&2
exit 1
}
usage() {
cat <<EOF
Compile the tree-sitter library and install it.
Usage: $prog_name [OPTIONS]
Options:
--help
Show this message and exit.
--prefix PATH
Global installation directory for tree-sitter executables and libraries.
Default: $default_prefix
EOF
}
prefix="$default_prefix"
while [[ $# -gt 0 ]]; do
case "$1" in
--help)
usage
exit 0
;;
--prefix)
prefix="$2"
shift
;;
*)
error "Invalid argument passed to '${prog_name}': '$1'"
esac
shift
done
libdir="$prefix"/lib
dir_name=$(dirname "$BASH_SOURCE")
"$dir_name"/update-version-symlinks
"$dir_name"/download-tree-sitter --lazy
(
cd downloads/tree-sitter
make PREFIX="$prefix"
make PREFIX="$prefix" install
)
cat <<EOF
tree-sitter libraries were installed in:
$prefix/lib/
EOF