Browse Source

ENH: Even better. Only replace when path longer than 20 characters. Also replace parent directory. That way it will replace for related projects.

Andy Cedilnik 22 years ago
parent
commit
dad738eab1
1 changed files with 25 additions and 22 deletions
  1. 25 22
      Source/cmCTest.cxx

+ 25 - 22
Source/cmCTest.cxx

@@ -1016,34 +1016,37 @@ int cmCTest::BuildDirectory()
     }
 
   int cc;
-  std::string srcdir = m_DartConfiguration["SourceDirectory"] + "/";
-  std::string bindir = m_DartConfiguration["BuildDirectory"] + "/";
-  std::string srcdirrep;
-  std::string bindirrep;
-  for ( cc = srcdir.size()-2; cc > 0; cc -- )
+  if ( m_DartConfiguration["SourceDirectory"].size() > 20 ||
+    m_DartConfiguration["BuildDirectory"].size() > 20 )
     {
-    if ( srcdir[cc] == '/' )
+    std::string srcdir = m_DartConfiguration["SourceDirectory"] + "/";
+    std::string bindir = m_DartConfiguration["BuildDirectory"] + "/";
+    std::string srcdirrep;
+    std::string bindirrep;
+    for ( cc = srcdir.size()-2; cc > 0; cc -- )
       {
-      srcdirrep = srcdir.c_str() + cc;
-      srcdirrep = "/..." + srcdirrep;
-      break;
+      if ( srcdir[cc] == '/' )
+        {
+        srcdirrep = srcdir.c_str() + cc;
+        srcdirrep = "/..." + srcdirrep;
+        srcdir = srcdir.substr(0, cc+1);
+        break;
+        }
       }
-    }
-  for ( cc = bindir.size()-2; cc > 0; cc -- )
-    {
-    if ( bindir[cc] == '/' )
+    for ( cc = bindir.size()-2; cc > 0; cc -- )
       {
-      bindirrep = bindir.c_str() + cc;
-      bindirrep = "/..." + bindirrep;
-      break;
+      if ( bindir[cc] == '/' )
+        {
+        bindirrep = bindir.c_str() + cc;
+        bindirrep = "/..." + bindirrep;
+        bindir = bindir.substr(0, cc+1);
+        break;
+        }
       }
-    }
 
-  //std::cout << "Use " << srcdirrep.c_str() << std::endl;
-  //std::cout << "Use " << bindirrep.c_str() << std::endl;
-
-  cmSystemTools::ReplaceString(output, srcdir.c_str(), srcdirrep.c_str());
-  cmSystemTools::ReplaceString(output, bindir.c_str(), bindirrep.c_str());
+    cmSystemTools::ReplaceString(output, srcdir.c_str(), "/.../"); //srcdirrep.c_str());
+    cmSystemTools::ReplaceString(output, bindir.c_str(), "/.../"); //bindirrep.c_str());
+    }
 
   // Parsing of output for errors and warnings.