[cmake-commits] hoffman committed cmLocalVisualStudio7Generator.h 1.28 1.29 cmLocalVisualStudio7Generator.cxx 1.158 1.159

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Jan 31 13:34:20 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv19312

Modified Files:
	cmLocalVisualStudio7Generator.h 
	cmLocalVisualStudio7Generator.cxx 
Log Message:
BUG: make sure external vs projects use the GUID in the project if it has one.


Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -d -r1.158 -r1.159
--- cmLocalVisualStudio7Generator.cxx	15 Jan 2007 17:12:56 -0000	1.158
+++ cmLocalVisualStudio7Generator.cxx	31 Jan 2007 18:34:18 -0000	1.159
@@ -16,6 +16,8 @@
 =========================================================================*/
 #include "cmGlobalVisualStudio7Generator.h"
 #include "cmLocalVisualStudio7Generator.h"
+#include "cmXMLParser.h"
+#include <cm_expat.h>
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
 #include "cmSourceFile.h"
@@ -1637,6 +1639,84 @@
   return ret;
 }
 
+
+// This class is used to parse an existing vs 7 project
+// and extract the GUID 
+class cmVS7XMLParser : public cmXMLParser
+{
+public:
+  virtual void EndElement(const char* name)
+    {
+    }
+  virtual void StartElement(const char* name, const char** atts)
+    {
+      // once the GUID is found do nothing
+      if(this->GUID.size())
+        {
+        return;
+        }
+      int i =0;
+      if(strcmp("VisualStudioProject", name) == 0)
+        {
+        while(atts[i])
+          {
+          if(strcmp(atts[i], "ProjectGUID") == 0)
+            { 
+            if(atts[i+1])
+              {
+              this->GUID =  atts[i+1];
+              this->GUID = this->GUID.substr(1, this->GUID.size()-2);
+              }
+            else
+              {
+              this->GUID = "";
+              }
+            return;
+            }
+          ++i;
+          }
+        } 
+    }
+  int InitializeParser()
+    {
+      int ret = cmXMLParser::InitializeParser();
+      if(ret == 0)
+        {
+        return ret;
+        }
+      // visual studio projects have a strange encoding, but it is 
+      // really utf-8
+      XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
+      return 1;
+    }
+  std::string GUID;
+};
+
+void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
+  const char* name,
+  const char* path)
+{
+  cmVS7XMLParser parser;
+  parser.ParseFile(path);
+  // if we can not find a GUID then create one
+  if(parser.GUID.size() == 0)
+    {
+    cmGlobalVisualStudio7Generator* gg =
+      static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
+    gg->CreateGUID(name);
+    return;
+    }
+  std::string guidStoreName = name;
+  guidStoreName += "_GUID_CMAKE";
+  // save the GUID in the cache
+  this->GlobalGenerator->GetCMakeInstance()->
+    AddCacheEntry(guidStoreName.c_str(),
+                  parser.GUID.c_str(),
+                  "Stored GUID",
+                  cmCacheManager::INTERNAL);
+}
+
+
 void cmLocalVisualStudio7Generator::ConfigureFinalPass()
 {
   cmLocalGenerator::ConfigureFinalPass();
@@ -1651,7 +1731,7 @@
       cmCustomCommand cc = l->second.GetPostBuildCommands()[0];
       const cmCustomCommandLines& cmds = cc.GetCommandLines();
       std::string project_name = cmds[0][0];
-      gg->CreateGUID(project_name.c_str());
+      this->ReadAndStoreExternalGUID(project_name.c_str(), cmds[0][1].c_str());
       }
     else
       {

Index: cmLocalVisualStudio7Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- cmLocalVisualStudio7Generator.h	12 Jan 2007 02:02:47 -0000	1.28
+++ cmLocalVisualStudio7Generator.h	31 Jan 2007 18:34:18 -0000	1.29
@@ -65,6 +65,8 @@
   void SetPlatformName(const char* n) { this->PlatformName = n;}
   virtual void ConfigureFinalPass();
 private:
+  void ReadAndStoreExternalGUID(const char* name,
+                                const char* path);
   void ReplaceFlagSetMap(std::string& flags, 
                          cmVS7FlagTable* flagTable,
                          std::map<cmStdString, 



More information about the Cmake-commits mailing list