3 # Copyright 2019 Hans Dembinski
4 # Distributed under the Boost Software License, Version 1.0.
5 # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
7 import subprocess as subp
8 from pathlib import Path
9 from multiprocessing.pool import ThreadPool
12 for version in range(15, 5, -1):
13 clang_tidy_cmd = f"clang-tidy-{version}"
14 if subp.run(("which", clang_tidy_cmd), stdout=subp.DEVNULL).returncode == 0:
17 project_dir = Path(__file__).resolve().parents[1]
18 assert project_dir.exists()
19 boost_dir = project_dir.parents[1]
21 filenames = (project_dir / "include").rglob("*.hpp")
24 def run_tidy(filename):
25 n = len(project_dir.parts) + 2
26 cmd = f"{clang_tidy_cmd} {filename} -- -I{boost_dir}"
29 subp.run(cmd.split(), stdout=subp.PIPE, stderr=subp.STDOUT).stdout.decode(
36 for cmd, report in pool.map(run_tidy, filenames):