tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: tree-sitter grammars



On 18 Jan 2023, at 5:21, Thomas Klausner wrote:

I've created textproc/tree-sitter/grammar.mk and created a package for
a python grammar for it (textproc/tree-sitter-python).

With pin's help I've tested this with wip/diffsitter and it worked.

Can we libtoolify this? I ask because on macOS I see this sort of thing, and I generally find it more maintainable to let libtool handle platform differences like these:

=> Checking for missing run-time search paths in tree-sitter-dockerfile-0.1.2 ERROR: lib/libtree-sitter-dockerfile.so: relative library path: libtree-sitter-dockerfile.so ERROR: lib/libtree-sitter-dockerfile.so: missing library: libtree-sitter-dockerfile.so

Indeed, the library doesn't look quite right:

$ otool -L work.magnetic-babysitter/.destdir/opt/pkg/lib/libtree-sitter-dockerfile.so
    work.magnetic-babysitter/.destdir/opt/pkg/lib/libtree-sitter-dockerfile.so:
libtree-sitter-dockerfile.so (compatibility version 0.0.0, current version 0.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.36.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

This one looks better, though I haven't tried it yet:

    $ otool -L /opt/pkg/lib/libtree-sitter-c.dylib
    /opt/pkg/lib/libtree-sitter-c.dylib:
/opt/pkg/lib/libtree-sitter-c.0.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.36.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

I got the above tree-sitter-c by twiddling its PLIST entry from .so to .la and changing tree-sitter/grammar.mk like so:

Index: grammar.mk
===================================================================
RCS file: /cvsroot/pkgsrc/textproc/tree-sitter/grammar.mk,v
retrieving revision 1.4
diff -u -p -r1.4 grammar.mk
--- grammar.mk	18 Jan 2023 16:32:26 -0000	1.4
+++ grammar.mk	18 Jan 2023 17:44:32 -0000
@@ -10,18 +10,19 @@ GRAMMAR_LIBRARY_NAME?=	lib${PKGBASE}
 GRAMMAR_SOURCE_DIR?=	src

 USE_LANGUAGES+=		c c++
+USE_LIBTOOL=		yes

 do-build:
 	cd ${WRKSRC}/${GRAMMAR_SOURCE_DIR} && \
-	${CC} ${CFLAGS} -std=c99 -I. -c -fPIC parser.c
+	libtool --mode=compile ${CC} ${CFLAGS} -std=c99 -I. -c -fPIC parser.c
 	cd ${WRKSRC}/${GRAMMAR_SOURCE_DIR} && \
- if [ -f scanner.c ]; then ${CC} ${CFLAGS} -std=c99 -I. -c -fPIC scanner.c; fi + if [ -f scanner.c ]; then libtool --mode=compile ${CC} ${CFLAGS} -std=c99 -I. -c -fPIC scanner.c; fi
 	cd ${WRKSRC}/${GRAMMAR_SOURCE_DIR} && \
- if [ -f scanner.cc ]; then ${CXX} ${CXXFLAGS} -I. -c -fPIC scanner.cc; fi + if [ -f scanner.cc ]; then libtool --mode=compile ${CXX} ${CXXFLAGS} -I. -c -fPIC scanner.cc; fi
 	cd ${WRKSRC}/${GRAMMAR_SOURCE_DIR} && \
-	${CXX} -shared -o ${GRAMMAR_LIBRARY_NAME}.so *.o
+ libtool --mode=link ${CXX} -o ${GRAMMAR_LIBRARY_NAME}.la -rpath ${PREFIX}/lib *.lo

 INSTALLATION_DIRS+=	lib

 do-install:
- ${INSTALL_LIB} ${WRKSRC}/${GRAMMAR_SOURCE_DIR}/${GRAMMAR_LIBRARY_NAME}.so ${DESTDIR}${PREFIX}/lib + libtool --mode=install ${INSTALL_LIB} ${WRKSRC}/${GRAMMAR_SOURCE_DIR}/${GRAMMAR_LIBRARY_NAME}.la ${DESTDIR}${PREFIX}/lib

Home | Main Index | Thread Index | Old Index