[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#49946] [PATCH 29/31] gnu: Add emacs-tree-sitter-core.
From: |
Pierre Langlois |
Subject: |
[bug#49946] [PATCH 29/31] gnu: Add emacs-tree-sitter-core. |
Date: |
Mon, 9 Aug 2021 00:43:56 +0100 |
* gnu/packages/tree-sitter.scm (tree-sitter-emacs-module): New local variable.
(emacs-tree-sitter-core): New variable.
---
gnu/packages/tree-sitter.scm | 79 ++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 4817b293ce..a9c1714936 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -19,6 +19,7 @@
(define-module (gnu packages tree-sitter)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cargo)
+ #:use-module (guix build-system emacs)
#:use-module (guix build-system node)
#:use-module (guix download)
#:use-module (guix git-download)
@@ -27,6 +28,7 @@
#:use-module (gnu packages algebra)
#:use-module (gnu packages crates-io)
#:use-module (gnu packages crates-graphics)
+ #:use-module (gnu packages llvm)
#:use-module (gnu packages node-xyz))
(define-public tree-sitter
@@ -529,3 +531,80 @@ library.")
"This package provides Typescript and TSX grammars for the Tree-sitter
library.")
(license license:expat)))
+
+;; Local package definition solely for building the native emacs module
+;; written in Rust.
+(define tree-sitter-emacs-module
+ (package
+ (name "tree-sitter-emacs-module")
+ (version "0.15.1")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url
"https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "15y0wjnck8rbfhl0xrl71ci7clbcp11lhqil5l8ykprsdjv0c2as"))))
+ (build-system cargo-build-system)
+ (inputs
+ `(("clang" ,clang)))
+ (arguments
+ `(#:cargo-inputs
+ (("rust-anyhow" ,rust-anyhow-1)
+ ("rust-emacs" ,rust-emacs-0.17)
+ ("rust-libloading" ,rust-libloading-0.7)
+ ("rust-once-cell" ,rust-once-cell-1)
+ ("rust-tree-sitter" ,rust-tree-sitter-0.19))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'delete-cargo.lock
+ (lambda _ (delete-file "Cargo.lock")))
+ (add-after 'delete-cargo.lock 'do-not-fetch-from-github
+ (lambda _
+ (substitute* "Cargo.toml"
+ (("\\[patch.*") "")
+ (("git = .*") ""))))
+ (add-after 'do-not-fetch-from-github 'chdir
+ (lambda _ (chdir "core")))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((lib (string-append (assoc-ref outputs "out") "/lib")))
+ (install-file "../target/release/libtsc_dyn.so" lib)))))))
+ (home-page #f)
+ (synopsis #f)
+ (description #f)
+ (license license:expat)))
+
+(define-public emacs-tree-sitter-core
+ (package
+ (name "emacs-tree-sitter-core")
+ (version (package-version tree-sitter-emacs-module))
+ (source (package-source tree-sitter-emacs-module))
+ (build-system emacs-build-system)
+ (native-inputs
+ `(("tree-sitter-emacs-module" ,tree-sitter-emacs-module)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _ (chdir "core")))
+ (add-after 'install 'install-module
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((elpa (elpa-directory (assoc-ref outputs "out")))
+ (module (string-append (assoc-ref inputs
"tree-sitter-emacs-module")
+ "/lib/libtsc_dyn.so")))
+ ;; Writing "LOCAL" in this file prevents the package from
+ ;; trying to download the module from the internet.
+ (call-with-output-file (string-append elpa "/DYN-VERSION")
+ (lambda (port) (display "LOCAL" port)))
+ (substitute* "tsc-dyn-get.el"
+ (("defcustom tsc-dyn-dir tsc--dir")
+ (string-append "defcustom tsc-dyn-dir \"" elpa "\"")))
+ (copy-file module (string-append elpa "/tsc-dyn.so"))))))))
+ (home-page "https://github.com/emacs-tree-sitter/elisp-tree-sitter")
+ (synopsis "Tree-sitter bindings for Emacs Lisp, core library")
+ (description "This package provides core APIs of the Emacs binding for
+Tree-sitter, an incremental parsing system.")
+ (license license:expat)))
--
2.32.0
- [bug#49946] [PATCH 19/31] gnu: Add tree-sitter-julia., (continued)
- [bug#49946] [PATCH 19/31] gnu: Add tree-sitter-julia., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 20/31] gnu: Add tree-sitter-php., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 21/31] gnu: Add tree-sitter-python., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 22/31] gnu: Add tree-sitter-rust., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 23/31] gnu: Add tree-sitter-typescript., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 27/31] gnu: rust-emacs-macros: Update to 0.17., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 28/31] gnu: rust-emacs: Update to 0.17., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 25/31] gnu: Add rust-tree-sitter., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 26/31] gnu: rust-emacs-module: Update to 0.16., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 24/31] gnu: Add rust-bindgen@0.56., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 29/31] gnu: Add emacs-tree-sitter-core.,
Pierre Langlois <=
- [bug#49946] [PATCH 30/31] gnu: Add emacs-tree-sitter., Pierre Langlois, 2021/08/08
- [bug#49946] [PATCH 31/31] gnu: Add emacs-tree-sitter-langs., Pierre Langlois, 2021/08/08