Skip to content

Commit

Permalink
ENH: Add code to support calling the VS reload macro from Visual Stud…
Browse files Browse the repository at this point in the history
…io 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.
  • Loading branch information
dlrdave committed Feb 15, 2008
1 parent ed76198 commit ca2a16c
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 41 deletions.
36 changes: 35 additions & 1 deletion Source/cmCallVisualStudioMacro.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
75 changes: 63 additions & 12 deletions Source/cmGlobalVisualStudio71Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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,
Expand Down Expand Up @@ -77,7 +129,7 @@ ::WriteSLNFile(std::ostream& fout,
this->WriteSLNFooter(fout);
}


//----------------------------------------------------------------------------
void
cmGlobalVisualStudio71Generator
::WriteSolutionConfigurations(std::ostream& fout)
Expand All @@ -91,6 +143,7 @@ ::WriteSolutionConfigurations(std::ostream& fout)
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
Expand All @@ -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
Expand Down Expand Up @@ -179,6 +231,7 @@ ::WriteProjectDepends(std::ostream& fout,
}
}

//----------------------------------------------------------------------------
// Write a dsp file into the SLN file, Note, that dependencies from
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator
Expand Down Expand Up @@ -219,7 +272,7 @@ ::WriteExternalProject(std::ostream& fout,

}


//----------------------------------------------------------------------------
// Write a dsp file into the SLN file, Note, that dependencies from
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator
Expand All @@ -240,9 +293,7 @@ ::WriteProjectConfigurations(std::ostream& fout, const char* name,
}
}




//----------------------------------------------------------------------------
// Standard end of dsw file
void cmGlobalVisualStudio71Generator::WriteSLNFooter(std::ostream& fout)
{
Expand All @@ -253,7 +304,7 @@ void cmGlobalVisualStudio71Generator::WriteSLNFooter(std::ostream& fout)
<< "EndGlobal\n";
}

//----------------------------------------------------------------------------
// ouput standard header for dsw file
void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout)
{
Expand Down
13 changes: 13 additions & 0 deletions Source/cmGlobalVisualStudio71Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator
///! 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,
Expand Down
20 changes: 9 additions & 11 deletions Source/cmGlobalVisualStudio8Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@
#include "cmMakefile.h"
#include "cmake.h"



//----------------------------------------------------------------------------
cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
{
this->FindMakeProgramFile = "CMakeVS8FindMake.cmake";
this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
this->PlatformName = "Win32";
}



//----------------------------------------------------------------------------
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator()
{
Expand All @@ -40,8 +38,8 @@ cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator()
lg->SetGlobalGenerator(this);
return lg;
}


//----------------------------------------------------------------------------
// ouput standard header for dsw file
void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout)
{
Expand Down Expand Up @@ -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";
}
Expand All @@ -115,6 +107,12 @@ std::string cmGlobalVisualStudio8Generator::GetUserMacrosDirectory()
return path;
}

//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio8Generator::GetUserMacrosRegKeyBase()
{
return "Software\\Microsoft\\VisualStudio\\8.0\\vsmacros";
}

//----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::Generate()
{
Expand Down
6 changes: 6 additions & 0 deletions Source/cmGlobalVisualStudio8Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator
*/
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; }
Expand Down
7 changes: 7 additions & 0 deletions Source/cmGlobalVisualStudio9Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -92,3 +93,9 @@ std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
// the Registry value
return path;
}

//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
{
return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
}
6 changes: 6 additions & 0 deletions Source/cmGlobalVisualStudio9Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,11 @@ class cmGlobalVisualStudio9Generator :
* 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
Loading

0 comments on commit ca2a16c

Please sign in to comment.