commit:     10f4218cb62f02b5ecfcaa97a877dc81f06cd944
Author:     Steffen Winter <steffen.winter <AT> proton <DOT> me>
AuthorDate: Wed Jul 17 13:05:18 2024 +0000
Commit:     Joonas Niilola <juippis <AT> gentoo <DOT> org>
CommitDate: Tue Jul 23 05:26:49 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=10f4218c

app-editors/helix: re-add grammar USE flag

This also patches two tree-sitter parsers which wouldn't built with
the newer stricter compilers regarding C11.

Closes: https://bugs.gentoo.org/901107
Closes: https://bugs.gentoo.org/912050
Closes: https://bugs.gentoo.org/918941
Closes: https://bugs.gentoo.org/933727
Closes: https://bugs.gentoo.org/934041

Signed-off-by: Steffen Winter <steffen.winter <AT> proton.me>
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>

 .../helix-23.10-tree-sitter-d-gnu-extension.patch  | 65 ++++++++++++++++++++++
 ...x-23.10-tree-sitter-rescript-implicit-int.patch | 38 +++++++++++++
 ...helix-23.10-r2.ebuild => helix-23.10-r3.ebuild} | 28 +++++++---
 .../{helix-24.03.ebuild => helix-24.03-r1.ebuild}  | 26 ++++++---
 app-editors/helix/metadata.xml                     |  3 +
 5 files changed, 142 insertions(+), 18 deletions(-)

diff --git 
a/app-editors/helix/files/helix-23.10-tree-sitter-d-gnu-extension.patch 
b/app-editors/helix/files/helix-23.10-tree-sitter-d-gnu-extension.patch
new file mode 100644
index 000000000000..b1789a9df944
--- /dev/null
+++ b/app-editors/helix/files/helix-23.10-tree-sitter-d-gnu-extension.patch
@@ -0,0 +1,65 @@
+From 394998798ef15175455a29cc239999e61ff78e6f Mon Sep 17 00:00:00 2001
+From: Michal Rostecki <vadorov...@protonmail.com>
+Date: Wed, 6 Dec 2023 15:24:34 +0000
+Bug: https://bugs.gentoo.org/912050
+Subject: [PATCH] chore: Update tree-sitter-d
+
+One of the included changes is gdamore/tree-sitter-d#22 which
+fixes the build of Helix when using clang as `CC`.
+---
+ languages.toml | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/languages.toml b/languages.toml
+index 66b43472f5a3..7f1c6b769fad 100644
+--- a/languages.toml
++++ b/languages.toml
+@@ -2220,7 +2220,7 @@ formatter = { command = "dfmt" }
+ 
+ [[grammar]]
+ name = "d"
+-source = { git = "https://github.com/gdamore/tree-sitter-d";, 
rev="601c4a1e8310fb2f3c43fa8a923d0d27497f3c04" }
++source = { git = "https://github.com/gdamore/tree-sitter-d";, rev = 
"5566f8ce8fc24186fad06170bbb3c8d97c935d74" }
+ 
+ [[language]]
+ name = "vhs"
+diff --git a/runtime/grammars/sources/d/src/scanner.c 
b/runtime/grammars/sources/d/src/scanner.c
+index 6753ba0..2061b02 100644
+--- a/runtime/grammars/sources/d/src/scanner.c
++++ b/runtime/grammars/sources/d/src/scanner.c
+@@ -67,7 +67,7 @@ match_escape(TSLexer *lexer)
+       case 'x':
+               for (int i = 0; i < 2; i++) { // expect two hex digits
+                       lexer->advance(lexer, false);
+-                      if (!isascii(lexer->lookahead) ||
++                      if (!(lexer->lookahead >= 0 && lexer->lookahead <= 127) 
||
+                           !isxdigit(lexer->lookahead)) {
+                               return (false);
+                       }
+@@ -78,7 +78,7 @@ match_escape(TSLexer *lexer)
+       case 'u':
+               for (int i = 0; i < 4; i++) {
+                       lexer->advance(lexer, false);
+-                      if (!isascii(lexer->lookahead) ||
++                      if (!(lexer->lookahead >= 0 && lexer->lookahead <= 127) 
||
+                           !isxdigit(lexer->lookahead)) {
+                               return (false);
+                       }
+@@ -89,7 +89,7 @@ match_escape(TSLexer *lexer)
+       case 'U':
+               for (int i = 0; i < 8; i++) {
+                       lexer->advance(lexer, false);
+-                      if (!isascii(lexer->lookahead) ||
++                      if (!(lexer->lookahead >= 0 && lexer->lookahead <= 127) 
||
+                           !isxdigit(lexer->lookahead)) {
+                               return (false);
+                       }
+@@ -123,7 +123,7 @@ match_escape(TSLexer *lexer)
+                               }
+                               break;
+                       }
+-                      if (!isascii(lexer->lookahead) ||
++                      if (!(lexer->lookahead >= 0 && lexer->lookahead <= 127) 
||
+                           !isalnum(lexer->lookahead)) {
+                               return (false);
+                       }

diff --git 
a/app-editors/helix/files/helix-23.10-tree-sitter-rescript-implicit-int.patch 
b/app-editors/helix/files/helix-23.10-tree-sitter-rescript-implicit-int.patch
new file mode 100644
index 000000000000..fd7ef56d2799
--- /dev/null
+++ 
b/app-editors/helix/files/helix-23.10-tree-sitter-rescript-implicit-int.patch
@@ -0,0 +1,38 @@
+From 17918a99bcf1bf39b08c09e0690d2ecccda8088d Mon Sep 17 00:00:00 2001
+From: Nan Zhong <m...@nanzho.ng>
+Date: Thu, 30 Nov 2023 22:35:49 -0500
+Bug: https://bugs.gentoo.org/912050
+Bug: https://bugs.gentoo.org/918941
+Subject: [PATCH] languages: update rescript grammar
+
+This bump fixes a build failure of the grammer with clang.
+---
+ languages.toml | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/languages.toml b/languages.toml
+index 10ed167b028d..f4ff483b2b11 100644
+--- a/languages.toml
++++ b/languages.toml
+@@ -1523,7 +1523,7 @@ indent = { tab-width = 2, unit = "  " }
+ 
+ [[grammar]]
+ name = "rescript"
+-source = { git = "https://github.com/jaredramirez/tree-sitter-rescript";, rev 
= "65609807c628477f3b94052e7ef895885ac51c3c" }
++source = { git = "https://github.com/jaredramirez/tree-sitter-rescript";, rev 
= "467dcf99f68c47823d7b378779a6b282d7ef9782" }
+ 
+ [[language]]
+ name = "erlang"
+diff --git a/runtime/grammars/sources/rescript/src/scanner.c 
b/runtime/grammars/sources/rescript/src/scanner.c
+index 9bf9fa4..113ca35 100644
+--- a/runtime/grammars/sources/rescript/src/scanner.c
++++ b/runtime/grammars/sources/rescript/src/scanner.c
+@@ -131,7 +131,7 @@ bool tree_sitter_rescript_external_scanner_scan(
+     const bool* valid_symbols
+     ) {
+   ScannerState* state = (ScannerState*)payload;
+-  const in_string = state->in_quotes || state->in_backticks;
++  const bool in_string = state->in_quotes || state->in_backticks;
+ 
+   if (valid_symbols[TEMPLATE_CHARS]) {
+     lexer->result_symbol = TEMPLATE_CHARS;

diff --git a/app-editors/helix/helix-23.10-r2.ebuild 
b/app-editors/helix/helix-23.10-r3.ebuild
similarity index 91%
rename from app-editors/helix/helix-23.10-r2.ebuild
rename to app-editors/helix/helix-23.10-r3.ebuild
index 2ee1d5fb78d8..cce301b3bf47 100644
--- a/app-editors/helix/helix-23.10-r2.ebuild
+++ b/app-editors/helix/helix-23.10-r3.ebuild
@@ -277,11 +277,13 @@ S="${WORKDIR}"
 LICENSE="0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD Boost-1.0 ISC MIT 
MPL-2.0 Unicode-DFS-2016 Unlicense ZLIB"
 SLOT="0"
 KEYWORDS="amd64"
+IUSE="+grammar"
 
 RDEPEND="dev-vcs/git"
 
 QA_FLAGS_IGNORED="
        usr/bin/hx
+       usr/share/helix/runtime/grammars/.*\.so
 "
 
 DOCS=(
@@ -292,11 +294,13 @@ DOCS=(
 )
 
 PATCHES=(
+       "${FILESDIR}/helix-23.10-tree-sitter-d-gnu-extension.patch"
        "${FILESDIR}/helix-23.10-tree-sitter-gemini-path.patch"
+       "${FILESDIR}/helix-23.10-tree-sitter-rescript-implicit-int.patch"
 )
 
 src_compile() {
-       local -x HELIX_DISABLE_AUTO_GRAMMAR_BUILD=1
+       use grammar || local -x HELIX_DISABLE_AUTO_GRAMMAR_BUILD=1
 
        cargo_src_compile
 }
@@ -304,10 +308,12 @@ src_compile() {
 src_install() {
        cargo_src_install --path helix-term
 
-       insinto /usr/share/helix/runtime
-       doins -r runtime/{queries,themes,tutor}
+       rm runtime/grammars/.gitkeep || die
+       rm -r runtime/grammars/sources || die
+       use grammar || rm -r runtime/grammars || die
 
        insinto /usr/share/helix
+       doins -r runtime
        dodoc -r "${DOCS[@]}"
 
        doicon -s 256x256 contrib/${PN}.png
@@ -324,16 +330,20 @@ src_install() {
 }
 
 pkg_postinst() {
-       einfo "The runtime files (queries, themes) have been"
+       einfo "The runtime files have been"
        einfo "installed in '/usr/share/helix/runtime'. The environment 
variable"
        einfo "HELIX_RUNTIME was also installed on your system. In running 
shell instances"
        einfo "you need to run 'source /etc/profile' to pick up the new 
variable"
        einfo "or manually set the environment variable 
HELIX_RUNTIME=/usr/share/helix/runtime."
-       einfo ""
-       einfo "Grammars are not installed yet. To fetch and install them, run:"
-       einfo ""
-       einfo "  hx --grammar fetch"
-       einfo "  hx --grammar build"
+
+       if ! use grammar ; then
+               einfo ""
+               einfo "Grammars are not installed yet. To fetch and install 
them, run:"
+               einfo ""
+               einfo "  hx --grammar fetch"
+               einfo "  hx --grammar build"
+       fi
+
        xdg_desktop_database_update
        xdg_icon_cache_update
 }

diff --git a/app-editors/helix/helix-24.03.ebuild 
b/app-editors/helix/helix-24.03-r1.ebuild
similarity index 93%
rename from app-editors/helix/helix-24.03.ebuild
rename to app-editors/helix/helix-24.03-r1.ebuild
index ddaf7570d53e..7ac23280faec 100644
--- a/app-editors/helix/helix-24.03.ebuild
+++ b/app-editors/helix/helix-24.03-r1.ebuild
@@ -290,11 +290,13 @@ S="${WORKDIR}"
 LICENSE="0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD Boost-1.0 ISC MIT 
MPL-2.0 Unicode-DFS-2016 Unlicense ZLIB"
 SLOT="0"
 KEYWORDS="amd64"
+IUSE="+grammar"
 
 RDEPEND="dev-vcs/git"
 
 QA_FLAGS_IGNORED="
        usr/bin/hx
+       usr/share/helix/runtime/grammars/.*\.so
 "
 
 DOCS=(
@@ -305,7 +307,7 @@ DOCS=(
 )
 
 src_compile() {
-       local -x HELIX_DISABLE_AUTO_GRAMMAR_BUILD=1
+       use grammar || local -x HELIX_DISABLE_AUTO_GRAMMAR_BUILD=1
 
        cargo_src_compile
 }
@@ -313,10 +315,12 @@ src_compile() {
 src_install() {
        cargo_src_install --path helix-term
 
-       insinto /usr/share/helix/runtime
-       doins -r runtime/{queries,themes,tutor}
+       rm runtime/grammars/.gitkeep || die
+       rm -r runtime/grammars/sources || die
+       use grammar || rm -r runtime/grammars || die
 
        insinto /usr/share/helix
+       doins -r runtime
        dodoc -r "${DOCS[@]}"
 
        doicon -s 256x256 contrib/${PN}.png
@@ -333,16 +337,20 @@ src_install() {
 }
 
 pkg_postinst() {
-       einfo "The runtime files (queries, themes) have been"
+       einfo "The runtime files have been"
        einfo "installed in '/usr/share/helix/runtime'. The environment 
variable"
        einfo "HELIX_RUNTIME was also installed on your system. In running 
shell instances"
        einfo "you need to run 'source /etc/profile' to pick up the new 
variable"
        einfo "or manually set the environment variable 
HELIX_RUNTIME=/usr/share/helix/runtime."
-       einfo ""
-       einfo "Grammars are not installed yet. To fetch and install them, run:"
-       einfo ""
-       einfo "  hx --grammar fetch"
-       einfo "  hx --grammar build"
+
+       if ! use grammar ; then
+               einfo ""
+               einfo "Grammars are not installed yet. To fetch and install 
them, run:"
+               einfo ""
+               einfo "  hx --grammar fetch"
+               einfo "  hx --grammar build"
+       fi
+
        xdg_desktop_database_update
        xdg_icon_cache_update
 }

diff --git a/app-editors/helix/metadata.xml b/app-editors/helix/metadata.xml
index f699ef0c9568..07edb24ed94b 100644
--- a/app-editors/helix/metadata.xml
+++ b/app-editors/helix/metadata.xml
@@ -13,6 +13,9 @@
                <email>proxy-ma...@gentoo.org</email>
                <name>Proxy Maintainers</name>
        </maintainer>
+       <use>
+               <flag name="grammar">Build and install grammar language 
files</flag>
+       </use>
        <upstream>
                <bugs-to>https://github.com/helix-editor/helix/issues</bugs-to>
                
<changelog>https://github.com/helix-editor/helix/commits/master</changelog>

Reply via email to