From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ONhFNhl+SGP9UgAAbAwnHQ (envelope-from ) for ; Thu, 13 Oct 2022 23:07:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id IAY/Nhl+SGPnXwAAauVa8A (envelope-from ) for ; Thu, 13 Oct 2022 23:07:37 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 890D6F777 for ; Thu, 13 Oct 2022 23:07:37 +0200 (CEST) Received: from localhost ([::1]:35560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oj5QW-0005Cg-Mt for larch@yhetil.org; Thu, 13 Oct 2022 17:07:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oj5P1-0002zx-DZ for guix-patches@gnu.org; Thu, 13 Oct 2022 17:06:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36088) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oj5P0-0007UL-Vs for guix-patches@gnu.org; Thu, 13 Oct 2022 17:06:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oj5P0-0005mc-QM for guix-patches@gnu.org; Thu, 13 Oct 2022 17:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58261] [PATCH v3 03/15] gnu: Add sajson. Resent-From: David Elsing Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 13 Oct 2022 21:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58261 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58261@debbugs.gnu.org Cc: David Elsing Received: via spool by 58261-submit@debbugs.gnu.org id=B58261.166569510622058 (code B ref 58261); Thu, 13 Oct 2022 21:06:02 +0000 Received: (at 58261) by debbugs.gnu.org; 13 Oct 2022 21:05:06 +0000 Received: from localhost ([127.0.0.1]:35141 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj5O6-0005jd-70 for submit@debbugs.gnu.org; Thu, 13 Oct 2022 17:05:06 -0400 Received: from mout01.posteo.de ([185.67.36.65]:59621) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj5Nt-0005h8-LW for 58261@debbugs.gnu.org; Thu, 13 Oct 2022 17:04:54 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 2BBFE240029 for <58261@debbugs.gnu.org>; Thu, 13 Oct 2022 23:04:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1665695088; bh=3RB/qoUS8+xbzKN61VD0Gg9UUu4vU88He+j5Lprdjc4=; h=From:To:Cc:Subject:Date:From; b=PeT7NmXZ2qVzSwL+IknBBFyOHNQ5gJzfC8QXZXiLNK20sj/ZCPhdXURikjiptGvuZ aOvFFCZupbEBOANGo/jQoezqAD/mhNhJpdXNfsLPnwtcbS200Qo7Gf40JAW42C6+mk o4yIiDDgxxYn45j8oc+fDKcR9UtlZFvODkELYo5Tq713Xy8FP8zH6y1+9L/ffi2Q0n K1WBHVAXKmKtAtQ19tQy8z/AAenmDhoIIhfXMyacMzKWjYwfXe0mTUuyMbnMWzvP8a rDNMGamrP64OfPhVfNYo5Eb9KZ4OIaFYqEzkb16rrFD0xPpqybLiKpB+hkP3/aNQNg 3I/OLFRECWWWg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MpMTq5V0Cz6tnd; Thu, 13 Oct 2022 23:04:47 +0200 (CEST) From: David Elsing Date: Thu, 13 Oct 2022 21:04:12 +0000 Message-Id: <20221013210424.993-4-david.elsing@posteo.net> In-Reply-To: <20221007152148.32591-1-david.elsing@posteo.net> References: <20221007152148.32591-1-david.elsing@posteo.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665695257; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=tci/+d0b9ReVYtFT9d89Sq8ng1dMMVWnz8S22Y8bMYg=; b=rQMp2s6dMCW71gMBcrmGb5mkckEDRimAvBKlYzzMD8UMSlm0HggeGam0koWxqq+O1i71im 1N3aFX7EO7J2veg5bP6QNDvXMJBvqDW0rrXvwRyVDsnuUZBie5bCZgICF1TzPihElrv0dE OTFYwYsmtsbUd2WdDz1AArNL5jfzzk7B1NNV3gT6ZuJ1vNTxIlQascUg4NWxuYEqcL5vsp rasiXE2wl4FUBh6hXin9bH/q935kMSg3ZGJVxF6cqyauwnQV6psqz3menYUPVeSfF1ns3Y RQ0DaIt+2rbWoUCNoihtAgpCmZ6N7mPPMYiUvkMqQF5DBCLySFudG2LfucrdmQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665695257; a=rsa-sha256; cv=none; b=Mh/rdKxg7DjyoNpt8/Fv9Trnl8m7mtSOwo6crMB/cfEryzlzElYxNrhvz4cH1dF9bkTFiy Ear5y4y2TKrpf5AD3CdvJFvtItbza9j5BQ2Eo5b4ZVVi2tqCrGhByExbWVT8WPmPczoXxc so68+MVIC6LXC1KwqGUyq/aHOHOw5FXcBFmyrYO+a51S5a2lzAGrgdBC+g11oqr5nbv7sf I6XC1q/D1chdDjxCS8dXP0V6hzdTVTWFkSWk1mWnvgNhzEcN5n0iE0i8z5xuY07gIlvqMI N0G/yopclpw+sRYRVOz8sOaVjKK2aSpNI3rOhqrp/gRiDQS1RyKHUXcO6zwvEg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=PeT7NmXZ; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 9.00 X-Spam: Yes Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=PeT7NmXZ; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 890D6F777 X-Spam-Score: 9.00 X-Migadu-Spam: Yes X-Migadu-Scanner: scn1.migadu.com X-TUID: /N6JAoR/1CG/ * 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 2b5841e777..b6a0a70ed7 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) @@ -2033,3 +2034,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 _ + (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 %build-inputs "/include/UnitTest++") + "', 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))))))) + (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 + 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 ++ const unsigned char globals_struct::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(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(c)] & 2) != 0; + } -- 2.37.0