# Description: C grammar for tree-sitter
# URL: https://github.com/tree-sitter/tree-sitter-c
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: npm tree-sitter

name=tree-sitter-c
version=0.20.4
release=1
source=(https://github.com/tree-sitter/tree-sitter-c/archive/v$version/$name-$version.tar.gz)

build() {
  cd $name-$version

  tree-sitter generate --log
  cd src
  export CFLAGS+=' -fPIC'
  cc $CFLAGS -std=c99 -c parser.c
  cc $LDFLAGS -shared parser.o -o parser.so

  install -Dm 644 parser.so $PKG/usr/lib/libtree-sitter-c.so
  install -d $PKG/usr/share/nvim/runtime/parser/
  ln -s /usr/lib/libtree-sitter-c.so $PKG/usr/share/nvim/runtime/parser/c.so
}
