Also apply --uncrustify to --fix mode

Before this commit, verify mode still hard-coded "uncrustify" as the command
name.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2023-11-20 17:22:33 +01:00
parent eaf2b3e358
commit 9707b5c138
+5 -5
View File
@@ -15,7 +15,6 @@ from mbedtls_framework import build_tree
UNCRUSTIFY_SUPPORTED_VERSION = "0.75.1"
CONFIG_FILE = ".uncrustify.cfg"
UNCRUSTIFY_EXE = "uncrustify"
UNCRUSTIFY_ARGS = ["-c", CONFIG_FILE]
CHECK_GENERATED_FILES = "tests/scripts/check-generated-files.sh"
@@ -213,13 +212,14 @@ def check_style_is_correct(uncrustify_exe: str,
return style_correct
def fix_style_single_pass(src_file_list: List[str]) -> bool:
def fix_style_single_pass(uncrustify_exe: str,
src_file_list: List[str]) -> bool:
"""
Run Uncrustify once over the source files.
"""
code_change_args = UNCRUSTIFY_ARGS + ["--no-backup"]
for src_file in src_file_list:
uncrustify_cmd = [UNCRUSTIFY_EXE] + code_change_args + [src_file]
uncrustify_cmd = [uncrustify_exe] + code_change_args + [src_file]
result = subprocess.run(uncrustify_cmd, check=False)
if result.returncode != 0:
print_err("Uncrustify with file returned: " +
@@ -232,9 +232,9 @@ def fix_style(uncrustify_exe: str, src_file_list: List[str]) -> int:
"""
Fix the code style. This takes 2 passes of Uncrustify.
"""
if not fix_style_single_pass(src_file_list):
if not fix_style_single_pass(uncrustify_exe, src_file_list):
return 1
if not fix_style_single_pass(src_file_list):
if not fix_style_single_pass(uncrustify_exe, src_file_list):
return 1
# Guard against future changes that cause the codebase to require