diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index c096cb5f4ca..8dd4fc5db12 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -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")