Skip to content

Commit

Permalink
tree-sitter-grammar.eclass: force use of local parser.h
Browse files Browse the repository at this point in the history
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: tree-sitter/tree-sitter-bash#199
Bug: https://bugs.gentoo.org/912716
Signed-off-by: Sam James <sam@gentoo.org>
  • Loading branch information
thesamesam committed Aug 26, 2023
1 parent 7834a00 commit 1c2cad6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions eclass/tree-sitter-grammar.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -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 )"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1c2cad6

Please sign in to comment.