scripts: ci: check_compliance.py: Fix perl script running on windows

Add an if clause to the CheckPatch Class that checks for windows os.
If windows os, check for perl installation.
If no perl installation present. Fail the check.
Without this change, CheckPatch can fail silently on windows,
as windows does not have a way to run perl scripts.

Signed-off-by: Jacob Wienecke <jacob.wienecke@nxp.com>
This commit is contained in:
Jacob Wienecke 2025-01-27 15:22:07 -06:00 committed by Benjamin Cabé
parent 9791034413
commit 8e778d86f7

View File

@ -212,16 +212,29 @@ class CheckPatch(ComplianceTest):
if not os.path.exists(checkpatch):
self.skip(f'{checkpatch} not found')
# check for Perl installation on Windows
if os.name == 'nt':
if not shutil.which('perl'):
self.failure("Perl not installed - required for checkpatch.pl. Please install Perl or add to PATH.")
return
else:
cmd = ['perl', checkpatch]
# Linux and MacOS
else:
cmd = [checkpatch]
cmd.extend(['--mailback', '--no-tree', '-'])
diff = subprocess.Popen(('git', 'diff', '--no-ext-diff', COMMIT_RANGE),
stdout=subprocess.PIPE,
cwd=GIT_TOP)
try:
subprocess.run((checkpatch, '--mailback', '--no-tree', '-'),
subprocess.run(cmd,
check=True,
stdin=diff.stdout,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=True, cwd=GIT_TOP)
shell=False, cwd=GIT_TOP)
except subprocess.CalledProcessError as ex:
output = ex.output.decode("utf-8")