[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#49946] [PATCH v2 12/33] gnu: Add tree-sitter-c.
From: |
Pierre Langlois |
Subject: |
[bug#49946] [PATCH v2 12/33] gnu: Add tree-sitter-c. |
Date: |
Sun, 29 Aug 2021 11:45:47 +0100 |
* gnu/packages/tree-sitter.scm (tree-sitter-c): New variable.
---
gnu/packages/tree-sitter.scm | 63 +++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index d8d4a305da..bc04a4a5a7 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -20,11 +20,13 @@
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cargo)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system node)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (gnu packages crates-graphics)
- #:use-module (gnu packages crates-io))
+ #:use-module (gnu packages crates-io)
+ #:use-module (gnu packages node-xyz))
(define-public tree-sitter
(package
@@ -130,3 +132,62 @@ can be embedded in any application.
This package includes the @command{tree-sitter} command-line tool.")
(license license:expat)))
+
+(define-public tree-sitter-c
+ (package
+ (name "tree-sitter-c")
+ (version "0.19.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tree-sitter/tree-sitter-c")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1diys8yigvhm4ppbmp3a473yxjg2d5lk11y0ay7qprcz7233lakv"))))
+ (build-system node-build-system)
+ (native-inputs
+ `(("tree-sitter-cli" ,tree-sitter-cli)
+ ("node-nan" ,node-nan)))
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ ;; tree-sitter-cli is listed as a Node.js dependency, however the
+ ;; node tree-sitter-cli package is just a wrapper which downloads a
+ ;; tree-sitter binary, see
+ ;; https://github.com/tree-sitter/tree-sitter/tree/master/cli/npm
+ ;; Instead we remove it as a dependency so that we can use our own
+ ;; tree-sitter package.
+ (add-after 'unpack 'fix-configure
+ (lambda _
+ (with-atomic-file-replacement "package.json"
+ (lambda (in out)
+ (use-modules ((guix build json)))
+ (let ((package-meta (read-json in)))
+ (assoc-remove! (assoc-ref package-meta "devDependencies")
+ "tree-sitter-cli")
+ (write-json package-meta out))))))
+ (add-before 'build 'set-cc
+ (lambda _
+ (setenv "CC" ,(cc-for-target))))
+ (add-before 'build 'make-files-writable
+ (lambda _
+ (for-each make-file-writable (find-files "src" ".*"))))
+ (add-after 'install 'install-native-lib
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((lib (string-append (assoc-ref outputs "out")
+ "/lib/tree-sitter")))
+ ;; Invoking `tree-sitter test' loads the grammar which
+ ;; compiles it to a .so binary that we install.
+ (invoke "tree-sitter" "test")
+ (mkdir-p lib)
+ (copy-recursively (string-append (getenv "HOME")
+ "/.tree-sitter/bin")
+ lib)))))))
+ (home-page "https://github.com/tree-sitter/tree-sitter-c")
+ (synopsis "Tree-sitter C grammar")
+ (description
+ "This package provides a C grammar for the Tree-sitter library.")
+ (license license:expat)))
--
2.33.0
- [bug#49946] [PATCH v2 07/33] gnu: Add tree-sitter., (continued)
- [bug#49946] [PATCH v2 07/33] gnu: Add tree-sitter., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 27/33] gnu: Add rust-tree-sitter., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 02/33] gnu: Add rust-fdlimit., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 08/33] gnu: Add tree-sitter-cli., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 11/33] gnu: Add node-nan., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 09/33] gnu: node: Patch /usr/bin/env in node-gyp., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 05/33] gnu: rust-tiny-http: Update to 0.8., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 16/33] gnu: Add tree-sitter-go., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 17/33] gnu: Add tree-sitter-html., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 19/33] gnu: Add tree-sitter-javascript., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 12/33] gnu: Add tree-sitter-c.,
Pierre Langlois <=
- [bug#49946] [PATCH v2 28/33] gnu: rust-emacs-module: Update to 0.16., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 31/33] gnu: Add emacs-tree-sitter-core., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 25/33] gnu: Add tree-sitter-typescript., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 23/33] gnu: Add tree-sitter-python., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 22/33] gnu: Add tree-sitter-php., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 21/33] gnu: Add tree-sitter-julia., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 24/33] gnu: Add tree-sitter-rust., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 26/33] gnu: Add rust-bindgen@0.56., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 32/33] gnu: Add emacs-tree-sitter., Pierre Langlois, 2021/08/29
- [bug#49946] [PATCH v2 33/33] gnu: Add emacs-tree-sitter-langs., Pierre Langlois, 2021/08/29