summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: df5f5d4a1be856dbdc047675084f46bebef32d53 (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
52
53
# Maintainer: Wing Hei Chan <whmunkchan@outlook.com>
# Contributor: HelloImWar <helloimwar at proton dot me>
# Contributor: Luis Martinez <luis dot martinez at tuta dot io>

_lang=toml
_pkgname="tree-sitter-$_lang"
pkgname="$_pkgname-git"
pkgver=v0.5.1.r2.g8bd2056
pkgrel=3
pkgdesc="TOML grammar for tree-sitter"
arch=('x86_64')
url="https://github.com/ikatyang/tree-sitter-toml"
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 -I. -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: