Fix the case where the number of jobs is less than the
authorDavid Greene <greened@obbligato.org>
Fri, 4 Mar 2011 23:02:52 +0000 (23:02 +0000)
committerDavid Greene <greened@obbligato.org>
Fri, 4 Mar 2011 23:02:52 +0000 (23:02 +0000)
number of threads.  In that case make the number of threads
equal to the number of jobs and launch one jobs on each
thread.  This makes things work like make -j.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127045 91177308-0d34-0410-b5e6-96231b3b80d8

utils/llvmbuild

index fb8500d38efe577bc5ef254aa78a1bb840f0fe6c..5912c50ddfeb0c39fb6e317bfc0e7e1d8372ae84 100755 (executable)
@@ -650,7 +650,8 @@ class Builder(threading.Thread):
 
 
     def configure(self, component, srcdir, builddir, flags, env):
-        self.logger.debug("Configure " + str(flags))
+        self.logger.debug("Configure " + str(flags) + " " + str(srcdir) + " -> "
+                          + str(builddir))
 
         configure_files = dict(
             llvm=[(srcdir + "/configure", builddir + "/Makefile")],
@@ -721,8 +722,16 @@ branch_abbrev = get_path_abbrevs(set(options.branch))
 
 work_queue = queue.Queue()
 
-for t in range(options.threads):
-    jobs = options.jobs // options.threads
+jobs = options.jobs // options.threads
+if jobs == 0:
+    jobs = 1
+
+numthreads = options.threads
+if jobs < numthreads:
+    numthreads = jobs
+    jobs = 1
+
+for t in range(numthreads):
     builder = Builder(work_queue, jobs,
                       build_abbrev, source_abbrev, branch_abbrev,
                       options)