diff options
Diffstat (limited to 'scripts/formatcode.py')
| -rw-r--r-- | scripts/formatcode.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/scripts/formatcode.py b/scripts/formatcode.py index dc13ae117..49a8753da 100644 --- a/scripts/formatcode.py +++ b/scripts/formatcode.py @@ -1,8 +1,9 @@ import argparse -import os import fileinput +import os import pathlib import re +import subprocess match_expressions = [] valid_extensions = [] @@ -89,6 +90,20 @@ def parse_match_expressions(wildcards, matches): print(f'Could not parse input --match expression \'{regex}\': {str(ex)}') quit() +def validate_clang_format(): + vstring = subprocess.check_output("clang-format --version", shell=True).decode().rstrip() + + match = re.search(r'(\d+)\.(\d+)(\.(\d+))?$', vstring) + if not match: + raise ValueError("invalid version number '%s'" % vstring) + + (major, minor, patch) = match.group(1, 2, 4) + + if int(major) < 13: + if int(minor) == 0: + if int(patch) < 1: + raise ValueError(f'invalid clang-format version -- we require at least v12.0.1') + def _main(): global root_dir, use_batching @@ -106,6 +121,8 @@ def _main(): root_dir = pathlib.Path(__file__).parent.parent.resolve() use_batching = options.use_batching + validate_clang_format() + while True: if (os.path.isfile(".clang-format")): scan_zen(".") |