浏览代码

cmMakefile: Add API for elseif to create backtrace.

Stephen Kelly 10 年之前
父节点
当前提交
b68f2ea8ae
共有 3 个文件被更改,包括 17 次插入5 次删除
  1. 2 5
      Source/cmIfCommand.cxx
  2. 14 0
      Source/cmMakefile.cxx
  3. 1 0
      Source/cmMakefile.h

+ 2 - 5
Source/cmIfCommand.cxx

@@ -92,10 +92,6 @@ IsFunctionBlocked(const cmListFileFunction& lff,
             }
             }
           else
           else
             {
             {
-            // Place this call on the call stack.
-            cmMakefileCall stack_manager(&mf, this->Functions[c], status);
-            static_cast<void>(stack_manager);
-
             // if trace is enabled, print the evaluated "elseif" statement
             // if trace is enabled, print the evaluated "elseif" statement
             if(mf.GetCMakeInstance()->GetTrace())
             if(mf.GetCMakeInstance()->GetTrace())
               {
               {
@@ -119,7 +115,8 @@ IsFunctionBlocked(const cmListFileFunction& lff,
               {
               {
               std::string err = cmIfCommandError(expandedArguments);
               std::string err = cmIfCommandError(expandedArguments);
               err += errorString;
               err += errorString;
-              mf.IssueMessage(messType, err);
+              cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
+              mf.GetCMakeInstance()->IssueMessage(messType, err, bt);
               if (messType == cmake::FATAL_ERROR)
               if (messType == cmake::FATAL_ERROR)
                 {
                 {
                 cmSystemTools::SetFatalErrorOccured();
                 cmSystemTools::SetFatalErrorOccured();

+ 14 - 0
Source/cmMakefile.cxx

@@ -286,6 +286,20 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const
   return backtrace;
   return backtrace;
 }
 }
 
 
+//----------------------------------------------------------------------------
+cmListFileBacktrace
+cmMakefile::GetBacktrace(cmListFileContext const& lfc) const
+{
+  cmListFileBacktrace backtrace(this->GetLocalGenerator());
+  backtrace.Append(lfc);
+  for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin();
+      i != this->CallStack.rend(); ++i)
+    {
+    backtrace.Append(*i->Context);
+    }
+  return backtrace;
+}
+
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
 cmListFileContext cmMakefile::GetExecutionContext() const
 cmListFileContext cmMakefile::GetExecutionContext() const
 {
 {

+ 1 - 0
Source/cmMakefile.h

@@ -572,6 +572,7 @@ public:
    * Get the current context backtrace.
    * Get the current context backtrace.
    */
    */
   cmListFileBacktrace GetBacktrace() const;
   cmListFileBacktrace GetBacktrace() const;
+  cmListFileBacktrace GetBacktrace(cmListFileContext const& lfc) const;
   cmListFileContext GetExecutionContext() const;
   cmListFileContext GetExecutionContext() const;
 
 
   /**
   /**