Files
json/tools/generate_natvis
Niels LohmannandKartikey 3f8677d028 Limit Natvis namespace variants to two ABI tags (#5877)
The generator wrote a namespace entry for every combination of ABI tags,
so nlohmann_json.natvis doubled with each new tag. With the 12 tags on
develop it had reached 57.9 MB, and one more tag would push it past
GitHub's 100 MB file limit. It now covers the default namespace, every
single tag, and every pair of tags (versioned and unversioned), which is
158 entries / 1 MB with 12 tags.

Taken over from #5868. Refs #5863.

Signed-off-by: Kartikey <kg704925@gmail.com>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Co-authored-by: Kartikey <kg704925@gmail.com>
2026-10-21 18:26:07 +02:00
..

generate_natvis.py

Generate the Natvis debugger visualization file for namespace combinations with up to two ABI tags.

The checked-in nlohmann_json.natvis covers the default namespace (no ABI tags), every single ABI tag, and every pair of ABI tags, with both versioned and unversioned namespace variants. Configurations that enable three or more ABI tags are not covered by this reduced file.

The ABI tag list and the library version are parsed from include/nlohmann/detail/abi_macros.hpp, so this script must be re-run (via make natvis) whenever an NLOHMANN_JSON_ABI_TAG_* macro is added to that file or the library version is bumped — otherwise the committed nlohmann_json.natvis drifts from the header it visualizes, and make check-amalgamation fails.

Usage

make natvis

make natvis sets up a virtual environment tools/generate_natvis/venv with the dependencies from requirements.txt (Jinja2) and runs the script with it. Alternatively, install the requirements yourself and run:

./generate_natvis.py [--version X.Y.Z] [repository_root/]

--version and the output/repository-root directory both default to values derived from this script's own location, so they only need to be given explicitly when generating a Natvis file for a different checkout or a version other than the one in abi_macros.hpp.