-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use .dylib extension for the dynamic module on macOS, instead of .so
- Loading branch information
Showing
4 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
(require 'seq) | ||
|
||
;; XXX: Using `require' after setting`module-file-suffix' to `.dylib' results in "Cannot open load | ||
;; file: No such file or directory, tree-sitter-dyn". | ||
;; | ||
;; XXX: Using `load' results in an error message with garbled text: "Symbol’s value as variable is | ||
;; void: Ïúíþ". | ||
;; | ||
;; Therefore, we use `module-load' directly. | ||
(defun ts--try-load-dyn (name) | ||
(or (featurep 'tree-sitter-dyn) | ||
(condition-case _ | ||
(module-load name) | ||
(module-open-failed nil)))) | ||
|
||
(unwind-protect | ||
(let ((name "tree-sitter-dyn.dylib")) | ||
;; Try directory containing `load-file-name'. Typical case. | ||
(when load-file-name | ||
(ts--try-load-dyn (concat (file-name-directory load-file-name) | ||
name))) | ||
;; Try working directory (e.g. when invoked by `cask'). | ||
(ts--try-load-dyn name) | ||
;; Fall back to `load-path'. | ||
(seq-find (lambda (dir) | ||
(let ((full-name (concat (file-name-as-directory | ||
(expand-file-name dir)) | ||
name))) | ||
(ts--try-load-dyn full-name))) | ||
load-path)) | ||
(fmakunbound 'ts--try-load-dyn)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters