mirror of
https://github.com/reactos/CMake.git
synced 2024-11-27 13:30:39 +00:00
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.
This commit is contained in:
parent
ed76198b84
commit
ca2a16c0a2
@ -94,7 +94,41 @@ HRESULT InstanceCallMacro(
|
||||
|
||||
hr = vsIDE->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
|
||||
DISPATCH_METHOD, ¶ms, &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);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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";
|
||||
}
|
||||
@ -115,6 +107,12 @@ std::string cmGlobalVisualStudio8Generator::GetUserMacrosDirectory()
|
||||
return path;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmGlobalVisualStudio8Generator::GetUserMacrosRegKeyBase()
|
||||
{
|
||||
return "Software\\Microsoft\\VisualStudio\\8.0\\vsmacros";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmGlobalVisualStudio8Generator::Generate()
|
||||
{
|
||||
|
@ -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; }
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
@ -194,6 +197,12 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosDirectory()
|
||||
return "";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmGlobalVisualStudioGenerator::FixUtilityDepends()
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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};
|
||||
|
||||
/**
|
||||
|
BIN
Templates/CMakeVSMacros2.vsmacros
Normal file
BIN
Templates/CMakeVSMacros2.vsmacros
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user