Bug 1536763 - Support more than 100 files in ./mach static-analysis check, r=andi
authorBastien Abadie <bastien@mozilla.com>
Wed, 20 Mar 2019 13:03:13 +0000
changeset 465223 2a807fde4c47339f48e548127d215880183fbcae
parent 465222 d808eb8f5dd52d49348586d0764ecf8a419d1e9f
child 465224 4ce441f87fdf4abc6443ff83d610b2adff4d3885
push id112496
push usershindli@mozilla.com
push dateThu, 21 Mar 2019 04:37:39 +0000
treeherdermozilla-inbound@29476d3ca61d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersandi
bugs1536763
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1536763 - Support more than 100 files in ./mach static-analysis check, r=andi Differential Revision: https://phabricator.services.mozilla.com/D24151
python/mozbuild/mozbuild/mach_commands.py
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -1711,23 +1711,27 @@ class StaticAnalysis(MachCommandBase):
         self.log_manager.enable_all_structured_loggers()
 
         rc = self._build_compile_db(verbose=verbose)
         rc = rc or self._build_export(jobs=jobs, verbose=verbose)
         rc = rc or self._get_clang_tools(verbose=verbose)
         if rc != 0:
             return rc
 
+        # Split in several chunks to avoid hitting Python's limit of 100 groups in re
         compile_db = json.loads(open(self._compile_db, 'r').read())
         total = 0
         import re
-        name_re = re.compile('(' + ')|('.join(source) + ')')
-        for f in compile_db:
-            if name_re.search(f['file']):
-                total = total + 1
+        chunk_size = 50
+        for offset in range(0, len(source), chunk_size):
+            source_chunks = source[offset:offset + chunk_size]
+            name_re = re.compile('(' + ')|('.join(source_chunks) + ')')
+            for f in compile_db:
+                if name_re.search(f['file']):
+                    total = total + 1
 
         if not total:
             return 0
 
         cwd = self.topobjdir
         self._compilation_commands_path = self.topobjdir
         self._clang_tidy_config = self._get_clang_tidy_config()
         args = self._get_clang_tidy_command(