Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate_natvis.py: validate version number; cleanup #3698

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions tools/generate_natvis/generate_natvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
import itertools
import jinja2
import os
import re
import sys

def semver(v):
if not re.fullmatch(r'\d+\.\d+\.\d+', v):
raise ValueError
return v

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--version', required=True, help='Library version number')
parser.add_argument('--version', required=True, type=semver, help='Library version number')
parser.add_argument('output', help='Output directory for nlohmann_json.natvis')
args = parser.parse_args()

Expand All @@ -18,11 +24,11 @@
version = '_v' + args.version.replace('.', '_')
inline_namespaces = []

# generate all combinations of inline namespace names
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]
inline_namespaces += [ns, ns + version]

namespaces += [f'{namespaces[0]}::{ns}' for ns in inline_namespaces]

Expand Down