bin/find-unneeded-includes |   23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

New commits:
commit 1421831429056ed770a67feeec12c843f80bb006
Author:     Gabor Kelemen <kelemen.gab...@nisz.hu>
AuthorDate: Thu Jun 24 07:42:32 2021 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Jun 28 08:58:02 2021 +0200

    find-unneeded-includes: introduce --dontstop switch
    
    ...to make it not stop after each error found.
    
    In case there are not many problems to be expected, it is faster to
    check a bunch of files and fix the problematic 5% than re-check
    over and over again the non-problematic ones after each error found.
    
    Change-Id: Iec5a2aa96ac557c0247ae2f06eb710daa75cc19b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117756
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/bin/find-unneeded-includes b/bin/find-unneeded-includes
index 4f90ab55e9f5..fbda1007adfd 100755
--- a/bin/find-unneeded-includes
+++ b/bin/find-unneeded-includes
@@ -27,6 +27,7 @@ import subprocess
 import sys
 import threading
 import yaml
+import argparse
 
 
 def ignoreRemoval(include, toAdd, absFileName, moduleRules):
@@ -212,7 +213,7 @@ def processIWYUOutput(iwyuOutput, moduleRules, fileName):
     return len(toRemove)
 
 
-def run_tool(task_queue, failed_files):
+def run_tool(task_queue, failed_files, dontstop):
     while True:
         invocation, moduleRules = task_queue.get()
         if not len(failed_files):
@@ -223,7 +224,8 @@ def run_tool(task_queue, failed_files):
                 print("ERROR: A file is probably not self contained, check 
this commands output:\n" + invocation)
             elif retcode > 0:
                 print("ERROR: The following command found unused includes:\n" 
+ invocation)
-                failed_files.append(invocation)
+                if not dontstop:
+                    failed_files.append(invocation)
         task_queue.task_done()
 
 
@@ -240,14 +242,15 @@ def isInUnoIncludeFile(path):
             or path.startswith("include/uno/")
 
 
-def tidy(compileCommands, paths):
+def tidy(compileCommands, paths, dontstop):
     return_code = 0
+
     try:
         max_task = multiprocessing.cpu_count()
         task_queue = queue.Queue(max_task)
         failed_files = []
         for _ in range(max_task):
-            t = threading.Thread(target=run_tool, args=(task_queue, 
failed_files))
+            t = threading.Thread(target=run_tool, args=(task_queue, 
failed_files, dontstop))
             t.daemon = True
             t.start()
 
@@ -300,8 +303,16 @@ def tidy(compileCommands, paths):
 
 
 def main(argv):
+    parser = argparse.ArgumentParser(description='Check source files for 
unneeded includes.')
+    parser.add_argument('--dontstop', action='store_true',
+                    help='Don\'t stop on errors. Useful for periodic re-check 
of large amount of files')
+    parser.add_argument('Files' , nargs='*',
+                    help='The files to be checked')
+
+    args = parser.parse_args()
+
     if not len(argv):
-        print("usage: find-unneeded-includes [FILE]...")
+        parser.print_help()
         return
 
     try:
@@ -311,7 +322,7 @@ def main(argv):
         print ("File 'compile_commands.json' does not exist, please run:\nmake 
vim-ide-integration")
         sys.exit(-1)
 
-    tidy(compileCommands, paths=argv)
+    tidy(compileCommands, paths=args.Files, dontstop=args.dontstop)
 
 if __name__ == '__main__':
     main(sys.argv[1:])
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to