Wed Jan 18 13:28:15 2023 UTC ()
tree-sitter: not all grammars come with a scanner, make it optional


(wiz)
diff -r1.2 -r1.3 pkgsrc/textproc/tree-sitter/grammar.mk

cvs diff -r1.2 -r1.3 pkgsrc/textproc/tree-sitter/grammar.mk (expand / switch to unified diff)

--- pkgsrc/textproc/tree-sitter/grammar.mk 2023/01/18 08:21:32 1.2
+++ pkgsrc/textproc/tree-sitter/grammar.mk 2023/01/18 13:28:15 1.3
@@ -1,25 +1,26 @@ @@ -1,25 +1,26 @@
1# $NetBSD: grammar.mk,v 1.2 2023/01/18 08:21:32 wiz Exp $ 1# $NetBSD: grammar.mk,v 1.3 2023/01/18 13:28:15 wiz Exp $
2# 2#
3# Common logic to build and install tree-sitter grammars. 3# Common logic to build and install tree-sitter grammars.
4# 4#
5# GRAMMAR_LIBRARY_NAME 5# GRAMMAR_LIBRARY_NAME
6# Name of the grammar library to build and install. 6# Name of the grammar library to build and install.
7# 7#
8 8
9GRAMMAR_LIBRARY_NAME?= lib${PKGBASE} 9GRAMMAR_LIBRARY_NAME?= lib${PKGBASE}
10 10
11USE_LANGUAGES+= c c++ 11USE_LANGUAGES+= c c++
12 12
13do-build: 13do-build:
14 cd ${WRKSRC}/src && \ 14 cd ${WRKSRC}/src && \
15 ${CC} ${CFLAGS} -std=c99 -I. -c -fPIC parser.c 15 ${CC} ${CFLAGS} -std=c99 -I. -c -fPIC parser.c
16 cd ${WRKSRC}/src && \ 16 cd ${WRKSRC}/src && \
17 if [ -f scanner.c ]; then ${CC} ${CFLAGS} -std=c99 -I. -c -fPIC scanner.c; else \ 17 if [ -f scanner.c ]; then ${CC} ${CFLAGS} -std=c99 -I. -c -fPIC scanner.c; fi
18 ${CXX} ${CXXFLAGS} -I. -c -fPIC scanner.cc; fi 
19 cd ${WRKSRC}/src && \ 18 cd ${WRKSRC}/src && \
20 ${CXX} -shared -o ${GRAMMAR_LIBRARY_NAME}.so scanner.o parser.o 19 if [ -f scanner.cc ]; then ${CXX} ${CXXFLAGS} -I. -c -fPIC scanner.cc; fi
 20 cd ${WRKSRC}/src && \
 21 ${CXX} -shared -o ${GRAMMAR_LIBRARY_NAME}.so *.o
21 22
22INSTALLATION_DIRS+= lib 23INSTALLATION_DIRS+= lib
23 24
24do-install: 25do-install:
25 ${INSTALL_LIB} ${WRKSRC}/src/${GRAMMAR_LIBRARY_NAME}.so ${DESTDIR}${PREFIX}/lib 26 ${INSTALL_LIB} ${WRKSRC}/src/${GRAMMAR_LIBRARY_NAME}.so ${DESTDIR}${PREFIX}/lib