summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2008-02-15 16:49:58 (GMT)
committerDavid Cole <david.cole@kitware.com>2008-02-15 16:49:58 (GMT)
commitca2a16c0a221bb0c3be4491125c044c9112836e0 (patch)
tree38e2fab8d33aaf4915039dede364d6d34d815744 /Source
parented76198b840b83d49ee4eba9ca0c7753b41d54cf (diff)
downloadCMake-ca2a16c0a221bb0c3be4491125c044c9112836e0.zip
CMake-ca2a16c0a221bb0c3be4491125c044c9112836e0.tar.gz
CMake-ca2a16c0a221bb0c3be4491125c044c9112836e0.tar.bz2
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.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCallVisualStudioMacro.cxx36
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx75
-rw-r--r--Source/cmGlobalVisualStudio71Generator.h13
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx20
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h6
-rw-r--r--Source/cmGlobalVisualStudio9Generator.cxx7
-rw-r--r--Source/cmGlobalVisualStudio9Generator.h6
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx44
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h6
9 files changed, 172 insertions, 41 deletions
diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx
index 8011284..2476631 100644
--- a/Source/cmCallVisualStudioMacro.cxx
+++ b/Source/cmCallVisualStudioMacro.cxx
@@ -94,7 +94,41 @@ HRESULT InstanceCallMacro(
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);
}
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 26a095e..b3abec7 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -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 @@ cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator()
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 @@ void cmGlobalVisualStudio71Generator
this->WriteSLNFooter(fout);
}
-
+//----------------------------------------------------------------------------
void
cmGlobalVisualStudio71Generator
::WriteSolutionConfigurations(std::ostream& fout)
@@ -91,6 +143,7 @@ cmGlobalVisualStudio71Generator
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 @@ cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
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 @@ cmGlobalVisualStudio71Generator
}
}
+//----------------------------------------------------------------------------
// 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 @@ void cmGlobalVisualStudio71Generator
}
-
+//----------------------------------------------------------------------------
// 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 @@ void cmGlobalVisualStudio71Generator
}
}
-
-
-
+//----------------------------------------------------------------------------
// Standard end of dsw file
void cmGlobalVisualStudio71Generator::WriteSLNFooter(std::ostream& fout)
{
@@ -253,7 +304,7 @@ void cmGlobalVisualStudio71Generator::WriteSLNFooter(std::ostream& fout)
<< "EndGlobal\n";
}
-
+//----------------------------------------------------------------------------
// ouput standard header for dsw file
void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout)
{
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index f357c8f..9a2bcdb 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -43,6 +43,19 @@ public:
///! 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,
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 7a39459..52225aa 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -20,8 +20,7 @@
#include "cmMakefile.h"
#include "cmake.h"
-
-
+//----------------------------------------------------------------------------
cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
{
this->FindMakeProgramFile = "CMakeVS8FindMake.cmake";
@@ -29,8 +28,7 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
this->PlatformName = "Win32";
}
-
-
+//----------------------------------------------------------------------------
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator()
{
@@ -40,8 +38,8 @@ cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator()
lg->SetGlobalGenerator(this);
return lg;
}
-
+//----------------------------------------------------------------------------
// ouput standard header for dsw file
void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout)
{
@@ -100,12 +98,6 @@ std::string cmGlobalVisualStudio8Generator::GetUserMacrosDirectory()
{
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::GetUserMacrosDirectory()
}
//----------------------------------------------------------------------------
+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
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index 534258a..8e6a994 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -57,6 +57,12 @@ public:
*/
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; }
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index 9899f9c..ffc31af 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -33,6 +33,7 @@ void cmGlobalVisualStudio9Generator::AddPlatformDefinitions(cmMakefile* mf)
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 @@ std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
// the Registry value
return path;
}
+
+//----------------------------------------------------------------------------
+std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
+{
+ return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
+}
diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h
index 66d0180..0841603 100644
--- a/Source/cmGlobalVisualStudio9Generator.h
+++ b/Source/cmGlobalVisualStudio9Generator.h
@@ -59,5 +59,11 @@ public:
* 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
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index b824590..efa9adf 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -68,19 +68,21 @@ void cmGlobalVisualStudioGenerator::Generate()
//----------------------------------------------------------------------------
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 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
}
}
- RegisterVisualStudioMacros(dst);
+ RegisterVisualStudioMacros(dst, this->GetUserMacrosRegKeyBase());
}
}
@@ -140,7 +142,8 @@ cmGlobalVisualStudioGenerator
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::GetUserMacrosDirectory()
}
//----------------------------------------------------------------------------
+std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase()
+{
+ return "";
+}
+
+//----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::FixUtilityDepends()
{
// Skip for VS versions 8 and above.
@@ -396,6 +405,7 @@ cmGlobalVisualStudioGenerator::GetUtilityForTarget(cmTarget& target,
//----------------------------------------------------------------------------
bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
+ const std::string& regKeyBase,
std::string& nextAvailableSubKeyName)
{
bool macrosRegistered = false;
@@ -413,8 +423,7 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
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 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
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 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
//----------------------------------------------------------------------------
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 WriteVSMacrosFileRegistryEntry(
}
//----------------------------------------------------------------------------
-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 @@ void RegisterVisualStudioMacros(const std::string& macrosFile)
//
if (0 == count)
{
- IsVisualStudioMacrosFileRegistered(macrosFile,
+ IsVisualStudioMacrosFileRegistered(macrosFile, regKeyBase,
nextAvailableSubKeyName);
}
}
@@ -690,7 +699,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile)
//
if (0 == count)
{
- WriteVSMacrosFileRegistryEntry(nextAvailableSubKeyName, macrosFile);
+ WriteVSMacrosFileRegistryEntry(nextAvailableSubKeyName, macrosFile,
+ regKeyBase);
}
}
}
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 2fbb478..750418c 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -49,6 +49,12 @@ public:
*/
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};
/**