ENH: move project map to global generator base

This commit is contained in:
Bill Hoffman 2005-01-21 12:26:32 -05:00
parent 35c33d0e2d
commit 13865fc4fa
6 changed files with 35 additions and 51 deletions

View File

@ -554,6 +554,9 @@ void cmGlobalGenerator::Configure()
"Please set the following variables:\n", "Please set the following variables:\n",
notFoundVars.c_str()); notFoundVars.c_str());
} }
// at this point m_LocalGenerators has been filled,
// so create the map from project name to vector of local generators
this->FillProjectMap();
if ( !m_CMakeInstance->GetScriptMode() ) if ( !m_CMakeInstance->GetScriptMode() )
{ {
m_CMakeInstance->UpdateProgress("Configuring done", -1); m_CMakeInstance->UpdateProgress("Configuring done", -1);
@ -774,3 +777,24 @@ const char* cmGlobalGenerator::GetLinkerPreference(const char* lang)
} }
return "None"; return "None";
} }
void cmGlobalGenerator::FillProjectMap()
{
unsigned int i;
for(i = 0; i < m_LocalGenerators.size(); ++i)
{
std::string name = m_LocalGenerators[i]->GetMakefile()->GetProjectName();
// for each local generator add the local generator to the project that
// it is in
m_ProjectMap[name].push_back(m_LocalGenerators[i]);
// now add the local generator to any parent project it is part of
std::vector<std::string> const& pprojects
= m_LocalGenerators[i]->GetMakefile()->GetParentProjects();
for(unsigned int k =0; k < pprojects.size(); ++k)
{
m_ProjectMap[pprojects[k]].push_back(m_LocalGenerators[i]);
}
}
}

View File

@ -116,6 +116,8 @@ public:
///! What is the output extension for a given source file extension. ///! What is the output extension for a given source file extension.
const char* GetLanguageOutputExtensionFromExtension(const char* lang); const char* GetLanguageOutputExtensionFromExtension(const char* lang);
protected: protected:
// Fill the m_ProjectMap, this must be called after m_LocalGenerators has been populated.
void FillProjectMap();
bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen);
void FindMakeProgram(cmMakefile*); void FindMakeProgram(cmMakefile*);
@ -124,6 +126,8 @@ protected:
cmStdString m_ConfiguredFilesPath; cmStdString m_ConfiguredFilesPath;
cmake *m_CMakeInstance; cmake *m_CMakeInstance;
std::vector<cmLocalGenerator *> m_LocalGenerators; std::vector<cmLocalGenerator *> m_LocalGenerators;
// map from project name to vector of local generators in that project
std::map<cmStdString, std::vector<cmLocalGenerator*> > m_ProjectMap;
///! used by Configure() ///! used by Configure()
void RecursiveConfigure(cmLocalGenerator *lg, float start, float end); void RecursiveConfigure(cmLocalGenerator *lg, float start, float end);

View File

@ -159,14 +159,11 @@ cmLocalGenerator *cmGlobalVisualStudio6Generator::CreateLocalGenerator()
void cmGlobalVisualStudio6Generator::Generate() void cmGlobalVisualStudio6Generator::Generate()
{ {
// collect sub-projects
this->CollectSubprojects();
// add a special target that depends on ALL projects for easy build // add a special target that depends on ALL projects for easy build
// of one configuration only. // of one configuration only.
std::vector<std::string> srcs; std::vector<std::string> srcs;
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it) for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
{ {
std::vector<cmLocalGenerator*>& gen = it->second; std::vector<cmLocalGenerator*>& gen = it->second;
// add the ALL_BUILD to the first local generator of each project // add the ALL_BUILD to the first local generator of each project
@ -192,24 +189,6 @@ void cmGlobalVisualStudio6Generator::Generate()
this->OutputDSWFile(); this->OutputDSWFile();
} }
// populate the m_SubProjectMap
void cmGlobalVisualStudio6Generator::CollectSubprojects()
{
unsigned int i;
for(i = 0; i < m_LocalGenerators.size(); ++i)
{
std::string name = m_LocalGenerators[i]->GetMakefile()->GetProjectName();
m_SubProjectMap[name].push_back(m_LocalGenerators[i]);
std::vector<std::string> const& pprojects
= m_LocalGenerators[i]->GetMakefile()->GetParentProjects();
for(unsigned int k =0; k < pprojects.size(); ++k)
{
m_SubProjectMap[pprojects[k]].push_back(m_LocalGenerators[i]);
}
}
}
// Write a DSW file to the stream // Write a DSW file to the stream
void cmGlobalVisualStudio6Generator::WriteDSWFile(std::ostream& fout, void cmGlobalVisualStudio6Generator::WriteDSWFile(std::ostream& fout,
cmLocalGenerator* root, cmLocalGenerator* root,
@ -373,7 +352,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile(cmLocalGenerator* root,
void cmGlobalVisualStudio6Generator::OutputDSWFile() void cmGlobalVisualStudio6Generator::OutputDSWFile()
{ {
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it) for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
{ {
this->OutputDSWFile(it->second[0], it->second); this->OutputDSWFile(it->second[0], it->second);
} }
@ -431,7 +410,7 @@ void cmGlobalVisualStudio6Generator::SetupTests()
{ {
std::vector<std::string> srcs; std::vector<std::string> srcs;
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it) for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
{ {
std::vector<cmLocalGenerator*>& gen = it->second; std::vector<cmLocalGenerator*>& gen = it->second;
// add the ALL_BUILD to the first local generator of each project // add the ALL_BUILD to the first local generator of each project

View File

@ -73,7 +73,6 @@ public:
cmLocalGenerator* root, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators); std::vector<cmLocalGenerator*>& generators);
private: private:
void CollectSubprojects();
void GenerateConfigurations(cmMakefile* mf); void GenerateConfigurations(cmMakefile* mf);
void SetupTests(); void SetupTests();
void WriteDSWFile(std::ostream& fout); void WriteDSWFile(std::ostream& fout);
@ -85,7 +84,6 @@ private:
const char* name, const char* path, const char* name, const char* path,
const std::vector<std::string>& dependencies); const std::vector<std::string>& dependencies);
void WriteDSWFooter(std::ostream& fout); void WriteDSWFooter(std::ostream& fout);
std::map<cmStdString, std::vector<cmLocalGenerator*> > m_SubProjectMap;
}; };
#endif #endif

View File

@ -162,7 +162,7 @@ void cmGlobalVisualStudio7Generator::SetupTests()
{ {
std::vector<std::string> srcs; std::vector<std::string> srcs;
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it) for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
{ {
std::vector<cmLocalGenerator*>& gen = it->second; std::vector<cmLocalGenerator*>& gen = it->second;
// add the ALL_BUILD to the first local generator of each project // add the ALL_BUILD to the first local generator of each project
@ -246,13 +246,11 @@ void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf)
void cmGlobalVisualStudio7Generator::Generate() void cmGlobalVisualStudio7Generator::Generate()
{ {
// collect sub-projects
this->CollectSubprojects();
// add a special target that depends on ALL projects for easy build // add a special target that depends on ALL projects for easy build
// of Debug only // of Debug only
std::vector<std::string> srcs; std::vector<std::string> srcs;
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it) for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
{ {
std::vector<cmLocalGenerator*>& gen = it->second; std::vector<cmLocalGenerator*>& gen = it->second;
// add the ALL_BUILD to the first local generator of each project // add the ALL_BUILD to the first local generator of each project
@ -302,7 +300,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(cmLocalGenerator* root,
void cmGlobalVisualStudio7Generator::OutputSLNFile() void cmGlobalVisualStudio7Generator::OutputSLNFile()
{ {
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it) for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
{ {
this->OutputSLNFile(it->second[0], it->second); this->OutputSLNFile(it->second[0], it->second);
} }
@ -724,23 +722,6 @@ void cmGlobalVisualStudio7Generator::GetDocumentation(cmDocumentationEntry& entr
entry.full = ""; entry.full = "";
} }
// populate the m_SubProjectMap
void cmGlobalVisualStudio7Generator::CollectSubprojects()
{
unsigned int i;
for(i = 0; i < m_LocalGenerators.size(); ++i)
{
std::string name = m_LocalGenerators[i]->GetMakefile()->GetProjectName();
m_SubProjectMap[name].push_back(m_LocalGenerators[i]);
std::vector<std::string> const& pprojects
= m_LocalGenerators[i]->GetMakefile()->GetParentProjects();
for(unsigned int k =0; k < pprojects.size(); ++k)
{
m_SubProjectMap[pprojects[k]].push_back(m_LocalGenerators[i]);
}
}
}
// make sure "special" targets have GUID's // make sure "special" targets have GUID's
void cmGlobalVisualStudio7Generator::Configure() void cmGlobalVisualStudio7Generator::Configure()
{ {

View File

@ -88,7 +88,6 @@ public:
virtual void Configure(); virtual void Configure();
protected: protected:
std::string GetGUID(const char* name); std::string GetGUID(const char* name);
void CollectSubprojects();
virtual void OutputSLNFile(cmLocalGenerator* root, virtual void OutputSLNFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators); std::vector<cmLocalGenerator*>& generators);
virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
@ -112,7 +111,6 @@ protected:
std::vector<std::string> m_Configurations; std::vector<std::string> m_Configurations;
std::map<cmStdString, cmStdString> m_GUIDMap; std::map<cmStdString, cmStdString> m_GUIDMap;
std::map<cmStdString, std::vector<cmLocalGenerator*> > m_SubProjectMap;
}; };
#endif #endif