public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] tree-sitter-grammar.eclass: force use of local parser.h
@ 2023-08-26 17:54 Sam James
  0 siblings, 0 replies; only message in thread
From: Sam James @ 2023-08-26 17:54 UTC (permalink / raw
  To: gentoo-dev; +Cc: matthew, sarnex, arthurzam, Sam James

There shouldn't be a system-wide copy of parser.h and upstream plan on
dropping this from dev-libs/tree-sitter as it can cause issues if there's
a mismatch between the version used for the bundled generated parser
vs the header used to build the library.

Force use of the correct one in the dist tarball at src/tree_sitter/parser.h
instead. Drop the dependency on dev-libs/tree-sitter given we were only depending
on it for this header.

Bug: https://github.com/tree-sitter/tree-sitter-bash/issues/199
Bug: https://bugs.gentoo.org/912716
Signed-off-by: Sam James <sam@gentoo.org>
---
 eclass/tree-sitter-grammar.eclass | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/eclass/tree-sitter-grammar.eclass b/eclass/tree-sitter-grammar.eclass
index e74d18653b8ad..b2563220cfc27 100644
--- a/eclass/tree-sitter-grammar.eclass
+++ b/eclass/tree-sitter-grammar.eclass
@@ -24,9 +24,6 @@ SRC_URI="https://github.com/tree-sitter/${PN}/archive/${TS_PV:-v${PV}}.tar.gz
 	-> ${P}.tar.gz"
 S="${WORKDIR}"/${PN}-${TS_PV:-${PV}}/src
 
-# Needed for tree_sitter/parser.h
-DEPEND="dev-libs/tree-sitter"
-
 BDEPEND+=" test? ( dev-util/tree-sitter-cli )"
 IUSE+=" test"
 RESTRICT+=" !test? ( test )"
@@ -61,8 +58,10 @@ tree-sitter-grammar_src_compile() {
 	# or scanner.cc.
 
 	tc-export CC CXX
-	export CFLAGS="${CFLAGS} -fPIC"
-	export CXXFLAGS="${CXXFLAGS} -fPIC"
+	# We want to use the bundled parser.h, not anything lurking on the system, hence -I
+	# See https://github.com/tree-sitter/tree-sitter-bash/issues/199#issuecomment-1694416505
+	export CFLAGS="${CFLAGS} -fPIC -I. -Itree_sitter"
+	export CXXFLAGS="${CXXFLAGS} -fPIC -I. -Itree_sitter"
 
 	local objects=( parser.o )
 	if [[ -f "${S}"/scanner.c || -f "${S}"/scanner.cc ]]; then
-- 
2.42.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-26 17:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-26 17:54 [gentoo-dev] [PATCH] tree-sitter-grammar.eclass: force use of local parser.h Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox