mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
gnu: Add tree-sitter-grammar-html.
* gnu/packages/crates-io.scm (tree-sitter-grammar): New variable. (tree-sitter-grammar-html): New variable.
This commit is contained in:
parent
0cd9bd5dce
commit
53b00b91b7
1 changed files with 61 additions and 0 deletions
|
@ -1,6 +1,9 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2022 Luis Henrique Gomes Higino <luishenriquegh2701@gmail.com>
|
||||
;;; Copyright © 2022 Pierre Langlois <pierre.langlois@gmx.com>
|
||||
;;; Copyright © 2022 muradm <mail@muradm.net>
|
||||
;;; Copyright © 2022 Aleksandr Vityazev <avityazev@posteo.org>
|
||||
;;; Copyright © 2023 Andrew Tropin <andrew@trop.in>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
|
@ -151,3 +154,61 @@ (define-public tree-sitter-cli
|
|||
|
||||
This package includes the @command{tree-sitter} command-line tool.")
|
||||
(license license:expat)))
|
||||
|
||||
(define* (tree-sitter-grammar
|
||||
language language-for-synopsis version commit hash
|
||||
#:key
|
||||
(repository-url
|
||||
(format #f "https://github.com/tree-sitter/tree-sitter-~a" language))
|
||||
(source-directory ""))
|
||||
(let ((synopsis (string-append language-for-synopsis
|
||||
" grammar for tree-sitter"))
|
||||
(name (string-append "tree-sitter-grammar-" language))
|
||||
(src-dir source-directory)
|
||||
(lib (format #f "libtree-sitter-~a.so" language)))
|
||||
(package
|
||||
(name name)
|
||||
(version version)
|
||||
(home-page repository-url)
|
||||
(source (origin
|
||||
(method git-fetch)
|
||||
(uri (git-reference
|
||||
(url repository-url)
|
||||
(commit commit)))
|
||||
(file-name (git-file-name name version))
|
||||
(sha256 (base32 hash))))
|
||||
(build-system gnu-build-system)
|
||||
(arguments
|
||||
(list
|
||||
#:phases
|
||||
#~(modify-phases %standard-phases
|
||||
(delete 'configure)
|
||||
(replace 'build
|
||||
(lambda _
|
||||
(with-directory-excursion (string-append #$src-dir "src")
|
||||
(let* ((scanner? (or (file-exists? "scanner.c")
|
||||
(file-exists? "scanner.cc")))
|
||||
(CC (if (file-exists? "scanner.cc") "g++" "gcc"))
|
||||
(compile (lambda (f) (invoke CC "-fPIC" "-c" "-I." f)))
|
||||
(link-args `("-fPIC" "-shared" "parser.o"
|
||||
,@(if scanner? '("scanner.o") '())
|
||||
"-o" ,#$lib)))
|
||||
(invoke "gcc" "-fPIC" "-c" "-I." "parser.c")
|
||||
(for-each
|
||||
(lambda (f) (when (file-exists? f) (compile f)))
|
||||
'("scanner.c" "scanner.cc"))
|
||||
(apply invoke CC link-args)))))
|
||||
(delete 'check)
|
||||
(replace 'install
|
||||
(lambda _
|
||||
(install-file (string-append #$src-dir "src/" #$lib)
|
||||
(string-append #$output "/lib/tree-sitter")))))))
|
||||
(synopsis synopsis)
|
||||
(description (string-append synopsis "."))
|
||||
(license license:expat))))
|
||||
|
||||
(define-public tree-sitter-grammar-html
|
||||
(tree-sitter-grammar
|
||||
"html" "HTML"
|
||||
"0.19.0" "v0.19.0"
|
||||
"1hg7vbcy7bir6b8x11v0a4x0glvqnsqc3i2ixiarbxmycbgl3axy"))
|
||||
|
|
Loading…
Reference in a new issue