Subject: [bug#49946] [PATCH v6 04/27] gnu: Add tree-sitter-c.

From: Pierre Langlois <[email-masked]>
Date: Sun, 15 May 2022 19:38:11 +0100

* gnu/packages/tree-sitter.scm (tree-sitter-c): New variable.
---
 gnu/packages/tree-sitter.scm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
index 18c9fe0844..3f07b2d91c 100644
--- a/gnu/packages/tree-sitter.scm
+++ b/gnu/packages/tree-sitter.scm
@@ -22,6 +22,7 @@ (define-module (gnu packages tree-sitter)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system cargo)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system tree-sitter)
   #:use-module (guix git-download)
   #:use-module (guix packages)
   #:use-module (guix utils)
@@ -155,3 +156,35 @@ (define-public tree-sitter-cli

 This package includes the @command{tree-sitter} command-line tool.")
     (license license:expat)))
+
+(define tree-sitter-delete-generated-files
+  '(begin
+     (delete-file "binding.gyp")
+     (delete-file-recursively "bindings")
+     (delete-file "src/grammar.json")
+     (delete-file "src/node-types.json")
+     (delete-file "src/parser.c")
+     (delete-file-recursively "src/tree_sitter")
+     #t))
+
+(define-public tree-sitter-c
+  (package
+    (name "tree-sitter-c")
+    (version "0.20.1")
+    (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
+                "0454jziys33i4kbwnvi9xcck0fzya792ghy32ahgk1hhv96xga9w"))
+              (modules '((guix build utils)))
+              (snippet tree-sitter-delete-generated-files)))
+    (build-system tree-sitter-build-system)
+    (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.36.0