commit:     f0a16a3f519de9ec5ecef601788219dbba7e1a8f
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 26 18:02:46 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 27 20:26:13 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f0a16a3f

dev-libs/tree-sitter: stop installing parser.h

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.

Backport that change to avoid mismatches.

Bug: https://github.com/tree-sitter/tree-sitter-bash/issues/199
Bug: https://bugs.gentoo.org/912716
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../tree-sitter-0.20.8-no-parser-header.patch      | 23 +++++++++
 dev-libs/tree-sitter/tree-sitter-0.20.8-r1.ebuild  | 54 ++++++++++++++++++++++
 2 files changed, 77 insertions(+)

diff --git 
a/dev-libs/tree-sitter/files/tree-sitter-0.20.8-no-parser-header.patch 
b/dev-libs/tree-sitter/files/tree-sitter-0.20.8-no-parser-header.patch
new file mode 100644
index 000000000000..1e055a69e00d
--- /dev/null
+++ b/dev-libs/tree-sitter/files/tree-sitter-0.20.8-no-parser-header.patch
@@ -0,0 +1,23 @@
+https://github.com/tree-sitter/tree-sitter-bash/issues/199
+https://github.com/tree-sitter/tree-sitter/pull/2573
+https://github.com/tree-sitter/tree-sitter/pull/2574
+
+From 05b18c2cda9b391efffb4986bf46fa56333d801b Mon Sep 17 00:00:00 2001
+From: Andrew Hlynskyi <[email protected]>
+Date: Sat, 26 Aug 2023 20:50:23 +0300
+Subject: [PATCH] fix: makefile should install only  header
+
+--- a/Makefile
++++ b/Makefile
+@@ -57,7 +57,7 @@ install: all
+       ln -sf libtree-sitter.$(SOEXTVER) 
'$(DESTDIR)$(LIBDIR)'/libtree-sitter.$(SOEXTVER_MAJOR)
+       ln -sf libtree-sitter.$(SOEXTVER) 
'$(DESTDIR)$(LIBDIR)'/libtree-sitter.$(SOEXT)
+       install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter
+-      install -m644 lib/include/tree_sitter/*.h 
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/
++      install -m644 lib/include/tree_sitter/api.h 
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/
+       install -d '$(DESTDIR)$(PCLIBDIR)'
+       sed -e 
's|@LIBDIR@|$(LIBDIR)|;s|@INCLUDEDIR@|$(INCLUDEDIR)|;s|@VERSION@|$(VERSION)|' \
+           -e 's|=$(PREFIX)|=$${prefix}|' \
+-- 
+2.42.0
+

diff --git a/dev-libs/tree-sitter/tree-sitter-0.20.8-r1.ebuild 
b/dev-libs/tree-sitter/tree-sitter-0.20.8-r1.ebuild
new file mode 100644
index 000000000000..734e7a2a9491
--- /dev/null
+++ b/dev-libs/tree-sitter/tree-sitter-0.20.8-r1.ebuild
@@ -0,0 +1,54 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+inherit optfeature toolchain-funcs
+
+DESCRIPTION="Tree-sitter is a parser generator tool and an incremental parsing 
library"
+HOMEPAGE="https://github.com/tree-sitter/tree-sitter";
+
+if [[ ${PV} == *9999* ]]; then
+       inherit git-r3
+       EGIT_REPO_URI="https://github.com/${PN}/${PN}";
+else
+       SRC_URI="https://github.com/${PN}/${PN}/archive/refs/tags/v${PV}.tar.gz 
-> ${P}.tar.gz"
+       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~ppc ~ppc64 
~riscv ~s390 ~sparc ~x86 ~x64-macos"
+fi
+
+LICENSE="MIT"
+SLOT="0"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-No-static-libs-gentoo.patch"
+       "${FILESDIR}/${PN}-0.20.8-no-parser-header.patch"
+)
+
+# see Makefile:1
+QA_PKGCONFIG_VERSION="0.20.9"
+
+# XXX: Please, don't forget to check this on next version bump.
+# And, maybe remove as non-needed, if version in Makefile will
+# match the release.
+# ref: https://github.com/tree-sitter/tree-sitter/issues/2210
+
+src_prepare() {
+       default
+       tc-export CC
+}
+
+src_compile() {
+       emake \
+               PREFIX="${EPREFIX}/usr" \
+               LIBDIR="${EPREFIX}/usr/$(get_libdir)"
+}
+
+src_install() {
+       emake DESTDIR="${D}" \
+               PREFIX="${EPREFIX}/usr" \
+               LIBDIR="${EPREFIX}/usr/$(get_libdir)" \
+               install
+}
+
+pkg_postinst() {
+       optfeature "building and testing grammars" dev-util/tree-sitter-cli
+}

Reply via email to