[Cmake-commits] CMake branch, next, updated. v3.8.0-rc4-689-gc634476

Kitware Robot kwrobot at kitware.com
Wed Apr 5 10:35:02 EDT 2017


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  c6344769be9302414d662ad26f398abcb12d7dd0 (commit)
       via  333ff168eb04e12d5d118a2e9cf50d600c508db5 (commit)
       via  3ecbe76e60293275b7d6753d551fb003fceb2cab (commit)
       via  8243fe7c46075c1e310f9ad761b9906b0fb4400b (commit)
      from  d9bd7adfdfa0e06ec77507933664f7ae344dcf1a (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 -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c6344769be9302414d662ad26f398abcb12d7dd0
commit c6344769be9302414d662ad26f398abcb12d7dd0
Merge: 333ff16 8243fe7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Apr 5 14:31:04 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Apr 5 10:31:07 2017 -0400

    Stage topic 'codelite-virtual-dirs'
    
    Topic-id: 23432
    Topic-url: https://gitlab.kitware.com/cmake/cmake/merge_requests/653


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8243fe7c46075c1e310f9ad761b9906b0fb4400b
commit 8243fe7c46075c1e310f9ad761b9906b0fb4400b
Author:     rahmjan <rahmjan at gmail.com>
AuthorDate: Fri Mar 31 14:27:56 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Mar 31 15:00:59 2017 -0400

    CodeLite: Distribute source files into folders (virtual directories)

diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index fd7da18..856d42e 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -349,6 +349,87 @@ void cmExtraCodeLiteGenerator::FindMatchingHeaderfiles(
   }
 }
 
+void cmExtraCodeLiteGenerator::CreateFoldersAndFiles(
+  std::set<std::string>& cFiles, cmXMLWriter& xml,
+  const std::string& projectPath)
+{
+  std::vector<std::string> tmp_path;
+  std::vector<std::string> components;
+  size_t numOfEndEl = 0;
+
+  for (std::set<std::string>::const_iterator it = cFiles.begin();
+       it != cFiles.end(); ++it) {
+    std::string frelapath =
+      cmSystemTools::RelativePath(projectPath.c_str(), it->c_str());
+    cmsys::SystemTools::SplitPath(frelapath, components, false);
+    components.pop_back(); // erase last member -> it is file, not folder
+    components.erase(components.begin()); // erase "root"
+
+    size_t sizeOfSkip = 0;
+
+    for (size_t i = 0; i < components.size(); ++i) {
+      // skip relative path
+      if (components[i] == ".." || components[i] == ".") {
+        sizeOfSkip++;
+        continue;
+      }
+
+      // same folder
+      if (tmp_path.size() > i - sizeOfSkip &&
+          tmp_path[i - sizeOfSkip] == components[i]) {
+        continue;
+      }
+
+      // delete "old" subfolders
+      if (tmp_path.size() > i - sizeOfSkip) {
+        numOfEndEl = tmp_path.size() - i + sizeOfSkip;
+        tmp_path.erase(tmp_path.end() - numOfEndEl, tmp_path.end());
+        for (; numOfEndEl--;) {
+          xml.EndElement();
+        }
+      }
+
+      // add folder
+      xml.StartElement("VirtualDirectory");
+      xml.Attribute("Name", components[i]);
+      tmp_path.push_back(components[i]);
+    }
+
+    // delete "old" subfolders
+    numOfEndEl = tmp_path.size() - components.size() + sizeOfSkip;
+    if (numOfEndEl) {
+      tmp_path.erase(tmp_path.end() - numOfEndEl, tmp_path.end());
+      for (; numOfEndEl--;) {
+        xml.EndElement();
+      }
+    }
+
+    // add file
+    xml.StartElement("File");
+    xml.Attribute("Name", frelapath);
+    xml.EndElement();
+  }
+
+  // end of folders
+  numOfEndEl = tmp_path.size();
+  for (; numOfEndEl--;) {
+    xml.EndElement();
+  }
+}
+
+void cmExtraCodeLiteGenerator::CreateFoldersAndFiles(
+  std::map<std::string, cmSourceFile*>& cFiles, cmXMLWriter& xml,
+  const std::string& projectPath)
+{
+  std::set<std::string> s;
+  for (std::map<std::string, cmSourceFile*>::const_iterator it =
+         cFiles.begin();
+       it != cFiles.end(); ++it) {
+    s.insert(it->first);
+  }
+  this->CreateFoldersAndFiles(s, xml, projectPath);
+}
+
 void cmExtraCodeLiteGenerator::CreateProjectSourceEntries(
   std::map<std::string, cmSourceFile*>& cFiles,
   std::set<std::string>& otherFiles, cmXMLWriter* _xml,
@@ -366,26 +447,12 @@ void cmExtraCodeLiteGenerator::CreateProjectSourceEntries(
 
   // insert all source files in the codelite project
   // first the C/C++ implementation files, then all others
-  for (std::map<std::string, cmSourceFile*>::const_iterator sit =
-         cFiles.begin();
-       sit != cFiles.end(); ++sit) {
-    xml.StartElement("File");
-    std::string fpath(sit->first);
-    std::string frelapath =
-      cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str());
-    xml.Attribute("Name", frelapath);
-    xml.EndElement();
-  }
+  this->CreateFoldersAndFiles(cFiles, xml, projectPath);
   xml.EndElement(); // VirtualDirectory
+
   xml.StartElement("VirtualDirectory");
   xml.Attribute("Name", "include");
-  for (std::set<std::string>::const_iterator sit = otherFiles.begin();
-       sit != otherFiles.end(); ++sit) {
-    xml.StartElement("File");
-    xml.Attribute(
-      "Name", cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str()));
-    xml.EndElement();
-  }
+  this->CreateFoldersAndFiles(otherFiles, xml, projectPath);
   xml.EndElement(); // VirtualDirectory
 
   // Get the number of CPUs. We use this information for the make -jN
diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h
index 773515d..3263eb6 100644
--- a/Source/cmExtraCodeLiteGenerator.h
+++ b/Source/cmExtraCodeLiteGenerator.h
@@ -50,6 +50,10 @@ protected:
                                   const cmMakefile* mf,
                                   const std::string& projectType,
                                   const std::string& targetName);
+  void CreateFoldersAndFiles(std::set<std::string>& cFiles, cmXMLWriter& xml,
+                             const std::string& projectPath);
+  void CreateFoldersAndFiles(std::map<std::string, cmSourceFile*>& cFiles,
+                             cmXMLWriter& xml, const std::string& projectPath);
 
 public:
   cmExtraCodeLiteGenerator();

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

Summary of changes:
 Help/manual/cmake-generator-expressions.7.rst |    2 +-
 Source/cmExtraCodeLiteGenerator.cxx           |  101 ++++++++++++++++++++-----
 Source/cmExtraCodeLiteGenerator.h             |    4 +
 3 files changed, 89 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list