mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
build-system/tree-sitter: Switch to (json).
* guix/build/tree-sitter-build-system.scm (patch-dependencies, install): Switch from (guix build json) to (json). Signed-off-by: Jelle Licht <jlicht@fsfe.org> Change-Id: I8de71c74475514c932e84303a20f0409419e8527
This commit is contained in:
parent
93d4d16375
commit
c48019577c
1 changed files with 20 additions and 24 deletions
|
@ -18,10 +18,10 @@
|
||||||
|
|
||||||
(define-module (guix build tree-sitter-build-system)
|
(define-module (guix build tree-sitter-build-system)
|
||||||
#:use-module ((guix build node-build-system) #:prefix node:)
|
#:use-module ((guix build node-build-system) #:prefix node:)
|
||||||
#:use-module (guix build json)
|
|
||||||
#:use-module (guix build utils)
|
#:use-module (guix build utils)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 regex)
|
#:use-module (ice-9 regex)
|
||||||
|
#:use-module (json)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:export (%standard-phases
|
#:export (%standard-phases
|
||||||
tree-sitter-build))
|
tree-sitter-build))
|
||||||
|
@ -47,28 +47,24 @@
|
||||||
"Rewrite dependencies in 'package.json'. We remove all runtime dependencies
|
"Rewrite dependencies in 'package.json'. We remove all runtime dependencies
|
||||||
and replace development dependencies with tree-sitter grammar node modules."
|
and replace development dependencies with tree-sitter grammar node modules."
|
||||||
|
|
||||||
(define (rewrite package.json)
|
(node:with-atomic-json-file-replacement
|
||||||
(map (match-lambda
|
(lambda (pkg-meta-alist)
|
||||||
(("dependencies" @ . _)
|
(map (match-lambda
|
||||||
'("dependencies" @))
|
(("dependencies" dependencies ...)
|
||||||
(("devDependencies" @ . _)
|
'("dependencies"))
|
||||||
`("devDependencies" @
|
(("devDependencies" dev-dependencies ...)
|
||||||
,@(filter-map (match-lambda
|
`("devDependencies"
|
||||||
((key . directory)
|
,@(filter-map (match-lambda
|
||||||
(let ((node-module
|
((key . directory)
|
||||||
(string-append directory
|
(let ((node-module
|
||||||
"/lib/node_modules/"
|
(string-append directory
|
||||||
key)))
|
"/lib/node_modules/"
|
||||||
(and (directory-exists? node-module)
|
key)))
|
||||||
`(,key . ,node-module)))))
|
(and (directory-exists? node-module)
|
||||||
(alist-delete "node" inputs))))
|
`(,key . ,node-module)))))
|
||||||
(other other))
|
(alist-delete "node" inputs))))
|
||||||
package.json))
|
(other other))
|
||||||
|
pkg-meta-alist))))
|
||||||
(node:with-atomic-json-file-replacement "package.json"
|
|
||||||
(match-lambda
|
|
||||||
(('@ . package.json)
|
|
||||||
(cons '@ (rewrite package.json))))))
|
|
||||||
|
|
||||||
;; FIXME: The node build-system's configure phase does not support
|
;; FIXME: The node build-system's configure phase does not support
|
||||||
;; cross-compiling so we re-define it.
|
;; cross-compiling so we re-define it.
|
||||||
|
@ -99,7 +95,7 @@ and replace development dependencies with tree-sitter grammar node modules."
|
||||||
(define (compile-language dir)
|
(define (compile-language dir)
|
||||||
(with-directory-excursion dir
|
(with-directory-excursion dir
|
||||||
(let ((lang (assoc-ref (call-with-input-file "src/grammar.json"
|
(let ((lang (assoc-ref (call-with-input-file "src/grammar.json"
|
||||||
read-json)
|
json->scm)
|
||||||
"name"))
|
"name"))
|
||||||
(source-file (lambda (path)
|
(source-file (lambda (path)
|
||||||
(if (file-exists? path)
|
(if (file-exists? path)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue