unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: David Elsing <david.elsing@posteo.net>, 58261@debbugs.gnu.org
Subject: [bug#58261] [PATCH v2 03/13] gnu: Add sajson.
Date: Sun, 09 Oct 2022 13:46:18 +0200	[thread overview]
Message-ID: <8fbe13ce961324619084c6972edcb7a3784f17f8.camel@gmail.com> (raw)
In-Reply-To: <20221007152148.32591-4-david.elsing@posteo.net>

Am Freitag, dem 07.10.2022 um 15:21 +0000 schrieb David Elsing:
> * gnu/packages/cpp.scm (sajson): New variable.
> ---
>  gnu/packages/cpp.scm                          | 60
> +++++++++++++++++++
>  .../patches/sajson-build-with-gcc10.patch     | 45 ++++++++++++++
>  2 files changed, 105 insertions(+)
>  create mode 100644 gnu/packages/patches/sajson-build-with-
> gcc10.patch
> 
> diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
> index 38a2a9e829..dca0245df5 100644
> --- a/gnu/packages/cpp.scm
> +++ b/gnu/packages/cpp.scm
> @@ -57,6 +57,7 @@ (define-module (gnu packages cpp)
>    #:use-module (guix build-system gnu)
>    #:use-module (guix build-system meson)
>    #:use-module (guix build-system python)
> +  #:use-module (guix build-system scons)
>    #:use-module (guix modules)
>    #:use-module (guix gexp)
>    #:use-module (gnu packages)
> @@ -2005,3 +2006,62 @@ (define-public pocketfft-cpp
>  computing Fast Fourier transformations.  It supports
> multidimensional arrays,
>  different floating point sizes and complex transformations.")
>        (license license:bsd-3))))
> +
> +(define-public sajson
> +  (let ((commit "ec644013e34f9984a3cc9ba568cab97a391db9cd")
> +        (revision "0"))
> +    (package
> +      (name "sajson")
> +      (version (git-version "1.0" revision commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://github.com/chadaustin/sajson")
> +                      (commit commit)))
> +                (file-name (git-file-name name version))
> +                (patches
> +                 (search-patches "sajson-build-with-gcc10.patch"))
> +                (sha256
> +                 (base32
> +                 
> "0fjag27w7gvkc5pdhq3ad7yc09rabpzahndw1sgsg04ipznidmmq"))
> +                (modules '((guix build utils)))
> +                (snippet '(delete-file-recursively "third-party"))))
> +      (build-system scons-build-system)
> +      (arguments
> +       (list
> +        #:phases
> +        #~(modify-phases %standard-phases
> +            (add-after 'unpack 'disable-other-builds
> +              (lambda _
> +                (substitute* "SConstruct"
> +                  (("for name, tools in builds:")
> +                   "for name, tools in [('opt', [gcc, opt])]:"))))
> +            (add-after 'unpack 'use-external-unittest-cpp
> +              (lambda* (#:key inputs #:allow-other-keys)
> +                (substitute* "SConscript"
> +                  (("unittestpp_env\\.Library") "_dummy = ")
> +                  (("test_env = env.Clone\\(tools=\\[unittestpp,
> sajson\\]\\)")
> +                   (string-append
> +                    "test_env = env.Clone(tools=[sajson])\n"
> +                    "test_env.Append(CPPPATH='"
> +                    (search-input-directory inputs
> "/include/UnitTest++")
Note that you need (or native-inputs inputs) wherever you wrote inputs.
> +                    "', LIBPATH='"
> +                    (string-append #$(this-package-native-input
> "unittest-cpp")
> +                                   "/lib")
> +                    "', LIBS=['UnitTest++'])")))))
> +            (replace 'check
> +              (lambda* (#:key tests? #:allow-other-keys)
> +                (when tests?
> +                  (invoke "build/opt/test")
> +                  (invoke "build/opt/test_unsorted"))))
> +            (replace 'install
> +              (lambda _
> +                (let ((out (string-append #$output "/include")))
> +                  (install-file "include/sajson.h" out)
> +                  (install-file "include/sajson_ostream.h"
> out)))))))
For the record, what would a regular install do?
> +      (native-inputs (list unittest-cpp))
> +      (home-page "https://github.com/chadaustin/sajson")
> +      (synopsis "C++11 header-only, in-place JSON parser")
> +      (description "@code{sajson} is an in-place JSON parser with
> support for
> +parsing with only a single memory allocation.")
> +      (license license:expat))))
> diff --git a/gnu/packages/patches/sajson-build-with-gcc10.patch
> b/gnu/packages/patches/sajson-build-with-gcc10.patch
> new file mode 100644
> index 0000000000..878706dc79
> --- /dev/null
> +++ b/gnu/packages/patches/sajson-build-with-gcc10.patch
> @@ -0,0 +1,45 @@
> +This patch is from the upstream pull request
> +https://github.com/chadaustin/sajson/pull/54.
> +It fixes linking with GCC.
> +
> +diff --git a/include/sajson.h b/include/sajson.h
> +index 8b4e05a..1bd045b 100644
> +--- a/include/sajson.h
> ++++ b/include/sajson.h
> +@@ -138,12 +138,17 @@ constexpr inline size_t make_element(tag t,
> size_t value) {
> + // header. This trick courtesy of Rich Geldreich's Purple JSON
> parser.
> + template <typename unused = void>
> + struct globals_struct {
> ++    static const unsigned char parse_flags[256];
> ++};
> ++typedef globals_struct<> globals;
> ++
> + // clang-format off
> + 
> +     // bit 0 (1) - set if: plain ASCII string character
> +     // bit 1 (2) - set if: whitespace
> +     // bit 4 (0x10) - set if: 0-9 e E .
> +-    constexpr static const uint8_t parse_flags[256] = {
> ++    template <typename unused>
> ++    const unsigned char globals_struct<unused>::parse_flags[256] =
> {
> +      // 0    1    2    3    4    5    6    7      8    9    A   
> B    C    D    E    F
> +         0,   0,   0,   0,   0,   0,   0,   0,     0,   2,   2,  
> 0,   0,   2,   0,   0, // 0
> +         0,   0,   0,   0,   0,   0,   0,   0,     0,   0,   0,  
> 0,   0,   0,   0,   0, // 1
> +@@ -162,15 +167,13 @@ struct globals_struct {
> +     };
> + 
> + // clang-format on
> +-};
> +-typedef globals_struct<> globals;
> + 
> +-constexpr inline bool is_plain_string_character(char c) {
> ++inline bool is_plain_string_character(char c) {
> +     // return c >= 0x20 && c <= 0x7f && c != 0x22 && c != 0x5c;
> +     return (globals::parse_flags[static_cast<unsigned char>(c)] &
> 1) != 0;
> + }
> + 
> +-constexpr inline bool is_whitespace(char c) {
> ++inline bool is_whitespace(char c) {
> +     // return c == '\r' || c == '\n' || c == '\t' || c == ' ';
> +     return (globals::parse_flags[static_cast<unsigned char>(c)] &
> 2) != 0;
> + }


  reply	other threads:[~2022-10-09 11:47 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 22:55 [bug#58261] [PATCH 00/11] Add rdkit David Elsing
2022-10-03  0:19 ` [bug#58261] [PATCH 01/11] gnu: Add fast-float David Elsing
2022-10-04  6:57   ` Liliana Marie Prikler via Guix-patches via
2022-10-07 15:08     ` David Elsing
2022-10-03  0:19 ` [bug#58261] [PATCH 02/11] gnu: Add pocketfft David Elsing
2022-10-04  7:09   ` Liliana Marie Prikler
2022-10-07 15:10     ` David Elsing
2022-10-03  0:19 ` [bug#58261] [PATCH 03/11] gnu: Add sajson David Elsing
2022-10-04  7:22   ` Liliana Marie Prikler
2022-10-07 15:10     ` David Elsing
2022-10-03  0:19 ` [bug#58261] [PATCH 04/11] gnu: Add tinydir David Elsing
2022-10-04  7:27   ` Liliana Marie Prikler
2022-10-07 15:11     ` David Elsing
2022-10-07 15:13       ` Liliana Marie Prikler
2022-10-03  0:19 ` [bug#58261] [PATCH 05/11] gnu: Add optionparser David Elsing
2022-10-04  7:42   ` Liliana Marie Prikler
2022-10-07 15:11     ` David Elsing
2022-10-03  0:19 ` [bug#58261] [PATCH 06/11] gnu: Add gemmi David Elsing
2022-10-04  7:49   ` Liliana Marie Prikler
2022-10-07 15:11     ` David Elsing
2022-10-07 15:17       ` Liliana Marie Prikler
2022-10-03  0:19 ` [bug#58261] [PATCH 07/11] gnu: Add freesasa David Elsing
2022-10-04  8:02   ` Liliana Marie Prikler
2022-10-07 15:12     ` David Elsing
2022-10-07 15:19       ` Liliana Marie Prikler
2022-10-03  0:19 ` [bug#58261] [PATCH 08/11] gnu: Add maeparser David Elsing
2022-10-03  0:19 ` [bug#58261] [PATCH 09/11] gnu: Add coordgenlibs David Elsing
2022-10-03  0:19 ` [bug#58261] [PATCH 10/11] gnu: Add yaehmop-tightbind David Elsing
2022-10-04  7:54   ` Liliana Marie Prikler
2022-10-07 15:12     ` David Elsing
2022-10-07 15:25       ` Liliana Marie Prikler
2022-10-03  0:19 ` [bug#58261] [PATCH 11/11] gnu: Add rdkit David Elsing
2022-10-04  8:13   ` Liliana Marie Prikler
2022-10-07 15:12     ` David Elsing
2022-10-07 15:29       ` Liliana Marie Prikler
2022-10-07 15:21 ` [bug#58261] [PATCH v2 00/13] Add rdkit v2 David Elsing
2022-10-09 10:02   ` Liliana Marie Prikler
2022-10-13 20:58     ` David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 00/15] Add rdkit v3 David Elsing
2022-10-15 14:37     ` bug#58261: " Liliana Marie Prikler
2022-10-17  9:55       ` [bug#58261] " David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 01/15] gnu: Add fast-float David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 02/15] gnu: Add pocketfft-cpp David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 03/15] gnu: Add sajson David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 04/15] gnu: Add cbehave David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 05/15] gnu: Add tinydir David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 06/15] gnu: Add optionparser David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 07/15] gnu: Add sajson-for-gemmi David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 08/15] gnu: Add gemmi David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 09/15] gnu: Add freesasa David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 10/15] gnu: Add maeparser David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 11/15] gnu: Add coordgenlibs David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 12/15] gnu: Add yaehmop David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 13/15] gnu: Add avalon-toolkit David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 14/15] gnu: Add ringdecomposerlib David Elsing
2022-10-13 21:04   ` [bug#58261] [PATCH v3 15/15] gnu: Add rdkit David Elsing
2022-10-07 15:21 ` [bug#58261] [PATCH v2 01/13] gnu: Add fast-float David Elsing
2022-10-09 10:04   ` Liliana Marie Prikler
2022-10-07 15:21 ` [bug#58261] [PATCH v2 02/13] gnu: Add pocketfft David Elsing
2022-10-09 11:42   ` Liliana Marie Prikler
2022-10-07 15:21 ` [bug#58261] [PATCH v2 03/13] gnu: Add sajson David Elsing
2022-10-09 11:46   ` Liliana Marie Prikler [this message]
2022-10-13 20:59     ` David Elsing
2022-10-14 21:30       ` Liliana Marie Prikler
2022-10-07 15:21 ` [bug#58261] [PATCH v2 04/13] gnu: Add tinydir David Elsing
2022-10-09 11:48   ` Liliana Marie Prikler
2022-10-07 15:21 ` [bug#58261] [PATCH v2 05/13] gnu: Add optionparser David Elsing
2022-10-07 15:21 ` [bug#58261] [PATCH v2 06/13] gnu: Add gemmi David Elsing
2022-10-09 11:54   ` Liliana Marie Prikler
2022-10-13 21:00     ` David Elsing
2022-10-14 21:32       ` Liliana Marie Prikler
2022-10-07 15:21 ` [bug#58261] [PATCH v2 07/13] gnu: Add freesasa David Elsing
2022-10-07 15:21 ` [bug#58261] [PATCH v2 08/13] gnu: Add maeparser David Elsing
2022-10-07 15:21 ` [bug#58261] [PATCH v2 09/13] gnu: Add coordgenlibs David Elsing
2022-10-09 11:56   ` Liliana Marie Prikler
2022-10-13 21:00     ` David Elsing
2022-10-07 15:21 ` [bug#58261] [PATCH v2 10/13] gnu: Add yaehmop-tightbind David Elsing
2022-10-09 12:02   ` Liliana Marie Prikler
2022-10-13 21:00     ` David Elsing
2022-10-14 21:33       ` Liliana Marie Prikler
2022-10-07 15:21 ` [bug#58261] [PATCH v2 11/13] gnu: Add avalontoolkit David Elsing
2022-10-09 12:06   ` Liliana Marie Prikler
2022-10-13 21:01     ` David Elsing
2022-10-07 15:22 ` [bug#58261] [PATCH v2 12/13] gnu: Add ringdecomposerlib David Elsing
2022-10-07 15:22 ` [bug#58261] [PATCH v2 13/13] gnu: Add rdkit David Elsing
2022-10-09 12:12   ` Liliana Marie Prikler
2022-10-13 21:01     ` David Elsing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8fbe13ce961324619084c6972edcb7a3784f17f8.camel@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=58261@debbugs.gnu.org \
    --cc=david.elsing@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).