瀏覽代碼

Merge topic 'cmake-trace-elseif'

b3b095a Print any evaluated 'elseif'/'else' commands in trace mode (#13220)
David Cole 13 年之前
父節點
當前提交
e1c5691a0f
共有 3 個文件被更改,包括 36 次插入12 次删除
  1. 13 0
      Source/cmIfCommand.cxx
  2. 18 12
      Source/cmMakefile.cxx
  3. 5 0
      Source/cmMakefile.h

+ 13 - 0
Source/cmIfCommand.cxx

@@ -74,6 +74,13 @@ IsFunctionBlocked(const cmListFileFunction& lff,
           {
           this->IsBlocking = this->HasRun;
           this->HasRun = true;
+
+          // if trace is enabled, print a (trivially) evaluated "else"
+          // statement
+          if(!this->IsBlocking && mf.GetCMakeInstance()->GetTrace())
+            {
+            mf.PrintCommandTrace(this->Functions[c]);
+            }
           }
         else if (scopeDepth == 0 && !cmSystemTools::Strucmp
                  (this->Functions[c].Name.c_str(),"elseif"))
@@ -88,6 +95,12 @@ IsFunctionBlocked(const cmListFileFunction& lff,
             cmMakefileCall stack_manager(&mf, this->Functions[c], status);
             static_cast<void>(stack_manager);
 
+            // if trace is enabled, print the evaluated "elseif" statement
+            if(mf.GetCMakeInstance()->GetTrace())
+              {
+              mf.PrintCommandTrace(this->Functions[c]);
+              }
+
             std::string errorString;
 
             std::vector<std::string> expandedArguments;

+ 18 - 12
Source/cmMakefile.cxx

@@ -353,6 +353,22 @@ bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const
   return true;
 }
 
+//----------------------------------------------------------------------------
+void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff)
+{
+  cmOStringStream msg;
+  msg << lff.FilePath << "(" << lff.Line << "):  ";
+  msg << lff.Name << "(";
+  for(std::vector<cmListFileArgument>::const_iterator i =
+        lff.Arguments.begin(); i != lff.Arguments.end(); ++i)
+    {
+    msg << i->Value;
+    msg << " ";
+    }
+  msg << ")";
+  cmSystemTools::Message(msg.str().c_str());
+}
+
 //----------------------------------------------------------------------------
 bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
                                 cmExecutionStatus &status)
@@ -385,20 +401,10 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
        || pcmd->IsScriptable()))
 
       {
-      // if trace is one, print out invoke information
+      // if trace is enabled, print out invoke information
       if(this->GetCMakeInstance()->GetTrace())
         {
-        cmOStringStream msg;
-        msg << lff.FilePath << "(" << lff.Line << "):  ";
-        msg << lff.Name << "(";
-        for(std::vector<cmListFileArgument>::const_iterator i =
-              lff.Arguments.begin(); i != lff.Arguments.end(); ++i)
-          {
-          msg << i->Value;
-          msg << " ";
-          }
-        msg << ")";
-        cmSystemTools::Message(msg.str().c_str());
+        this->PrintCommandTrace(lff);
         }
       // Try invoking the command.
       if(!pcmd->InvokeInitialPass(lff.Arguments,status) ||

+ 5 - 0
Source/cmMakefile.h

@@ -700,6 +700,11 @@ public:
                                  std::vector<cmSourceGroup> &groups);
 #endif
 
+  /**
+   * Print a command's invocation
+   */
+  void PrintCommandTrace(const cmListFileFunction& lff);
+
   /**
    * Execute a single CMake command.  Returns true if the command
    * succeeded or false if it failed.