[cmake-commits] david.cole committed cmCallVisualStudioMacro.cxx 1.2 1.3 cmGlobalVisualStudio71Generator.cxx 1.47 1.48 cmGlobalVisualStudio71Generator.h 1.17 1.18 cmGlobalVisualStudio8Generator.cxx 1.34 1.35 cmGlobalVisualStudio8Generator.h 1.12 1.13 cmGlobalVisualStudio9Generator.cxx 1.5 1.6 cmGlobalVisualStudio9Generator.h 1.3 1.4 cmGlobalVisualStudioGenerator.cxx 1.10 1.11 cmGlobalVisualStudioGenerator.h 1.6 1.7

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Feb 15 11:50:00 EST 2008


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

Modified Files:
	cmCallVisualStudioMacro.cxx 
	cmGlobalVisualStudio71Generator.cxx 
	cmGlobalVisualStudio71Generator.h 
	cmGlobalVisualStudio8Generator.cxx 
	cmGlobalVisualStudio8Generator.h 
	cmGlobalVisualStudio9Generator.cxx 
	cmGlobalVisualStudio9Generator.h 
	cmGlobalVisualStudioGenerator.cxx 
	cmGlobalVisualStudioGenerator.h 
Log Message:
ENH: Add code to support calling the VS reload macro from Visual Studio 7.1 and 9.0 in addition to 8.0 sp1... Make new macros file with VS 7.1 so that it can be read by 7.1 and later. VS 7.1 does not appear to run the macros while a build is in progress, but does not return any errors either, so for now, the reload macro is not called when using 7.1. If I can figure out how to get 7.1 to execute the macro, I will uncomment the code in cmGlobalVisualStudio71Generator::GetUserMacrosDirectory() to activate executing the macros in VS 7.1, too.


Index: cmGlobalVisualStudio8Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cmGlobalVisualStudio8Generator.h	21 Dec 2007 20:04:06 -0000	1.12
+++ cmGlobalVisualStudio8Generator.h	15 Feb 2008 16:49:58 -0000	1.13
@@ -57,6 +57,12 @@
    */
   virtual std::string GetUserMacrosDirectory();
 
+  /**
+   * What is the reg key path to "vsmacros" for this version of Visual
+   * Studio?
+   */
+  virtual std::string GetUserMacrosRegKeyBase();
+
 protected:
 
   virtual bool VSLinksDependencies() const { return false; }

Index: cmGlobalVisualStudio8Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.cxx,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- cmGlobalVisualStudio8Generator.cxx	28 Jan 2008 13:38:35 -0000	1.34
+++ cmGlobalVisualStudio8Generator.cxx	15 Feb 2008 16:49:58 -0000	1.35
@@ -20,8 +20,7 @@
 #include "cmMakefile.h"
 #include "cmake.h"
 
-
-
+//----------------------------------------------------------------------------
 cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
 {
   this->FindMakeProgramFile = "CMakeVS8FindMake.cmake";
@@ -29,8 +28,7 @@
   this->PlatformName = "Win32";
 }
 
-
-
+//----------------------------------------------------------------------------
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator()
 {
@@ -40,8 +38,8 @@
   lg->SetGlobalGenerator(this);
   return lg;
 }
-
   
+//----------------------------------------------------------------------------
 // ouput standard header for dsw file
 void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout)
 {
@@ -100,12 +98,6 @@
     {
     cmSystemTools::ConvertToUnixSlashes(base);
 
-    // 7.0 macros folder:
-    //path = base + "/VSMacros";
-
-    // 7.1 macros folder:
-    //path = base + "/VSMacros71";
-
     // 8.0 macros folder:
     path = base + "/VSMacros80";
     }
@@ -116,6 +108,12 @@
 }
 
 //----------------------------------------------------------------------------
+std::string cmGlobalVisualStudio8Generator::GetUserMacrosRegKeyBase()
+{
+  return "Software\\Microsoft\\VisualStudio\\8.0\\vsmacros";
+}
+
+//----------------------------------------------------------------------------
 void cmGlobalVisualStudio8Generator::Generate()
 {
   // Add a special target on which all other targets depend that

Index: cmGlobalVisualStudio71Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio71Generator.cxx,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- cmGlobalVisualStudio71Generator.cxx	30 Jan 2008 17:04:38 -0000	1.47
+++ cmGlobalVisualStudio71Generator.cxx	15 Feb 2008 16:49:58 -0000	1.48
@@ -20,16 +20,14 @@
 #include "cmMakefile.h"
 #include "cmake.h"
 
-
-
+//----------------------------------------------------------------------------
 cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator()
 {
   this->FindMakeProgramFile = "CMakeVS71FindMake.cmake";
   this->ProjectConfigurationSectionName = "ProjectConfiguration";
 }
 
-
-
+//----------------------------------------------------------------------------
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator()
 {
@@ -40,12 +38,66 @@
   return lg;
 }
 
+//----------------------------------------------------------------------------
 void cmGlobalVisualStudio71Generator::AddPlatformDefinitions(cmMakefile* mf)
 {
   mf->AddDefinition("MSVC71", "1");
 }
 
+//----------------------------------------------------------------------------
+std::string cmGlobalVisualStudio71Generator::GetUserMacrosDirectory()
+{
+  // Macros not supported on Visual Studio 7.1 and earlier because
+  // they do not appear to work *during* a build when called by an
+  // outside agent...
+  //
+  return "";
+
+#if 0
+  //
+  // The COM result from calling a Visual Studio macro with 7.1 indicates
+  // that the call succeeds, but the macro does not appear to execute...
+  //
+  // So, I am leaving this code here to show how to do it, but have not
+  // yet figured out what the issue is in terms of why the macro does not
+  // appear to execute...
+  //
+  std::string base;
+  std::string path;
+
+  // base begins with the VisualStudioProjectsLocation reg value...
+  if (cmSystemTools::ReadRegistryValue(
+    "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\7.1;"
+    "VisualStudioProjectsLocation",
+    base))
+    {
+    cmSystemTools::ConvertToUnixSlashes(base);
 
+    // 7.1 macros folder:
+    path = base + "/VSMacros71";
+    }
+
+  // path is (correctly) still empty if we did not read the base value from
+  // the Registry value
+  return path;
+#endif
+}
+
+//----------------------------------------------------------------------------
+std::string cmGlobalVisualStudio71Generator::GetUserMacrosRegKeyBase()
+{
+  // Macros not supported on Visual Studio 7.1 and earlier because
+  // they do not appear to work *during* a build when called by an
+  // outside agent...
+  //
+  return "";
+
+#if 0
+  return "Software\\Microsoft\\VisualStudio\\7.1\\vsmacros";
+#endif
+}
+
+//----------------------------------------------------------------------------
 void cmGlobalVisualStudio71Generator
 ::WriteSLNFile(std::ostream& fout,
                cmLocalGenerator* root,
@@ -77,7 +129,7 @@
   this->WriteSLNFooter(fout);
 }
 
-
+//----------------------------------------------------------------------------
 void
 cmGlobalVisualStudio71Generator
 ::WriteSolutionConfigurations(std::ostream& fout)
@@ -91,6 +143,7 @@
   fout << "\tEndGlobalSection\n";
 }
 
+//----------------------------------------------------------------------------
 // Write a dsp file into the SLN file,
 // Note, that dependencies from executables to 
 // the libraries it uses are also done here
@@ -112,8 +165,7 @@
   fout <<"EndProject\n";
 }
 
-
-
+//----------------------------------------------------------------------------
 // Write a dsp file into the SLN file,
 // Note, that dependencies from executables to 
 // the libraries it uses are also done here
@@ -179,6 +231,7 @@
     }
 }
 
+//----------------------------------------------------------------------------
 // Write a dsp file into the SLN file, Note, that dependencies from
 // executables to the libraries it uses are also done here
 void cmGlobalVisualStudio71Generator
@@ -219,7 +272,7 @@
 
 }
 
-
+//----------------------------------------------------------------------------
 // Write a dsp file into the SLN file, Note, that dependencies from
 // executables to the libraries it uses are also done here
 void cmGlobalVisualStudio71Generator
@@ -240,9 +293,7 @@
     }
 }
 
-
-
-
+//----------------------------------------------------------------------------
 // Standard end of dsw file
 void cmGlobalVisualStudio71Generator::WriteSLNFooter(std::ostream& fout)
 {
@@ -253,7 +304,7 @@
        << "EndGlobal\n";
 }
 
-  
+//----------------------------------------------------------------------------
 // ouput standard header for dsw file
 void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout)
 {

Index: cmGlobalVisualStudio71Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio71Generator.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- cmGlobalVisualStudio71Generator.h	30 Jan 2008 17:04:38 -0000	1.17
+++ cmGlobalVisualStudio71Generator.h	15 Feb 2008 16:49:58 -0000	1.18
@@ -43,6 +43,19 @@
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
 
+  /**
+   * Where does this version of Visual Studio look for macros for the
+   * current user? Returns the empty string if this version of Visual
+   * Studio does not implement support for VB macros.
+   */
+  virtual std::string GetUserMacrosDirectory();
+
+  /**
+   * What is the reg key path to "vsmacros" for this version of Visual
+   * Studio?
+   */
+  virtual std::string GetUserMacrosRegKeyBase();
+
 protected:
   virtual void AddPlatformDefinitions(cmMakefile* mf);
   virtual void WriteSLNFile(std::ostream& fout, 

Index: cmGlobalVisualStudioGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudioGenerator.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmGlobalVisualStudioGenerator.h	21 Dec 2007 20:04:06 -0000	1.6
+++ cmGlobalVisualStudioGenerator.h	15 Feb 2008 16:49:58 -0000	1.7
@@ -49,6 +49,12 @@
    */
   virtual std::string GetUserMacrosDirectory();
 
+  /**
+   * What is the reg key path to "vsmacros" for this version of Visual
+   * Studio?
+   */
+  virtual std::string GetUserMacrosRegKeyBase();
+
   enum MacroName {MacroReload, MacroStop};
 
   /**

Index: cmGlobalVisualStudio9Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio9Generator.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmGlobalVisualStudio9Generator.cxx	18 Jan 2008 19:34:48 -0000	1.5
+++ cmGlobalVisualStudio9Generator.cxx	15 Feb 2008 16:49:58 -0000	1.6
@@ -33,6 +33,7 @@
   mf->AddDefinition("MSVC90", "1");
 }
 
+//----------------------------------------------------------------------------
 void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
 {
   fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
@@ -92,3 +93,9 @@
   // the Registry value
   return path;
 }
+
+//----------------------------------------------------------------------------
+std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
+{
+  return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
+}

Index: cmCallVisualStudioMacro.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCallVisualStudioMacro.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmCallVisualStudioMacro.cxx	20 Nov 2007 16:10:11 -0000	1.2
+++ cmCallVisualStudioMacro.cxx	15 Feb 2008 16:49:58 -0000	1.3
@@ -94,7 +94,41 @@
 
       hr = vsIDE->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
         DISPATCH_METHOD, &params, &result, &excep, &arg);
-      ReportHRESULT(hr, "Invoke(ExecuteCommand)");
+
+      std::ostringstream oss;
+      oss << std::endl;
+      oss << "Invoke(ExecuteCommand)" << std::endl;
+      oss << "  Macro: " << macro.c_str() << std::endl;
+      oss << "  Args: " << args.c_str() << std::endl;
+
+      if (DISP_E_EXCEPTION == hr)
+        {
+        oss << "DISP_E_EXCEPTION EXCEPINFO:" << excep.wCode << std::endl;
+        oss << "  wCode: " << excep.wCode << std::endl;
+        oss << "  wReserved: " << excep.wReserved << std::endl;
+        if (excep.bstrSource)
+          {
+          oss << "  bstrSource: " <<
+            (const char*)(_bstr_t)excep.bstrSource << std::endl;
+          }
+        if (excep.bstrDescription)
+          {
+          oss << "  bstrDescription: " <<
+            (const char*)(_bstr_t)excep.bstrDescription << std::endl;
+          }
+        if (excep.bstrHelpFile)
+          {
+          oss << "  bstrHelpFile: " <<
+            (const char*)(_bstr_t)excep.bstrHelpFile << std::endl;
+          }
+        oss << "  dwHelpContext: " << excep.dwHelpContext << std::endl;
+        oss << "  pvReserved: " << excep.pvReserved << std::endl;
+        oss << "  pfnDeferredFillIn: " << excep.pfnDeferredFillIn << std::endl;
+        oss << "  scode: " << excep.scode << std::endl;
+        }
+
+      std::string exstr(oss.str());
+      ReportHRESULT(hr, exstr.c_str());
 
       VariantClear(&result);
       }

Index: cmGlobalVisualStudio9Generator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio9Generator.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cmGlobalVisualStudio9Generator.h	18 Jan 2008 19:34:48 -0000	1.3
+++ cmGlobalVisualStudio9Generator.h	15 Feb 2008 16:49:58 -0000	1.4
@@ -59,5 +59,11 @@
    * Studio does not implement support for VB macros.
    */
   virtual std::string GetUserMacrosDirectory();
+
+  /**
+   * What is the reg key path to "vsmacros" for this version of Visual
+   * Studio?
+   */
+  virtual std::string GetUserMacrosRegKeyBase();
 };
 #endif

Index: cmGlobalVisualStudioGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudioGenerator.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cmGlobalVisualStudioGenerator.cxx	28 Jan 2008 13:38:35 -0000	1.10
+++ cmGlobalVisualStudioGenerator.cxx	15 Feb 2008 16:49:58 -0000	1.11
@@ -68,19 +68,21 @@
 
 //----------------------------------------------------------------------------
 bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
+  const std::string& regKeyBase,
   std::string& nextAvailableSubKeyName);
 
-void RegisterVisualStudioMacros(const std::string& macrosFile);
+void RegisterVisualStudioMacros(const std::string& macrosFile,
+  const std::string& regKeyBase);
 
 //----------------------------------------------------------------------------
 #define CMAKE_VSMACROS_FILENAME \
-  "CMakeVSMacros1.vsmacros"
+  "CMakeVSMacros2.vsmacros"
 
 #define CMAKE_VSMACROS_RELOAD_MACRONAME \
-  "Macros.CMakeVSMacros1.Macros.ReloadProjects"
+  "Macros.CMakeVSMacros2.Macros.ReloadProjects"
 
 #define CMAKE_VSMACROS_STOP_MACRONAME \
-  "Macros.CMakeVSMacros1.Macros.StopBuild"
+  "Macros.CMakeVSMacros2.Macros.StopBuild"
 
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
@@ -113,7 +115,7 @@
         }
       }
 
-    RegisterVisualStudioMacros(dst);
+    RegisterVisualStudioMacros(dst, this->GetUserMacrosRegKeyBase());
     }
 }
 
@@ -140,7 +142,8 @@
     std::string macrosFile = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
     std::string nextSubkeyName;
     if (cmSystemTools::FileExists(macrosFile.c_str()) &&
-      IsVisualStudioMacrosFileRegistered(macrosFile, nextSubkeyName)
+      IsVisualStudioMacrosFileRegistered(macrosFile,
+        this->GetUserMacrosRegKeyBase(), nextSubkeyName)
       )
       {
       std::string topLevelSlnName;
@@ -195,6 +198,12 @@
 }
 
 //----------------------------------------------------------------------------
+std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase()
+{
+  return "";
+}
+
+//----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::FixUtilityDepends()
 {
   // Skip for VS versions 8 and above.
@@ -396,6 +405,7 @@
 
 //----------------------------------------------------------------------------
 bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
+  const std::string& regKeyBase,
   std::string& nextAvailableSubKeyName)
 {
   bool macrosRegistered = false;
@@ -413,8 +423,7 @@
   LONG result = ERROR_SUCCESS;
   DWORD index = 0;
 
-  keyname =
-    "Software\\Microsoft\\VisualStudio\\8.0\\vsmacros\\OtherProjects7";
+  keyname = regKeyBase + "\\OtherProjects7";
   hkey = NULL;
   result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(),
                         0, KEY_READ, &hkey);
@@ -517,8 +526,7 @@
   nextAvailableSubKeyName = ossNext.str();
 
 
-  keyname =
-    "Software\\Microsoft\\VisualStudio\\8.0\\vsmacros\\RecordingProject7";
+  keyname = regKeyBase + "\\RecordingProject7";
   hkey = NULL;
   result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(),
                         0, KEY_READ, &hkey);
@@ -567,10 +575,10 @@
 //----------------------------------------------------------------------------
 void WriteVSMacrosFileRegistryEntry(
   const std::string& nextAvailableSubKeyName,
-  const std::string& macrosFile)
+  const std::string& macrosFile,
+  const std::string& regKeyBase)
 {
-  std::string keyname =
-    "Software\\Microsoft\\VisualStudio\\8.0\\vsmacros\\OtherProjects7";
+  std::string keyname = regKeyBase + "\\OtherProjects7";
   HKEY hkey = NULL;
   LONG result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), 0,
     KEY_READ|KEY_WRITE, &hkey);
@@ -634,13 +642,14 @@
 }
 
 //----------------------------------------------------------------------------
-void RegisterVisualStudioMacros(const std::string& macrosFile)
+void RegisterVisualStudioMacros(const std::string& macrosFile,
+  const std::string& regKeyBase)
 {
   bool macrosRegistered;
   std::string nextAvailableSubKeyName;
 
   macrosRegistered = IsVisualStudioMacrosFileRegistered(macrosFile,
-    nextAvailableSubKeyName);
+    regKeyBase, nextAvailableSubKeyName);
 
   if (!macrosRegistered)
     {
@@ -681,7 +690,7 @@
       //
       if (0 == count)
         {
-        IsVisualStudioMacrosFileRegistered(macrosFile,
+        IsVisualStudioMacrosFileRegistered(macrosFile, regKeyBase,
           nextAvailableSubKeyName);
         }
       }
@@ -690,7 +699,8 @@
     //
     if (0 == count)
       {
-      WriteVSMacrosFileRegistryEntry(nextAvailableSubKeyName, macrosFile);
+      WriteVSMacrosFileRegistryEntry(nextAvailableSubKeyName, macrosFile,
+        regKeyBase);
       }
     }
 }



More information about the Cmake-commits mailing list