瀏覽代碼

cmListFileBacktrace: Internalize the step of making paths relative.

Currently cmMakefile calls MakeRelative on a copy of the backtrace,
emits the copy to the stream once, then discards the copy.  There
is no need to have API for the path conversion.
Stephen Kelly 10 年之前
父節點
當前提交
499ebb6564
共有 3 個文件被更改,包括 8 次插入23 次删除
  1. 8 18
      Source/cmListFileCache.cxx
  2. 0 4
      Source/cmListFileCache.h
  3. 0 1
      Source/cmake.cxx

+ 8 - 18
Source/cmListFileCache.cxx

@@ -405,29 +405,17 @@ void cmListFileBacktrace::Append(cmListFileContext const& context)
   this->push_back(context);
   this->push_back(context);
 }
 }
 
 
-//----------------------------------------------------------------------------
-void cmListFileBacktrace::MakeRelative()
-{
-  if (this->Relative)
-    {
-    return;
-    }
-  for (cmListFileBacktrace::iterator i = this->begin();
-       i != this->end(); ++i)
-    {
-    i->FilePath = this->LocalGenerator->Convert(i->FilePath,
-                                                cmLocalGenerator::HOME);
-    }
-  this->Relative = true;
-}
-
 void cmListFileBacktrace::PrintTitle(std::ostream& out)
 void cmListFileBacktrace::PrintTitle(std::ostream& out)
 {
 {
   if (this->empty())
   if (this->empty())
     {
     {
     return;
     return;
     }
     }
-  out << (this->front().Line ? " at " : " in ") << this->front();
+
+  cmListFileContext lfc = this->front();
+  lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
+                                               cmLocalGenerator::HOME);
+  out << (lfc.Line ? " at " : " in ") << lfc;
 }
 }
 
 
 void cmListFileBacktrace::PrintCallStack(std::ostream& out)
 void cmListFileBacktrace::PrintCallStack(std::ostream& out)
@@ -441,7 +429,9 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out)
   out << "Call Stack (most recent call first):\n";
   out << "Call Stack (most recent call first):\n";
   while(i != this->end())
   while(i != this->end())
     {
     {
-    cmListFileContext const& lfc = *i;
+    cmListFileContext lfc = *i;
+    lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
+                                                 cmLocalGenerator::HOME);
     out << "  " << lfc << "\n";
     out << "  " << lfc << "\n";
     ++i;
     ++i;
     }
     }

+ 0 - 4
Source/cmListFileCache.h

@@ -76,19 +76,15 @@ class cmListFileBacktrace: private std::vector<cmListFileContext>
   public:
   public:
     cmListFileBacktrace(cmLocalGenerator* localGen = 0)
     cmListFileBacktrace(cmLocalGenerator* localGen = 0)
       : LocalGenerator(localGen)
       : LocalGenerator(localGen)
-      , Relative(localGen ? false : true)
     {
     {
     }
     }
 
 
     void Append(cmListFileContext const& context);
     void Append(cmListFileContext const& context);
 
 
-    void MakeRelative();
-
     void PrintTitle(std::ostream& out);
     void PrintTitle(std::ostream& out);
     void PrintCallStack(std::ostream& out);
     void PrintCallStack(std::ostream& out);
   private:
   private:
     cmLocalGenerator* LocalGenerator;
     cmLocalGenerator* LocalGenerator;
-    bool Relative;
 };
 };
 
 
 struct cmListFile
 struct cmListFile

+ 0 - 1
Source/cmake.cxx

@@ -2519,7 +2519,6 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
                          cmListFileBacktrace const& bt)
                          cmListFileBacktrace const& bt)
 {
 {
   cmListFileBacktrace backtrace = bt;
   cmListFileBacktrace backtrace = bt;
-  backtrace.MakeRelative();
 
 
   std::ostringstream msg;
   std::ostringstream msg;
   if (!this->PrintMessagePreamble(t, msg))
   if (!this->PrintMessagePreamble(t, msg))