1
0
Эх сурвалжийг харах

BUG: fix for bug 1717 incorrect path sent to dart server

Bill Hoffman 20 жил өмнө
parent
commit
fadff33791

+ 23 - 1
Source/CTest/cmCTestBuildHandler.cxx

@@ -463,7 +463,11 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
   // only report the first 50 warnings and first 50 errors
   unsigned short numErrorsAllowed = 50;
   unsigned short numWarningsAllowed = 50;
-
+  std::string srcdir = m_CTest->GetDartConfiguration("SourceDirectory");
+  // make sure the source dir is in the correct case on windows
+  // via a call to collapse full path.
+  srcdir = cmSystemTools::CollapseFullPath(srcdir.c_str());
+  srcdir += "/";
   for ( it = ew.begin(); 
         it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ )
     {
@@ -491,6 +495,24 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
         if ( re->find(cm->m_Text.c_str() ) )
           {
           cm->m_SourceFile = re->match(rit->m_FileIndex);
+          // At this point we need to make m_SourceFile relative to 
+          // the source root of the project, so cvs links will work
+          cmSystemTools::ConvertToUnixSlashes(cm->m_SourceFile);
+          if(cm->m_SourceFile.find("/.../") != cm->m_SourceFile.npos)
+            {
+            cmSystemTools::ReplaceString(cm->m_SourceFile, "/.../", "");
+            std::string::size_type p = cm->m_SourceFile.find("/");
+            if(p != cm->m_SourceFile.npos)
+              {
+              cm->m_SourceFile = cm->m_SourceFile.substr(p+1, cm->m_SourceFile.size()-p);
+              }
+            }
+          else
+            {
+            // make sure it is a full path with the correct case
+            cm->m_SourceFile = cmSystemTools::CollapseFullPath(cm->m_SourceFile.c_str());
+            cmSystemTools::ReplaceString(cm->m_SourceFile, srcdir.c_str(), "");
+            }
           cm->m_LineNumber = atoi(re->match(rit->m_LineIndex).c_str());
           break;
           }

+ 20 - 0
Source/kwsys/SystemTools.cxx

@@ -2228,10 +2228,30 @@ kwsys_stl::string SystemTools::CollapseFullPath(const char* in_path,
   // Update the translation table with this potentially new path.
   SystemTools::AddTranslationPath(newPath.c_str(), in_path);
   SystemTools::CheckTranslationPath(newPath);
+#ifdef _WIN32
+  newPath = SystemTools::GetActualCaseForPath(newPath.c_str());
+#endif
   // Return the reconstructed path.
   return newPath;
 }
 
+//----------------------------------------------------------------------------
+kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p)
+{
+#ifndef _WIN32
+  return p;
+#else
+  std::string path;
+  if(!SystemTools::GetShortPath(p, path))
+    {
+    return path;
+    }
+  char buffer[MAX_PATH+1];
+  ::GetLongPathName(path.c_str(), buffer, MAX_PATH+1);
+  return buffer;
+#endif  
+}
+
 //----------------------------------------------------------------------------
 void SystemTools::SplitPath(const char* p,
                             kwsys_stl::vector<kwsys_stl::string>& components)

+ 8 - 0
Source/kwsys/SystemTools.hxx.in

@@ -241,6 +241,14 @@ public:
    */
   static const char* GetExecutableExtension();
 
+  /**
+   *  Given a path that exists on a windows machine, return the
+   *  actuall case of the path as it was created.  If the file
+   *  does not exist path is returned unchanged.  This does nothing
+   *  on unix but return path.
+   */
+  static kwsys_stl::string GetActualCaseForPath(const char* path);
+
   /**
    * Given the path to a program executable, get the directory part of
    * the path with the file stripped off.  If there is no directory