Subject: [bug#49946] [PATCH v7 07/32] gnu: Add tree-sitter-c.

From: Pierre Langlois <[email-masked]>
Date: Fri, 25 Nov 2022 01:21:17 +0000

* 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 30bf17b79b..4f75b0251a 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)
@@ -156,3 +157,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.2")
+    (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
+                "1w03r4l773ki4iq2xxsc2pqxf3pjsbybq3xq4glmnsihgylibn8v"))
+              (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.38.1