-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Python script for generating Natvis file and update file for 3.11…
….2 (#3697)
- Loading branch information
1 parent
0e61ee8
commit c0dae0f
Showing
4 changed files
with
329 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
generate_natvis.py | ||
================== | ||
|
||
Generate the Natvis debugger visualization file for all supported namespace combinations. | ||
|
||
## Usage | ||
|
||
``` | ||
./generate_natvis.py --version X.Y.Z output_directory/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import itertools | ||
import jinja2 | ||
import os | ||
import sys | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--version', required=True, help='Library version number') | ||
parser.add_argument('output', help='Output directory for nlohmann_json.natvis') | ||
args = parser.parse_args() | ||
|
||
namespaces = ['nlohmann'] | ||
abi_prefix = 'json_abi' | ||
abi_tags = ['_diag', '_ldvcmp'] | ||
version = '_v' + args.version.replace('.', '_') | ||
inline_namespaces = [] | ||
|
||
for n in range(0, len(abi_tags) + 1): | ||
for tags in itertools.combinations(abi_tags, n): | ||
ns = abi_prefix + ''.join(tags) | ||
inline_namespaces += [ns] | ||
inline_namespaces += [ns + version] | ||
|
||
namespaces += [f'{namespaces[0]}::{ns}' for ns in inline_namespaces] | ||
|
||
env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath=sys.path[0]), autoescape=True, trim_blocks=True, | ||
lstrip_blocks=True, keep_trailing_newline=True) | ||
template = env.get_template('nlohmann_json.natvis.j2') | ||
natvis = template.render(namespaces=namespaces) | ||
|
||
with open(os.path.join(args.output, 'nlohmann_json.natvis'), 'w') as f: | ||
f.write(natvis) |
Oops, something went wrong.