Patch #3342 2012-10-05 17:05

sodev

Honour compile priority during parallel build
Download
3342-Honour_compile.patch (1.5 KB)
Category
Plugin::Bugfix
Status
Accepted
Close date
2012-11-07 09:56
Assigned to
mortenmacfly
Index: src/plugins/compilergcc/directcommands.cpp
===================================================================
--- src/plugins/compilergcc/directcommands.cpp    (revision 8431)
+++ src/plugins/compilergcc/directcommands.cpp    (working copy)
@@ -438,6 +438,8 @@
     size_t counter = ret.GetCount();
     MyFilesArray files = GetProjectFilesSortedByWeight(target, true, false);
     size_t fcount = files.GetCount();
+    bool hasWeight = false;
+    unsigned short int lastWeight = 0;
     for (unsigned int i = 0; i < fcount; ++i)
     {
         ProjectFile* pf = files[i];
@@ -449,9 +451,24 @@
         wxString err;
         if (force || IsObjectOutdated(target, pfd, &err))
         {
+            // Add a wait command if the weight of the current file is different from the previous one
+            // Because GetCompileFileCommand() already adds a wait command if it compiled a PCH we
+            // check the last command to prevent two consecutive wait commands
+            if (hasWeight && lastWeight != pf->weight && (ret.IsEmpty() || ret.Last() != COMPILER_WAIT))
+            {
+                ret.Add(wxString(COMPILER_WAIT));
+            }
+
             // compile file
             wxArrayString filecmd = GetCompileFileCommand(target, pf);
             AppendArray(filecmd, ret);
+
+            // Update the weight
+            if (!hasWeight)
+            {
+                hasWeight = true;
+            }
+            lastWeight = pf->weight;
         }
         else
         {
sodev 2012-10-05 17:06

Ensure that during a parallel build all files of one priority level have been compiled before a file of another priority level gets compiled