summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1a252aa897114b498ab17713ca12851994426839 (plain)
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
# Maintainer: Wing Hei Chan <whmunkchan@outlook.com>

_lang=typst
_pkgname="tree-sitter-$_lang"
pkgname="$_pkgname-git"
pkgver=v0.11.0.r3.g3924cb9
pkgrel=1
pkgdesc="Typst grammar for tree-sitter"
arch=('x86_64')
url="https://github.com/uben0/tree-sitter-typst"
license=('MIT')
groups=('tree-sitter-grammars')
makedepends=('git' 'tree-sitter-cli')
optdepends=('tree-sitter: core library')
provides=("lib$_pkgname.so")
source=("$_pkgname::git+$url")
b2sums=('SKIP')

pkgver() {
  cd "$_pkgname"
  git describe --long --tags --abbrev=7 \
    | sed "s/\([^-]*-g\)/r\1/;s/-/./g"
}

prepare() {
  cd "$_pkgname"
  tree-sitter generate --no-bindings src/grammar.json
}

build() {
  cd "$_pkgname"/src
  cc $CFLAGS -fPIC -std=c99 -c parser.c
  cc $CFLAGS -fPIC -std=c99 -c scanner.c
  cc $LDFLAGS -shared parser.o scanner.o \
    -o "$srcdir"/"$_pkgname"/lib"$_pkgname".so
}

package() {
  cd "$_pkgname"
  install -Dm755 -t "$pkgdir"/usr/lib lib"$_pkgname".so
  install -d "$pkgdir"/usr/lib/tree_sitter
  ln -s /usr/lib/lib"$_pkgname".so \
    "$pkgdir"/usr/lib/tree_sitter/"$_lang".so

  install -Dm644 -t "$pkgdir"/usr/share/doc/"$_pkgname" README.md
  install -Dm644 -t "$pkgdir"/usr/share/licenses/"$_pkgname" LICENSE
}
# Local Variables:
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End: