Use run-clang-tidy when available.

pull/6092/head
Jussi Pakkanen 5 years ago
parent 212a05b87e
commit cce172432b
  1. 22
      mesonbuild/scripts/clangtidy.py

@ -14,23 +14,37 @@
import pathlib import pathlib
import subprocess import subprocess
import shutil
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from ..compilers import lang_suffixes from ..compilers import lang_suffixes
def clangformat(srcdir_name, builddir_name): def manual_clangformat(srcdir_name, builddir_name):
srcdir = pathlib.Path(srcdir_name) srcdir = pathlib.Path(srcdir_name)
suffixes = set(lang_suffixes['c']).union(set(lang_suffixes['cpp'])) suffixes = set(lang_suffixes['c']).union(set(lang_suffixes['cpp']))
suffixes.add('h') suffixes.add('h')
futures = [] futures = []
returncode = 0
with ThreadPoolExecutor() as e: with ThreadPoolExecutor() as e:
for f in (x for suff in suffixes for x in srcdir.glob('**/*.' + suff)): for f in (x for suff in suffixes for x in srcdir.glob('**/*.' + suff)):
strf = str(f) strf = str(f)
if strf.startswith(builddir_name): if strf.startswith(builddir_name):
continue continue
futures.append(e.submit(subprocess.check_call, ['clang-tidy', '-p', builddir_name, strf])) futures.append(e.submit(subprocess.run, ['clang-tidy', '-p', builddir_name, strf]))
[x.result() for x in futures] [max(returncode, x.result().returncode) for x in futures]
return 0 return returncode
def clangformat(srcdir_name, builddir_name):
run_clang_tidy = None
for rct in ('run-clang-tidy', 'run-clang-tidy.py'):
if shutil.which(rct):
run_clang_tidy = rct
break
if run_clang_tidy:
return subprocess.run([run_clang_tidy, '-p', builddir_name]).returncode
else:
print('Could not find run-clang-tidy, running checks manually.')
manual_clangformat(srcdir_name, builddir_name)
def run(args): def run(args):
srcdir_name = args[0] srcdir_name = args[0]

Loading…
Cancel
Save