[Cmake-commits] CMake branch, next, updated. v2.8.11.1-2869-g43d3695

Brad King brad.king at kitware.com
Mon Jul 1 09:51:29 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  43d36952f6147e8cb72e20570727a9b7ea7a99f5 (commit)
       via  551d3343cd16c566be4b33e96c892c3e769951af (commit)
      from  ca9de4cc7f66f6f2d60fdea90a74b7a0e53ac35a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=43d36952f6147e8cb72e20570727a9b7ea7a99f5
commit 43d36952f6147e8cb72e20570727a9b7ea7a99f5
Merge: ca9de4c 551d334
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Jul 1 09:51:23 2013 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Jul 1 09:51:23 2013 -0400

    Merge topic 'make-depends-collapse-paths' into next
    
    551d334 cmDependsC: Collapse relative include paths


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=551d3343cd16c566be4b33e96c892c3e769951af
commit 551d3343cd16c566be4b33e96c892c3e769951af
Author:     Pavel Shramov <Pavel.Shramov at micex.com>
AuthorDate: Wed Jun 19 16:35:23 2013 +0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jun 26 10:14:31 2013 -0400

    cmDependsC: Collapse relative include paths
    
    While calculating dependencies collapse sequences such as
    
     ../../../a/b/c/../../d/e/../../e/f
    
    to avoid total path lengths over the Windows path length limit as much
    as possible.

diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 43b7b8a..a252a1a 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -193,17 +193,8 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
           // Construct the name of the file as if it were in the current
           // include directory.  Avoid using a leading "./".
 
-          tempPathStr = "";
-          if((*i) == ".")
-            {
-            tempPathStr += current.FileName;
-            }
-          else
-            {
-            tempPathStr += *i;
-            tempPathStr+="/";
-            tempPathStr+=current.FileName;
-            }
+          tempPathStr =
+            cmSystemTools::CollapseCombinedPath(*i, current.FileName);
 
           // Look for the file in this location.
           if(cmSystemTools::FileExists(tempPathStr.c_str(), true))
@@ -458,9 +449,8 @@ void cmDependsC::Scan(std::istream& is, const char* directory,
         // This was a double-quoted include with a relative path.  We
         // must check for the file in the directory containing the
         // file we are scanning.
-        entry.QuotedLocation = directory;
-        entry.QuotedLocation += "/";
-        entry.QuotedLocation += entry.FileName;
+        entry.QuotedLocation =
+          cmSystemTools::CollapseCombinedPath(directory, entry.FileName);
         }
 
       // Queue the file if it has not yet been encountered and it
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 21c361d..f32f2dc 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1594,6 +1594,40 @@ std::string cmSystemTools::RelativePath(const char* local, const char* remote)
   return cmsys::SystemTools::RelativePath(local, remote);
 }
 
+std::string cmSystemTools::CollapseCombinedPath(std::string const& dir,
+                                                std::string const& file)
+{
+  if(dir.empty() || dir == ".")
+    {
+    return file;
+    }
+
+  std::vector<std::string> dirComponents;
+  std::vector<std::string> fileComponents;
+  cmSystemTools::SplitPath(dir.c_str(), dirComponents);
+  cmSystemTools::SplitPath(file.c_str(), fileComponents);
+
+  if(fileComponents.empty())
+    {
+    return dir;
+    }
+  if(fileComponents[0] != "")
+    {
+    // File is not a relative path.
+    return file;
+    }
+
+  std::vector<std::string>::iterator i = fileComponents.begin()+1;
+  while(i != fileComponents.end() && *i == ".." && dirComponents.size() > 1)
+    {
+    ++i; // Remove ".." file component.
+    dirComponents.pop_back(); // Remove last dir component.
+    }
+
+  dirComponents.insert(dirComponents.end(), i, fileComponents.end());
+  return cmSystemTools::JoinPath(dirComponents);
+}
+
 #ifdef CMAKE_BUILD_WITH_CMAKE
 //----------------------------------------------------------------------
 bool cmSystemTools::UnsetEnv(const char* value)
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index ec53929..9614449 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -365,6 +365,12 @@ public:
   */
   static std::string RelativePath(const char* local, const char* remote);
 
+  /** Joins two paths while collapsing x/../ parts
+   * For example CollapseCombinedPath("a/b/c", "../../d") results in "a/d"
+   */
+  static std::string CollapseCombinedPath(std::string const& dir,
+                                          std::string const& file);
+
 #ifdef CMAKE_BUILD_WITH_CMAKE
   /** Remove an environment variable */
   static bool UnsetEnv(const char* value);

-----------------------------------------------------------------------

Summary of changes:
 Source/cmDependsC.cxx    |   18 ++++--------------
 Source/cmSystemTools.cxx |   34 ++++++++++++++++++++++++++++++++++
 Source/cmSystemTools.h   |    6 ++++++
 3 files changed, 44 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list