diff options
author | Andrew Tropin <andrew@trop.in> | 2023-02-09 17:34:05 +0400 |
---|---|---|
committer | Andrew Tropin <andrew@trop.in> | 2023-02-09 17:37:14 +0400 |
commit | 53b00b91b73bd60412d5bd057e22e6d63194a7f7 (patch) | |
tree | e29c398ce880548e9b31d3573ba696e55f87c8c6 /gnu/packages | |
parent | 0cd9bd5dce2b51a6d79a1a1a6fc70bfd787acbc7 (diff) |
gnu: Add tree-sitter-grammar-html.
* gnu/packages/crates-io.scm (tree-sitter-grammar): New variable.
(tree-sitter-grammar-html): New variable.
Diffstat (limited to 'gnu/packages')
-rw-r--r-- | gnu/packages/tree-sitter.scm | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index 4a5e082e5b..2e44339ca2 100644 --- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -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 @@ can be embedded in any application. 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")) |