Skip to content

Commit 41acbdd

Browse files
authored
Merge pull request #73 from emacs-tree-sitter/platform-specific-binaries
Make grammar installation download platform-specific binaries
2 parents 4ac2400 + 04a12c9 commit 41acbdd

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Unreleased
4+
- Made `tree-sitter-langs-install-grammars` download platform-specific binaries (mainly for Apple Silicon).
45

56
## 0.10.15 - 2022-01-27
67
- Added `haskell` grammar.

tree-sitter-langs-build.el

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,21 @@ infrequent (grammar-only changes). It is different from the version of
252252
"Return the grammar bundle file's name, with optional EXT.
253253
If VERSION and OS are not spcified, use the defaults of
254254
`tree-sitter-langs--bundle-version' and `tree-sitter-langs--os'."
255-
(format "tree-sitter-grammars-%s-%s.tar%s"
256-
(or os tree-sitter-langs--os)
257-
(or version tree-sitter-langs--bundle-version)
258-
(or ext "")))
255+
(setq version (or version tree-sitter-langs--bundle-version))
256+
(setq os (or os tree-sitter-langs--os))
257+
(setq ext (or ext ""))
258+
(if (version<= "0.10.13" version)
259+
(format "tree-sitter-grammars.%s.v%s.tar%s"
260+
;; FIX: Implement this correctly, refactoring 'OS' -> 'platform'.
261+
(pcase os
262+
("windows" "x86_64-pc-windows-msvc")
263+
("linux" "x86_64-unknown-linux-gnu")
264+
("macos" (if (string-prefix-p "aarch64" system-configuration)
265+
"aarch64-apple-darwin"
266+
"x86_64-apple-darwin")))
267+
version ext)
268+
(format "tree-sitter-grammars-%s-%s.tar%s"
269+
os version ext)))
259270

260271
(defun tree-sitter-langs-compile (lang-symbol &optional clean target)
261272
"Download and compile the grammar for LANG-SYMBOL.

0 commit comments

Comments
 (0)