diff mbox series

[bug#49946,v7,28/32] gnu: Add rust-tree-sitter.

Message ID 20221125012142.22579-29-pierre.langlois@gmx.com
State New
Headers show
Series gnu: Add tree-sitter for emacs. | expand

Commit Message

Pierre Langlois Nov. 25, 2022, 1:21 a.m. UTC
* gnu/packages/tree-sitter.scm (rust-tree-sitter): New variable.
---
 gnu/packages/tree-sitter.scm | 38 ++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

Comments

\( Nov. 25, 2022, 7:11 a.m. UTC | #1
On Fri Nov 25, 2022 at 1:21 AM GMT, Pierre Langlois wrote:
> * gnu/packages/tree-sitter.scm (rust-tree-sitter): New variable.

> --- a/gnu/packages/tree-sitter.scm
> +++ b/gnu/packages/tree-sitter.scm

> @@ -158,6 +159,43 @@ (define-public tree-sitter-cli

> +               '(begin
> +                  ;; Remove the runtime library code and dynamically link to
> +                  ;; it instead.
> +                  (delete-file-recursively "src")
> +                  (delete-file "binding_rust/build.rs")
> +                  (with-output-to-file "binding_rust/build.rs"
> +                    (lambda _
> +                      (format #t "fn main() {~@
> +                              println!(\"cargo:rustc-link-lib=tree-sitter\");~@
> +                              }~%")))
> +                  #t))))

Maybe you should actually extract *this* snippet, as you also use
it with tree-sitter-cli?

> +    (arguments
> +     `(#:cargo-inputs
> +       (("rust-cc" ,rust-cc-1)
> +        ("rust-lazy-static" ,rust-lazy-static-1)
> +        ("rust-regex" ,rust-regex-1))))

(list ...) please.

    -- (
diff mbox series

Patch

diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 7cf9a41105..ca92fccfd6 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -23,6 +23,7 @@  (define-module (gnu packages tree-sitter)
   #:use-module (guix build-system cargo)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system tree-sitter)
+  #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix packages)
   #:use-module (guix utils)
@@ -158,6 +159,43 @@  (define-public tree-sitter-cli
 This package includes the @command{tree-sitter} command-line tool.")
     (license license:expat)))
 
+(define-public rust-tree-sitter
+  (package
+    (name "rust-tree-sitter")
+    (version "0.20.7")
+    (source (origin
+              (method url-fetch)
+              (uri (crate-uri "tree-sitter" version))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "183niy9malzr4dm81swcgl05xkwqamim6ck0gw5xb6k78nprz6jl"))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  ;; Remove the runtime library code and dynamically link to
+                  ;; it instead.
+                  (delete-file-recursively "src")
+                  (delete-file "binding_rust/build.rs")
+                  (with-output-to-file "binding_rust/build.rs"
+                    (lambda _
+                      (format #t "fn main() {~@
+                              println!(\"cargo:rustc-link-lib=tree-sitter\");~@
+                              }~%")))
+                  #t))))
+    (build-system cargo-build-system)
+    (inputs (list tree-sitter))
+    (arguments
+     `(#:cargo-inputs
+       (("rust-cc" ,rust-cc-1)
+        ("rust-lazy-static" ,rust-lazy-static-1)
+        ("rust-regex" ,rust-regex-1))))
+    (home-page "https://tree-sitter.github.io/tree-sitter/")
+    (synopsis "Rust bindings to the Tree-sitter parsing library")
+    (description "This package provides Rust bindings to the Tree-sitter
+parsing library.")
+    (license license:expat)))
+
 (define tree-sitter-delete-generated-files
   '(begin
      (delete-file "binding.gyp")