Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

88.23. rapidjson-1.1.0

Header-only JSON parser and generator for C++

Version 1.1.0, release 1
Shelf formats — Data-format and serialisation libraries (XML, JSON, YAML, TOML, INI, RDF, protobuf, thrift), plus data query and convert tools
Phase 41_system (System), 553 of 1047 in build order
Licence MIT
Homepage https://rapidjson.org/
Build time 0.1 SBU
Installed size 582.5 KiB in 39 files
Recipe ports/core/formats/rapidjson/kpkgbuild

About

RapidJSON is Tencent’s header-only JSON parser and generator for C++, with both a DOM and a SAX (streaming) API and in-place parsing. It installs only headers, a CMake package configuration and a pkg-config file. kodi, ppsspp, octave, opencascade, openbabel, opencpn and curaengine build against it.

Sources

Dependencies

Depends on: cmake, ninja.

Required by (7): curaengine, kodi, octave, openbabel, opencascade, opencpn, ppsspp.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install rapidjson'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/formats/rapidjson.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/formats/rapidjson
echo 'bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e  rapidjson-1.1.0.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/rapidjson
SRC=$SRC_ROOT/rapidjson-1.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf rapidjson-1.1.0.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 --no-backup-if-mismatch -i "$PORT_SRC/gcc14.patch"
patch -p1 --no-backup-if-mismatch -i "$PORT_SRC/CVE-2024-38517.patch"
patch -p1 --no-backup-if-mismatch -i "$PORT_SRC/prettywriter-writeflags.patch"

mkdir build && cd build
cmake .. -G Ninja -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DRAPIDJSON_BUILD_DOC=OFF \
	-DRAPIDJSON_BUILD_EXAMPLES=OFF \
	-DRAPIDJSON_BUILD_TESTS=OFF
ninja
DESTDIR=$PKG ninja install

rm -rf "$PKG/usr/share/doc"
test -z "$(find "$PKG" -name '*.orig' -o -name '*.rej')"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/rapidjson, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf rapidjson-1.1.0-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/rapidjson, and runs the triggers its paths call for.

Contents

Installed directories: /usr/include/rapidjson, /usr/lib/cmake/RapidJSON, /usr/share/licenses/rapidjson.

Short descriptions

RapidJSON.pc A fast JSON parser/generator for C++ with both SAX/DOM style API

Notes

gcc14.patch and CVE-2024-38517.patch are upstream commits that the release does not contain. The first removes an assignment operator of GenericStringRef that assigns to its const members and so does not compile with GCC 14; the second keeps the exponent arithmetic of the number parser from underflowing int on a very large negative exponent.

The install copies include/rapidjson as a directory, whatever is in it. patch therefore runs with --no-backup-if-mismatch, so a hunk applied with fuzz leaves no .orig file to be installed as a header, and the test -z "$(find … -name '*.orig' -o -name '*.rej')" line stops the build if one is there anyway. Upstream’s readme.md and the example sources it installs under /usr/share/doc are deleted.