diff options
author | Steven Voges <svoges.sbo@gmail.com> | 2022-04-22 20:32:46 +0100 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2022-04-24 01:47:10 +0700 |
commit | 49d042c841a857a54e8f6fd9fd3d98eed54a9f36 (patch) | |
tree | 06a0f734eebb3837d08ef11dbf0ae984970b2005 /libraries | |
parent | fc0732657e84e0eb38f342b74f9e2caa85456435 (diff) | |
download | slackbuilds-49d042c841a857a54e8f6fd9fd3d98eed54a9f36.tar.gz |
libraries/nlohmann_json: Added (JSON for Modern C++)
Signed-off-by: Dave Woodfall <dave@slackbuilds.org>
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/nlohmann_json/README | 35 | ||||
-rw-r--r-- | libraries/nlohmann_json/nlohmann_json.SlackBuild | 106 | ||||
-rw-r--r-- | libraries/nlohmann_json/nlohmann_json.info | 10 | ||||
-rw-r--r-- | libraries/nlohmann_json/slack-desc | 19 |
4 files changed, 170 insertions, 0 deletions
diff --git a/libraries/nlohmann_json/README b/libraries/nlohmann_json/README new file mode 100644 index 0000000000..7d8f084cf5 --- /dev/null +++ b/libraries/nlohmann_json/README @@ -0,0 +1,35 @@ +There are myriads of JSON libraries out there, and each may even have +its reason to exist. Our class had these design goals: + +Intuitive syntax. In languages such as Python, JSON feels like a first +class data type. We used all the operator magic of modern C++ to achieve +the same feeling in your code. Check out the examples below and you'll +know what I mean. + +Trivial integration. Our whole code consists of a single header file +json.hpp. That's it. No library, no subproject, no dependencies, no +complex build system. The class is written in vanilla C++11. All in all, +everything should require no adjustment of your compiler flags or +project settings. + +Serious testing. Our class is heavily unit-tested and covers 100% of the +code, including all exceptional behavior. Furthermore, we checked with +Valgrind and the Clang Sanitizers that there are no memory leaks. Google +OSS-Fuzz additionally runs fuzz tests against all parsers 24/7, +effectively executing billions of tests so far. To maintain high +quality, the project is following the Core Infrastructure Initiative +(CII) best practices. + +Other aspects were not so important to us: + +Memory efficiency. Each JSON object has an overhead of one pointer (the +maximal size of a union) and one enumeration element (1 byte). The +default generalization uses the following C++ data types: std::string +for strings, int64_t, uint64_t or double for numbers, std::map for +objects, std::vector for arrays, and bool for Booleans. However, you can +template the generalized class basic_json to your needs. + +Speed. There are certainly faster JSON libraries out there. However, if +your goal is to speed up your development by adding JSON support with a +single header, then this library is the way to go. If you know how to +use a std::vector or std::map, you are already set. diff --git a/libraries/nlohmann_json/nlohmann_json.SlackBuild b/libraries/nlohmann_json/nlohmann_json.SlackBuild new file mode 100644 index 0000000000..ec66b1a5ac --- /dev/null +++ b/libraries/nlohmann_json/nlohmann_json.SlackBuild @@ -0,0 +1,106 @@ +#!/bin/bash + +# Slackware build script for nlohmann_json + +# Copyright 2022 Steven Voges <svoges.sbo@gmail.com> +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +cd $(dirname $0) ; CWD=$(pwd) + +SRCNAM=json +PRGNAM=nlohmann_json +VERSION=${VERSION:-3.10.5} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i586 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $SRCNAM-$VERSION +tar xvf $CWD/$SRCNAM-$VERSION.tar.gz +cd $SRCNAM-$VERSION +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +mkdir -p build +cd build + cmake \ + -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release .. + make + make install/strip DESTDIR=$PKG +cd .. + +rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la + +find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ + | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + +find $PKG -name perllocal.pod -o -name ".packlist" -o -name "*.bs" | xargs rm -f || true + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a \ + *.md LICENSE.MIT \ + $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE diff --git a/libraries/nlohmann_json/nlohmann_json.info b/libraries/nlohmann_json/nlohmann_json.info new file mode 100644 index 0000000000..61314a58f4 --- /dev/null +++ b/libraries/nlohmann_json/nlohmann_json.info @@ -0,0 +1,10 @@ +PRGNAM="nlohmann_json" +VERSION="3.10.5" +HOMEPAGE="https://json.nlohmann.me/" +DOWNLOAD="https://github.com/nlohmann/json/archive/v3.10.5/json-3.10.5.tar.gz" +MD5SUM="5b946f7d892fa55eabec45e76a20286b" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="" +MAINTAINER="Steven Voges" +EMAIL="svoges.sbo@gmail.com" diff --git a/libraries/nlohmann_json/slack-desc b/libraries/nlohmann_json/slack-desc new file mode 100644 index 0000000000..ff3ddb155d --- /dev/null +++ b/libraries/nlohmann_json/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +nlohmann_json: nlohmann_json (JSON for Modern C++) +nlohmann_json: +nlohmann_json: nlohmann_json is a JSON library for modern C++ and was designed with +nlohmann_json: three goals in mind: Intuitive syntax, Trivial integration, and +nlohmann_json: Serious testing. +nlohmann_json: +nlohmann_json: +nlohmann_json: +nlohmann_json: +nlohmann_json: +nlohmann_json: |