[ITP] tree-sitter

Ken Brown kbrown@cornell.edu
Mon Jan 2 21:34:41 GMT 2023


cygport file and patch attached.

This package is present in all the major Linux distros.  I've tested the build 
on SCALLYWAG (https://github.com/cygwin/scallywag/actions/runs/3824702717), and 
I've tested that the library works as expected with the development version of 
emacs-29.

Ken
-------------- next part --------------
NAME="tree-sitter"
VERSION=0.20.7
RELEASE=1
LICENSE="MIT"

HOMEPAGE="https://tree-sitter.github.io"
SRC_URI="https://github.com/tree-sitter/${NAME}/archive/v${VERSION}/${NAME}-${VERSION}.tar.gz"
PATCH_URI="Makefile.patch"
CATEGORY="Libs Devel"
SUMMARY="An incremental parsing system for programming tools"
DESCRIPTION="Tree-sitter is a parser generator tool and an incremental parsing
library.  It can build a concrete syntax tree for a source file and
efficiently update the syntax tree as the source file is edited.
Tree-sitter aims to be:

 * General enough to parse any programming language
 * Fast enough to parse on every keystroke in a text editor
 * Robust enough to provide useful results even in the presence
   of syntax errors
 * Dependency-free so that the runtime library (which is written
   in pure C) can be embedded in any application"

PKG_NAMES="libtree-sitter0 libtree-sitter-devel"

libtree_sitter0_SUMMARY="${SUMMARY} (runtime)"
libtree_sitter0_CONTENTS="usr/bin/cygtree-sitter-0.dll"

libtree_sitter_devel_SUMMARY="${SUMMARY} (development)"
libtree_sitter_devel_CONTENTS="
	usr/include
	usr/lib
	usr/share/doc"

src_compile() {
	lndirs
	cd ${B}
	cygmake
}

src_install() {
	cd ${B}
	cyginstall PREFIX=/usr
}

SCALLYWAG=nodeploy
-------------- next part --------------
--- origsrc/tree-sitter-0.20.7/Makefile	2022-09-02 18:00:47.000000000 -0400
+++ src/tree-sitter-0.20.7/Makefile	2023-01-02 14:07:08.545346600 -0500
@@ -3,6 +3,7 @@ VERSION := 0.6.3
 # install directory layout
 PREFIX ?= /usr/local
 INCLUDEDIR ?= $(PREFIX)/include
+BINDIR ?= $(PREFIX)/bin
 LIBDIR ?= $(PREFIX)/lib
 PCLIBDIR ?= $(LIBDIR)/pkgconfig
 
@@ -26,37 +27,19 @@ SONAME_MAJOR := 0
 SONAME_MINOR := 0
 
 # OS-specific bits
-ifeq ($(shell uname),Darwin)
-	SOEXT = dylib
-	SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib
-	SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib
-	LINKSHARED += -dynamiclib -Wl,-install_name,$(LIBDIR)/libtree-sitter.$(SONAME_MAJOR).dylib
-else
-	SOEXT = so
-	SOEXTVER_MAJOR = so.$(SONAME_MAJOR)
-	SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR)
-	LINKSHARED += -shared -Wl,-soname,libtree-sitter.so.$(SONAME_MAJOR)
-endif
-ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly))
-	PCLIBDIR := $(PREFIX)/libdata/pkgconfig
-endif
-
-all: libtree-sitter.a libtree-sitter.$(SOEXTVER)
+	SOEXT = dll
+	LINKSHARED += -shared -Wl,--out-implib,libtree-sitter.dll.a
 
-libtree-sitter.a: $(OBJ)
-	$(AR) rcs $@ $^
+all: cygtree-sitter-$(SONAME_MAJOR).$(SOEXT)
 
-libtree-sitter.$(SOEXTVER): $(OBJ)
+cygtree-sitter-$(SONAME_MAJOR).$(SOEXT): $(OBJ)
 	$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@
-	ln -sf $@ libtree-sitter.$(SOEXT)
-	ln -sf $@ libtree-sitter.$(SOEXTVER_MAJOR)
 
 install: all
+	install -d '$(DESTDIR)$(BINDIR)'
+	install -m755 cygtree-sitter-$(SONAME_MAJOR).$(SOEXT) '$(DESTDIR)$(BINDIR)'/cygtree-sitter-$(SONAME_MAJOR).$(SOEXT)
 	install -d '$(DESTDIR)$(LIBDIR)'
-	install -m755 libtree-sitter.a '$(DESTDIR)$(LIBDIR)'/libtree-sitter.a
-	install -m755 libtree-sitter.$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter.$(SOEXTVER)
-	ln -sf libtree-sitter.$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter.$(SOEXTVER_MAJOR)
-	ln -sf libtree-sitter.$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter.$(SOEXT)
+	install -m755 libtree-sitter.dll.a '$(DESTDIR)$(LIBDIR)'/libtree-sitter.dll.a
 	install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter
 	install -m644 lib/include/tree_sitter/*.h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/
 	install -d '$(DESTDIR)$(PCLIBDIR)'
@@ -66,6 +49,6 @@ install: all
 	    tree-sitter.pc.in > '$(DESTDIR)$(PCLIBDIR)'/tree-sitter.pc
 
 clean:
-	rm -f lib/src/*.o libtree-sitter.a libtree-sitter.$(SOEXT) libtree-sitter.$(SOEXTVER_MAJOR) libtree-sitter.$(SOEXTVER)
+	rm -f lib/src/*.o cygtree-sitter-$(SONAME_MAJOR).$(SOEXT) libtree-sitter.dll.a
 
 .PHONY: all install clean


More information about the Cygwin-apps mailing list