Commit
Author: Kevin Schoon [me@kevinschoon.com]
Hash: e09f80e19f32205da8301dc2124ee7020b7fd316
Timestamp: Sun, 23 Jul 2023 15:57:55 +0000 (1 year ago)

+39 -0 +/-3 browse
add installer script
1diff --git a/README.md b/README.md
2index 9e87b84..c516d09 100644
3--- a/README.md
4+++ b/README.md
5 @@ -5,6 +5,22 @@ by downstream projects. Each parser is exposed as a shared module that can be
6 dynamically loaded in another application. Generated source code is also shipped
7 for use in build scripts.
8
9+ ## Installation
10+
11+ The best way to install this is via your package manager.
12+
13+ ### Known Distribution Packages
14+
15+ [aur](https://aur.archlinux.org/packages/tree-sitter-amalgamation)
16+
17+ ### Manual Installation
18+
19+ ```sh
20+ sudo ./install.sh
21+ # uninstall
22+ sudo ./uninstall.sh
23+ ```
24+
25 ## Compiling
26
27 You need to install [ninja](https://ninja-build.org) to build the project
28 diff --git a/install.sh b/install.sh
29new file mode 100755
30index 0000000..6e57778
31--- /dev/null
32+++ b/install.sh
33 @@ -0,0 +1,19 @@
34+ #!/bin/sh
35+
36+ install -d /usr/lib/tree-sitter-amalgamation
37+ install -t /usr/lib/tree-sitter-amalgamation target/*/*.so
38+ install -d /usr/include/tree-sitter-amalgamation
39+ for name in `find target -maxdepth 1 -type d -printf '%f\n' | tail -n +2` ; do
40+ install -d "/usr/include/tree-sitter-amalgamation/$name"
41+ install -m 0444 -t "/usr/include/tree-sitter-amalgamation/$name" \
42+ target/$name/*.c
43+ [[ -f target/$name/highlights.scm ]] && {
44+ install -m 0444 -t "/usr/include/tree-sitter-amalgamation/$name" \
45+ "target/$name/highlights.scm"
46+ }
47+ [[ -f target/$name/common/scanner.h ]] && {
48+ install -d "/usr/include/tree-sitter-amalgamation/$name/common"
49+ install -m 0444 -t "/usr/include/tree-sitter-amalgamation/$name/common" \
50+ "target/$name/common/scanner.h"
51+ }
52+ done
53 diff --git a/uninstall.sh b/uninstall.sh
54new file mode 100755
55index 0000000..4b246f3
56--- /dev/null
57+++ b/uninstall.sh
58 @@ -0,0 +1,4 @@
59+ #!/bin/sh
60+
61+ rm -r /usr/lib/tree-sitter-amalgamation
62+ rm -r /usr/include/tree-sitter-amalgamation