ENH: some code consolidation and cleanup
This commit is contained in:
parent
b4de606bdd
commit
2a1e2456ae
|
@ -1110,31 +1110,10 @@ void cmGlobalGenerator::FillProjectToTargetMap()
|
|||
{
|
||||
// add this target to the project
|
||||
this->ProjectToTargetMap[projectName].insert(&target);
|
||||
// now get all the targets that link to this target and
|
||||
// add them
|
||||
cmTarget::LinkLibraryVectorType::const_iterator j, jend;
|
||||
j = target.GetLinkLibraries().begin();
|
||||
jend = target.GetLinkLibraries().end();
|
||||
for(;j!= jend; ++j)
|
||||
{
|
||||
cmTarget* depTarget = this->FindTarget(0, j->first.c_str());
|
||||
if(depTarget)
|
||||
{
|
||||
this->ProjectToTargetMap[projectName].insert(depTarget);
|
||||
}
|
||||
}
|
||||
// Now add any utility targets used by this target
|
||||
std::set<cmStdString>::const_iterator i, end;
|
||||
i = target.GetUtilities().begin();
|
||||
end = target.GetUtilities().end();
|
||||
for(;i!= end; ++i)
|
||||
{
|
||||
cmTarget* depTarget = this->FindTarget(0, i->c_str());
|
||||
if(depTarget)
|
||||
{
|
||||
this->ProjectToTargetMap[projectName].insert(depTarget);
|
||||
}
|
||||
}
|
||||
// get the target's dependencies
|
||||
std::vector<cmTarget *>& tgtdeps = this->GetTargetDepends(target);
|
||||
this->ProjectToTargetMap[projectName].insert(tgtdeps.begin(),
|
||||
tgtdeps.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1504,3 +1483,80 @@ void cmGlobalGenerator::CheckMultipleOutputs(cmMakefile*, bool)
|
|||
// Only certain generators need this check. They define this
|
||||
// method.
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::vector<cmTarget *>& cmGlobalGenerator
|
||||
::GetTargetDepends(cmTarget& target)
|
||||
{
|
||||
// if the depends are already in the map then return
|
||||
std::map<cmStdString, std::vector<cmTarget *> >::iterator tgtI =
|
||||
this->TargetDependencies.find(target.GetName());
|
||||
if (tgtI != this->TargetDependencies.end())
|
||||
{
|
||||
return tgtI->second;
|
||||
}
|
||||
|
||||
// A target should not depend on itself.
|
||||
std::set<cmStdString> emitted;
|
||||
emitted.insert(target.GetName());
|
||||
|
||||
// the vector of results
|
||||
std::vector<cmTarget *>& result =
|
||||
this->TargetDependencies[target.GetName()];
|
||||
|
||||
// Loop over all library dependencies but not for static libs
|
||||
if (target.GetType() != cmTarget::STATIC_LIBRARY)
|
||||
{
|
||||
const cmTarget::LinkLibraryVectorType& tlibs = target.GetLinkLibraries();
|
||||
for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
|
||||
lib != tlibs.end(); ++lib)
|
||||
{
|
||||
// Don't emit the same library twice for this target.
|
||||
if(emitted.insert(lib->first).second)
|
||||
{
|
||||
cmTarget *target2 =
|
||||
target.GetMakefile()->FindTarget(lib->first.c_str());
|
||||
|
||||
// search each local generator until a match is found
|
||||
if (!target2)
|
||||
{
|
||||
target2 = this->FindTarget(0,lib->first.c_str());
|
||||
}
|
||||
|
||||
// if a match was found then ...
|
||||
if (target2)
|
||||
{
|
||||
// Add this dependency.
|
||||
result.push_back(target2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over all utility dependencies.
|
||||
const std::set<cmStdString>& tutils = target.GetUtilities();
|
||||
for(std::set<cmStdString>::const_iterator util = tutils.begin();
|
||||
util != tutils.end(); ++util)
|
||||
{
|
||||
// Don't emit the same utility twice for this target.
|
||||
if(emitted.insert(*util).second)
|
||||
{
|
||||
cmTarget *target2 = target.GetMakefile()->FindTarget(util->c_str());
|
||||
|
||||
// search each local generator until a match is found
|
||||
if (!target2)
|
||||
{
|
||||
target2 = this->FindTarget(0,util->c_str());
|
||||
}
|
||||
|
||||
// if a match was found then ...
|
||||
if (target2)
|
||||
{
|
||||
// Add this dependency.
|
||||
result.push_back(target2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,9 @@ public:
|
|||
virtual const char* GetEditCacheTargetName() { return 0; }
|
||||
virtual const char* GetRebuildCacheTargetName() { return 0; }
|
||||
|
||||
// what targets does the specified target depend on
|
||||
std::vector<cmTarget *>& GetTargetDepends(cmTarget& target);
|
||||
|
||||
protected:
|
||||
// Fill the ProjectMap, this must be called after LocalGenerators
|
||||
// has been populated.
|
||||
|
@ -236,6 +239,8 @@ private:
|
|||
|
||||
// this is used to improve performance
|
||||
std::map<cmStdString,cmTarget *> TotalTargets;
|
||||
|
||||
std::map<cmStdString, std::vector<cmTarget *> > TargetDependencies;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1002,82 +1002,6 @@ unsigned long cmGlobalUnixMakefileGenerator3
|
|||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::vector<cmTarget *>& cmGlobalUnixMakefileGenerator3
|
||||
::GetTargetDepends(cmTarget& target)
|
||||
{
|
||||
// if the depends are already in the map then return
|
||||
std::map<cmStdString, std::vector<cmTarget *> >::iterator tgtI =
|
||||
this->TargetDependencies.find(target.GetName());
|
||||
if (tgtI != this->TargetDependencies.end())
|
||||
{
|
||||
return tgtI->second;
|
||||
}
|
||||
|
||||
// A target should not depend on itself.
|
||||
std::set<cmStdString> emitted;
|
||||
emitted.insert(target.GetName());
|
||||
|
||||
// the vector of results
|
||||
std::vector<cmTarget *>& result =
|
||||
this->TargetDependencies[target.GetName()];
|
||||
|
||||
// Loop over all library dependencies but not for static libs
|
||||
if (target.GetType() != cmTarget::STATIC_LIBRARY)
|
||||
{
|
||||
const cmTarget::LinkLibraryVectorType& tlibs = target.GetLinkLibraries();
|
||||
for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
|
||||
lib != tlibs.end(); ++lib)
|
||||
{
|
||||
// Don't emit the same library twice for this target.
|
||||
if(emitted.insert(lib->first).second)
|
||||
{
|
||||
cmTarget *target2 =
|
||||
target.GetMakefile()->FindTarget(lib->first.c_str());
|
||||
|
||||
// search each local generator until a match is found
|
||||
if (!target2)
|
||||
{
|
||||
target2 = this->FindTarget(0,lib->first.c_str());
|
||||
}
|
||||
|
||||
// if a match was found then ...
|
||||
if (target2)
|
||||
{
|
||||
// Add this dependency.
|
||||
result.push_back(target2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over all utility dependencies.
|
||||
const std::set<cmStdString>& tutils = target.GetUtilities();
|
||||
for(std::set<cmStdString>::const_iterator util = tutils.begin();
|
||||
util != tutils.end(); ++util)
|
||||
{
|
||||
// Don't emit the same utility twice for this target.
|
||||
if(emitted.insert(*util).second)
|
||||
{
|
||||
cmTarget *target2 = target.GetMakefile()->FindTarget(util->c_str());
|
||||
|
||||
// search each local generator until a match is found
|
||||
if (!target2)
|
||||
{
|
||||
target2 = this->FindTarget(0,util->c_str());
|
||||
}
|
||||
|
||||
// if a match was found then ...
|
||||
if (target2)
|
||||
{
|
||||
// Add this dependency.
|
||||
result.push_back(target2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
cmGlobalUnixMakefileGenerator3
|
||||
|
|
|
@ -132,9 +132,6 @@ public:
|
|||
unsigned long GetNumberOfProgressActionsInAll
|
||||
(cmLocalUnixMakefileGenerator3 *lg);
|
||||
|
||||
// what targets does the specified target depend on
|
||||
std::vector<cmTarget *>& GetTargetDepends(cmTarget& target);
|
||||
|
||||
protected:
|
||||
void WriteMainMakefile2();
|
||||
void WriteMainCMakefile();
|
||||
|
@ -187,7 +184,6 @@ protected:
|
|||
typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
|
||||
MultipleOutputPairsType MultipleOutputPairs;
|
||||
|
||||
std::map<cmStdString, std::vector<cmTarget *> > TargetDependencies;
|
||||
std::map<cmStdString, int > TargetSourceFileCount;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue