1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-08 15:35:02 +00:00

Future-proof loading tree-sitter library on MS-Windows

* src/treesit.c (syms_of_treesit) <tree-sitter--library-abi>: New
internal variable.

* lisp/term/w32-win.el (dynamic-library-alist): Use
'tree-sitter--library-abi' to select a proper libtree-sitter DLL
version.
This commit is contained in:
Eli Zaretskii 2024-11-21 14:55:38 +02:00
parent 3eb3018682
commit 83fc3cf53a
2 changed files with 23 additions and 2 deletions

View File

@ -290,8 +290,18 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
'(lcms2 "liblcms2-2.dll")
'(gccjit "libgccjit-0.dll")
;; MSYS2 distributes libtree-sitter.dll, without API version
;; number...
'(tree-sitter "libtree-sitter.dll" "libtree-sitter-0.dll")))
;; number, upto and including version 0.24.3-2; later versions
;; come with libtree-sitter-major.minor.dll (as in
;; libtree-sitter-0.24.dll). Sadly, the header files don't have
;; any symbols for library version, so we can only use the
;; library-language ABI version; according to
;; https://github.com/tree-sitter/tree-sitter/issues/3925, the
;; language ABI must change when the library's ABI is modified.
(if (<= tree-sitter--library-abi 14)
'(tree-sitter "libtree-sitter-0.24.dll"
"libtree-sitter.dll"
"libtree-sitter-0.dll")
'(tree-sitter "libtree-sitter-0.25.dll"))))
;;; multi-tty support
(defvar w32-initialized nil

View File

@ -4371,4 +4371,15 @@ the symbol of that THING. For example, (or sexp sentence). */);
defsubr (&Streesit_subtree_stat);
#endif /* HAVE_TREE_SITTER */
defsubr (&Streesit_available_p);
#ifdef WINDOWSNT
DEFSYM (Qtree_sitter__library_abi, "tree-sitter--library-abi");
Fset (Qtree_sitter__library_abi,
#if HAVE_TREE_SITTER
make_fixnum (TREE_SITTER_LANGUAGE_VERSION)
#else
make_fixnum (-1)
#endif
);
#endif
}