Skip to content

Commit a36b930

Browse files
committed
check uncrustify version
1 parent d294692 commit a36b930

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/codeformat.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ def transform(m):
119119
)
120120
PY_EXTS = (".py",)
121121

122+
123+
def check_uncrustify_version():
124+
version = subprocess.check_output(
125+
["uncrustify", "--version"], encoding="utf-8", errors="replace"
126+
)
127+
if version < "Uncrustify-0.71":
128+
raise SystemExit(f"codeformat.py requires Uncrustify 0.71 or newer, got {version}")
129+
130+
122131
# Transform a filename argument relative to the current directory into one
123132
# relative to the TOP directory, which is what we need when checking against
124133
# path_rx.
@@ -218,6 +227,7 @@ def batch(cmd, files, N=200):
218227

219228
# Format C files with uncrustify.
220229
if format_c:
230+
check_uncrustify_version()
221231
command = ["uncrustify", "-c", UNCRUSTIFY_CFG, "-lC", "--no-backup"]
222232
if not args.v:
223233
command.append("-q")

0 commit comments

Comments
 (0)