Bug 1605879 - for clang-tidy based static-analysis pass the files for analysis in chuncks. r=sylvestre

Since we have a limit of the number of arguments length that the shell can support we have to
pass the files for the analysis to `run-clang-tidy.py` in chuncks, calculated in proportion
to the number or logical cpu cores.

Differential Revision: https://phabricator.services.mozilla.com/D58971

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andi-Bogdan Postelnicu 2020-01-09 10:28:20 +00:00
parent 3440918f3f
commit b85bad52aa

View File

@ -273,16 +273,28 @@ class StaticAnalysis(MachCommandBase):
self._compilation_commands_path = self.topobjdir
if self._clang_tidy_config is None:
self._clang_tidy_config = self._get_clang_tidy_config()
args = self._get_clang_tidy_command(
checks=checks, header_filter=header_filter, sources=source, jobs=jobs, fix=fix)
monitor = StaticAnalysisMonitor(
self.topsrcdir, self.topobjdir, self._clang_tidy_config, total)
footer = StaticAnalysisFooter(self.log_manager.terminal, monitor)
with StaticAnalysisOutputManager(self.log_manager, monitor, footer) as output_manager:
rc = self.run_process(args=args, ensure_exit_code=False,
line_handler=output_manager.on_line, cwd=cwd)
import math
import multiprocessing
batch_size = int(math.ceil(float(len(source)) / multiprocessing.cpu_count()))
for i in range(0, len(source), batch_size):
args = self._get_clang_tidy_command(
checks=checks,
header_filter=header_filter,
sources=source[i:(i + batch_size)],
jobs=jobs,
fix=fix)
rc = self.run_process(
args=args,
ensure_exit_code=False,
line_handler=output_manager.on_line,
cwd=cwd)
self.log(logging.WARNING, 'warning_summary',
{'count': len(monitor.warnings_db)},