guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/03: Remove (guix json) and require Guile-JSON 4.3.0+.


From: guix-commits
Subject: 03/03: Remove (guix json) and require Guile-JSON 4.3.0+.
Date: Mon, 7 Sep 2020 18:54:22 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit b5eb901ab508e13a10d8c11fe0c9d0d06dddce96
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Sep 7 23:12:27 2020 +0200

    Remove (guix json) and require Guile-JSON 4.3.0+.
    
    This is a followup to 4071879c86d059ee087c8986915ea72b8c742b72.
    
    * guix/json.scm: Remove.
    * Makefile.am (MODULES): Adjust accordingly.
    * m4/guix.m4 (GUIX_CHECK_GUILE_JSON): Check for 'define-json-mapping'.
    * doc/guix.texi (Requirements): Require Guile-JSON 4.3.0+.
    * guix/ci.scm, guix/cve.scm, guix/import/cpan.scm,
    guix/import/crate.scm, guix/swh.scm: Remove (guix json) import.
    * guix/import/gem.scm, guix/import/pypi.scm: Likewise, and import (json).
    * guix/self.scm (specification->package): Switch to GUILE-JSON-4.
    * guix/git-download.scm (git-fetch): Likewise.
---
 Makefile.am           |  1 -
 doc/guix.texi         |  3 +-
 guix/ci.scm           |  1 -
 guix/cve.scm          |  1 -
 guix/git-download.scm |  4 +--
 guix/import/cpan.scm  |  1 -
 guix/import/crate.scm |  1 -
 guix/import/gem.scm   |  2 +-
 guix/import/pypi.scm  |  2 +-
 guix/json.scm         | 83 ---------------------------------------------------
 guix/self.scm         |  2 +-
 guix/swh.scm          |  1 -
 m4/guix.m4            | 19 ++++++++----
 13 files changed, 21 insertions(+), 100 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 49fe57a..8e91e1e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -68,7 +68,6 @@ MODULES =                                     \
   guix/cpio.scm                                        \
   guix/deprecation.scm                         \
   guix/docker.scm                              \
-  guix/json.scm                                        \
   guix/records.scm                             \
   guix/openpgp.scm                             \
   guix/pki.scm                                 \
diff --git a/doc/guix.texi b/doc/guix.texi
index f224e35..4e9e558 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -790,7 +790,8 @@ or later;
 @c FIXME: Specify a version number once a release has been made.
 @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
 2017 or later;
-@item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON} 3.x;
+@item @uref{https://savannah.nongnu.org/projects/guile-json/,
+Guile-JSON} 4.3.0 or later;
 @item @url{https://www.gnu.org/software/make/, GNU Make}.
 @end itemize
 
diff --git a/guix/ci.scm b/guix/ci.scm
index 02eb90e..7a03bef 100644
--- a/guix/ci.scm
+++ b/guix/ci.scm
@@ -19,7 +19,6 @@
 
 (define-module (guix ci)
   #:use-module (guix http-client)
-  #:use-module (guix json)
   #:use-module (json)
   #:use-module (srfi srfi-1)
   #:use-module (ice-9 match)
diff --git a/guix/cve.scm b/guix/cve.scm
index ae9cca2..57b8459 100644
--- a/guix/cve.scm
+++ b/guix/cve.scm
@@ -19,7 +19,6 @@
 (define-module (guix cve)
   #:use-module (guix utils)
   #:use-module (guix http-client)
-  #:use-module (guix json)
   #:use-module (guix i18n)
   #:use-module ((guix diagnostics) #:select (formatted-message))
   #:use-module (json)
diff --git a/guix/git-download.scm b/guix/git-download.scm
index 90634a8..8e575e3 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès 
<ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès 
<ludo@gnu.org>
 ;;; Copyright © 2017 Mathieu Lirzin <mthl@gnu.org>
 ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
@@ -85,7 +85,7 @@ HASH-ALGO (a symbol).  Use NAME as the file name, or a 
generic name if #f."
                               'tar)))))
 
   (define guile-json
-    (module-ref (resolve-interface '(gnu packages guile)) 'guile-json-3))
+    (module-ref (resolve-interface '(gnu packages guile)) 'guile-json-4))
 
   (define guile-zlib
     (module-ref (resolve-interface '(gnu packages guile)) 'guile-zlib))
diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index 085467b..fd94041 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -28,7 +28,6 @@
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:use-module (json)
-  #:use-module (guix json)
   #:use-module (gcrypt hash)
   #:use-module (guix store)
   #:use-module (guix utils)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 796a764..f87c891 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -24,7 +24,6 @@
   #:use-module ((guix download) #:prefix download:)
   #:use-module (gcrypt hash)
   #:use-module (guix http-client)
-  #:use-module (guix json)
   #:use-module (guix import json)
   #:use-module (guix import utils)
   #:use-module ((guix licenses) #:prefix license:)
diff --git a/guix/import/gem.scm b/guix/import/gem.scm
index a2d99dd..3fe240f 100644
--- a/guix/import/gem.scm
+++ b/guix/import/gem.scm
@@ -22,7 +22,7 @@
 (define-module (guix import gem)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
-  #:use-module (guix json)
+  #:use-module (json)
   #:use-module ((guix download) #:prefix download:)
   #:use-module (guix import utils)
   #:use-module (guix import json)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index a4a2489..15116e3 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -46,7 +46,7 @@
   #:use-module (guix import utils)
   #:use-module ((guix download) #:prefix download:)
   #:use-module (guix import json)
-  #:use-module (guix json)
+  #:use-module (json)
   #:use-module (guix packages)
   #:use-module (guix upstream)
   #:use-module ((guix licenses) #:prefix license:)
diff --git a/guix/json.scm b/guix/json.scm
deleted file mode 100644
index 3e3a28b..0000000
--- a/guix/json.scm
+++ /dev/null
@@ -1,83 +0,0 @@
-;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
-;;;
-;;; This file is part of GNU Guix.
-;;;
-;;; GNU Guix is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3 of the License, or (at
-;;; your option) any later version.
-;;;
-;;; GNU Guix is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
-
-(define-module (guix json)
-  #:use-module (json)
-  #:use-module (srfi srfi-9))
-
-;;; Commentary:
-;;;
-;;; Helpers to map JSON objects to SRFI-9 records.  Taken from (guix swh).
-;;; This module is superseded by 'define-json-mapping' as found since version
-;;; 4.2.0 of Guile-JSON and will be removed once migration is complete.
-;;;
-;;; Code:
-
-(define-syntax define-as-needed
-  (lambda (s)
-    "Define the given syntax rule unless (json) already provides it."
-    (syntax-case s ()
-      ((_ (macro args ...) body ...)
-       (if (module-defined? (resolve-interface '(json))
-                            (syntax->datum #'macro))
-           #'(eval-when (expand load eval)
-               ;; Re-export MACRO from (json).
-               (module-re-export! (current-module) '(macro)))
-           #'(begin
-               ;; Using Guile-JSON < 4.2.0, so provide our own MACRO.
-               (define-syntax-rule (macro args ...)
-                 body ...)
-               (eval-when (expand load eval)
-                 (module-export! (current-module) '(macro)))))))))
-
-(define-syntax-rule (define-json-reader json->record ctor spec ...)
-  "Define JSON->RECORD as a procedure that converts a JSON representation,
-read from a port, string, or hash table, into a record created by CTOR and
-following SPEC, a series of field specifications."
-  (define (json->record input)
-    (let ((table (cond ((port? input)
-                        (json->scm input))
-                       ((string? input)
-                        (json-string->scm input))
-                       ((or (null? input) (pair? input))
-                        input))))
-      (let-syntax ((extract-field (syntax-rules ()
-                                    ((_ table (field key json->value))
-                                     (json->value (assoc-ref table key)))
-                                    ((_ table (field key))
-                                     (assoc-ref table key))
-                                    ((_ table (field))
-                                     (assoc-ref table
-                                                (symbol->string 'field))))))
-        (ctor (extract-field table spec) ...)))))
-
-;; For some reason we cannot just have colliding definitions of
-;; 'define-json-mapping' (that leads to a build failure in users of this
-;; module), hence the use of 'define-as-needed'.
-(define-as-needed (define-json-mapping rtd ctor pred json->record
-                    (field getter spec ...) ...)
-  "Define RTD as a record type with the given FIELDs and GETTERs, à la SRFI-9,
-and define JSON->RECORD as a conversion from JSON to a record of this type."
-  (begin
-    (define-record-type rtd
-      (ctor field ...)
-      pred
-      (field getter) ...)
-
-    (define-json-reader json->record ctor
-      (field spec ...) ...)))
diff --git a/guix/self.scm b/guix/self.scm
index 6a1640a..02ef982 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -49,7 +49,7 @@
                (module-ref (resolve-interface module) variable))))
     (match-lambda
       ("guile"      (ref '(gnu packages guile) 'guile-3.0/libgc-7))
-      ("guile-json" (ref '(gnu packages guile) 'guile-json-3))
+      ("guile-json" (ref '(gnu packages guile) 'guile-json-4))
       ("guile-ssh"  (ref '(gnu packages ssh)   'guile-ssh))
       ("guile-git"  (ref '(gnu packages guile) 'guile-git))
       ("guile-sqlite3" (ref '(gnu packages guile) 'guile-sqlite3))
diff --git a/guix/swh.scm b/guix/swh.scm
index a343ccf..0b765cc 100644
--- a/guix/swh.scm
+++ b/guix/swh.scm
@@ -22,7 +22,6 @@
   #:use-module (guix build utils)
   #:use-module ((guix build syscalls) #:select (mkdtemp!))
   #:use-module (web uri)
-  #:use-module (guix json)
   #:use-module (web client)
   #:use-module (web response)
   #:use-module (json)
diff --git a/m4/guix.m4 b/m4/guix.m4
index 7256e79..2fcc65e 100644
--- a/m4/guix.m4
+++ b/m4/guix.m4
@@ -161,14 +161,23 @@ dnl GUIX_CHECK_GUILE_JSON
 dnl
 dnl Check whether a recent-enough Guile-JSON is available.
 AC_DEFUN([GUIX_CHECK_GUILE_JSON], [
-  dnl Check whether we're using Guile-JSON 3.x, which uses a JSON-to-Scheme
-  dnl mapping different from that of earlier versions.
+  dnl Check whether we're using Guile-JSON 4.3+, which provides
+  dnl 'define-json-mapping'.
   AC_CACHE_CHECK([whether Guile-JSON is available and recent enough],
     [guix_cv_have_recent_guile_json],
     [GUILE_CHECK([retval],
-      [(use-modules (json) (ice-9 match))
-       (match (json-string->scm \"[[ { \\\"a\\\": 42 } ]]\")
-         (#((("a" . 42))) #t))])
+      [(use-modules (json))
+
+       (define-json-mapping <frob> make-frob
+         frob?
+        json->frob
+        (a frob-a)
+        (b frob-b \"bee\"))
+
+       (exit
+        (equal? (json->frob
+                 (open-input-string \"{ \\\"a\\\": 1, \\\"bee\\\": 2 }\"))
+                (make-frob 1 2)))])
      if test "$retval" = 0; then
        guix_cv_have_recent_guile_json="yes"
      else



reply via email to

[Prev in Thread] Current Thread [Next in Thread]