diff options
| author | Eli Zaretskii | 2024-11-21 14:55:38 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2024-11-21 14:55:38 +0200 |
| commit | 83fc3cf53a4b54a4ec3bf464cfea97f74522cd8d (patch) | |
| tree | 46e58996d6c8aaf128dd493168d1d1c5004b5976 | |
| parent | 3eb3018682595208076fe7beea1175e123cf1966 (diff) | |
| download | emacs-83fc3cf53a4b54a4ec3bf464cfea97f74522cd8d.tar.gz emacs-83fc3cf53a4b54a4ec3bf464cfea97f74522cd8d.zip | |
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.
| -rw-r--r-- | lisp/term/w32-win.el | 14 | ||||
| -rw-r--r-- | src/treesit.c | 11 |
2 files changed, 23 insertions, 2 deletions
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el index 3c0acf368f4..2a59ec2460d 100644 --- a/lisp/term/w32-win.el +++ b/lisp/term/w32-win.el | |||
| @@ -290,8 +290,18 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") | |||
| 290 | '(lcms2 "liblcms2-2.dll") | 290 | '(lcms2 "liblcms2-2.dll") |
| 291 | '(gccjit "libgccjit-0.dll") | 291 | '(gccjit "libgccjit-0.dll") |
| 292 | ;; MSYS2 distributes libtree-sitter.dll, without API version | 292 | ;; MSYS2 distributes libtree-sitter.dll, without API version |
| 293 | ;; number... | 293 | ;; number, upto and including version 0.24.3-2; later versions |
| 294 | '(tree-sitter "libtree-sitter.dll" "libtree-sitter-0.dll"))) | 294 | ;; come with libtree-sitter-major.minor.dll (as in |
| 295 | ;; libtree-sitter-0.24.dll). Sadly, the header files don't have | ||
| 296 | ;; any symbols for library version, so we can only use the | ||
| 297 | ;; library-language ABI version; according to | ||
| 298 | ;; https://github.com/tree-sitter/tree-sitter/issues/3925, the | ||
| 299 | ;; language ABI must change when the library's ABI is modified. | ||
| 300 | (if (<= tree-sitter--library-abi 14) | ||
| 301 | '(tree-sitter "libtree-sitter-0.24.dll" | ||
| 302 | "libtree-sitter.dll" | ||
| 303 | "libtree-sitter-0.dll") | ||
| 304 | '(tree-sitter "libtree-sitter-0.25.dll")))) | ||
| 295 | 305 | ||
| 296 | ;;; multi-tty support | 306 | ;;; multi-tty support |
| 297 | (defvar w32-initialized nil | 307 | (defvar w32-initialized nil |
diff --git a/src/treesit.c b/src/treesit.c index 679b8fc7ddd..4031d80f7c9 100644 --- a/src/treesit.c +++ b/src/treesit.c | |||
| @@ -4371,4 +4371,15 @@ the symbol of that THING. For example, (or sexp sentence). */); | |||
| 4371 | defsubr (&Streesit_subtree_stat); | 4371 | defsubr (&Streesit_subtree_stat); |
| 4372 | #endif /* HAVE_TREE_SITTER */ | 4372 | #endif /* HAVE_TREE_SITTER */ |
| 4373 | defsubr (&Streesit_available_p); | 4373 | defsubr (&Streesit_available_p); |
| 4374 | #ifdef WINDOWSNT | ||
| 4375 | DEFSYM (Qtree_sitter__library_abi, "tree-sitter--library-abi"); | ||
| 4376 | Fset (Qtree_sitter__library_abi, | ||
| 4377 | #if HAVE_TREE_SITTER | ||
| 4378 | make_fixnum (TREE_SITTER_LANGUAGE_VERSION) | ||
| 4379 | #else | ||
| 4380 | make_fixnum (-1) | ||
| 4381 | #endif | ||
| 4382 | ); | ||
| 4383 | #endif | ||
| 4384 | |||
| 4374 | } | 4385 | } |