Graphviz: Port to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-10-21 21:49:41 +02:00
parent bcee21ceb7
commit a0ebd69b52
2 changed files with 29 additions and 30 deletions

View File

@ -17,7 +17,7 @@
static const char* getShapeForTarget(const cmTarget* target) static const char* getShapeForTarget(const cmGeneratorTarget* target)
{ {
if (!target) if (!target)
{ {
@ -163,7 +163,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
this->CollectTargetsAndLibs(); this->CollectTargetsAndLibs();
for(std::map<std::string, const cmTarget*>::const_iterator ptrIt = for(std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
this->TargetPtrs.begin(); this->TargetPtrs.begin();
ptrIt != this->TargetPtrs.end(); ptrIt != this->TargetPtrs.end();
++ptrIt) ++ptrIt)
@ -214,7 +214,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
this->CollectTargetsAndLibs(); this->CollectTargetsAndLibs();
for(std::map<std::string, const cmTarget*>::const_iterator ptrIt = for(std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
this->TargetPtrs.begin(); this->TargetPtrs.begin();
ptrIt != this->TargetPtrs.end(); ptrIt != this->TargetPtrs.end();
++ptrIt) ++ptrIt)
@ -268,7 +268,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
std::set<std::string> insertedConnections; std::set<std::string> insertedConnections;
std::set<std::string> insertedNodes; std::set<std::string> insertedNodes;
for(std::map<std::string, const cmTarget*>::const_iterator ptrIt = for(std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
this->TargetPtrs.begin(); this->TargetPtrs.begin();
ptrIt != this->TargetPtrs.end(); ptrIt != this->TargetPtrs.end();
++ptrIt) ++ptrIt)
@ -308,8 +308,8 @@ void cmGraphVizWriter::WriteConnections(const std::string& targetName,
std::set<std::string>& insertedConnections, std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const cmGeneratedFileStream& str) const
{ {
std::map<std::string, const cmTarget* >::const_iterator targetPtrIt = std::map<std::string, const cmGeneratorTarget* >::const_iterator targetPtrIt
this->TargetPtrs.find(targetName); = this->TargetPtrs.find(targetName);
if (targetPtrIt == this->TargetPtrs.end()) // not found at all if (targetPtrIt == this->TargetPtrs.end()) // not found at all
{ {
@ -327,7 +327,7 @@ void cmGraphVizWriter::WriteConnections(const std::string& targetName,
std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
const cmTarget::LinkLibraryVectorType* ll = const cmTarget::LinkLibraryVectorType* ll =
&(targetPtrIt->second->GetOriginalLinkLibraries()); &(targetPtrIt->second->Target->GetOriginalLinkLibraries());
for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin(); for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
llit != ll->end(); llit != ll->end();
@ -367,8 +367,8 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName,
std::set<std::string>& insertedConnections, std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const cmGeneratedFileStream& str) const
{ {
std::map<std::string, const cmTarget* >::const_iterator targetPtrIt = std::map<std::string, const cmGeneratorTarget* >::const_iterator targetPtrIt
this->TargetPtrs.find(targetName); = this->TargetPtrs.find(targetName);
if (targetPtrIt == this->TargetPtrs.end()) // not found at all if (targetPtrIt == this->TargetPtrs.end()) // not found at all
{ {
@ -386,8 +386,8 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName,
std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
// now search who links against me // now search who links against me
for(std::map<std::string, const cmTarget*>::const_iterator dependerIt = for(std::map<std::string, const cmGeneratorTarget*>::const_iterator
this->TargetPtrs.begin(); dependerIt = this->TargetPtrs.begin();
dependerIt != this->TargetPtrs.end(); dependerIt != this->TargetPtrs.end();
++dependerIt) ++dependerIt)
{ {
@ -404,7 +404,7 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName,
// Now we have a target, check whether it links against targetName. // Now we have a target, check whether it links against targetName.
// If so, draw a connection, and then continue with dependers on that one. // If so, draw a connection, and then continue with dependers on that one.
const cmTarget::LinkLibraryVectorType* ll = const cmTarget::LinkLibraryVectorType* ll =
&(dependerIt->second->GetOriginalLinkLibraries()); &(dependerIt->second->Target->GetOriginalLinkLibraries());
for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin(); for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
llit != ll->end(); llit != ll->end();
@ -448,7 +448,7 @@ void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName,
void cmGraphVizWriter::WriteNode(const std::string& targetName, void cmGraphVizWriter::WriteNode(const std::string& targetName,
const cmTarget* target, const cmGeneratorTarget* target,
std::set<std::string>& insertedNodes, std::set<std::string>& insertedNodes,
cmGeneratedFileStream& str) const cmGeneratedFileStream& str) const
{ {
@ -488,12 +488,11 @@ int cmGraphVizWriter::CollectAllTargets()
lit != this->LocalGenerators.end(); lit != this->LocalGenerators.end();
++ lit ) ++ lit )
{ {
const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets();
for ( cmTargets::const_iterator tit = targets->begin(); for ( std::vector<cmGeneratorTarget*>::const_iterator it =
tit != targets->end(); targets.begin(); it != targets.end(); ++it )
++ tit )
{ {
const char* realTargetName = tit->first.c_str(); const char* realTargetName = (*it)->GetName().c_str();
if(this->IgnoreThisTarget(realTargetName)) if(this->IgnoreThisTarget(realTargetName))
{ {
// Skip ignored targets // Skip ignored targets
@ -503,7 +502,7 @@ int cmGraphVizWriter::CollectAllTargets()
std::ostringstream ostr; std::ostringstream ostr;
ostr << this->GraphNodePrefix << cnt++; ostr << this->GraphNodePrefix << cnt++;
this->TargetNamesNodes[realTargetName] = ostr.str(); this->TargetNamesNodes[realTargetName] = ostr.str();
this->TargetPtrs[realTargetName] = &tit->second; this->TargetPtrs[realTargetName] = *it;
} }
} }
@ -519,19 +518,18 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
lit != this->LocalGenerators.end(); lit != this->LocalGenerators.end();
++ lit ) ++ lit )
{ {
const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets();
for ( cmTargets::const_iterator tit = targets->begin(); for ( std::vector<cmGeneratorTarget*>::const_iterator it =
tit != targets->end(); targets.begin(); it != targets.end(); ++it )
++ tit )
{ {
const char* realTargetName = tit->first.c_str(); const char* realTargetName = (*it)->GetName().c_str();
if (this->IgnoreThisTarget(realTargetName)) if (this->IgnoreThisTarget(realTargetName))
{ {
// Skip ignored targets // Skip ignored targets
continue; continue;
} }
const cmTarget::LinkLibraryVectorType* ll = const cmTarget::LinkLibraryVectorType* ll =
&(tit->second.GetOriginalLinkLibraries()); &((*it)->Target->GetOriginalLinkLibraries());
for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin(); for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
llit != ll->end(); llit != ll->end();
++ llit ) ++ llit )
@ -543,8 +541,8 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
continue; continue;
} }
std::map<std::string, const cmTarget*>::const_iterator tarIt = std::map<std::string, const cmGeneratorTarget*>::const_iterator tarIt
this->TargetPtrs.find(libName); = this->TargetPtrs.find(libName);
if ( tarIt == this->TargetPtrs.end() ) if ( tarIt == this->TargetPtrs.end() )
{ {
std::ostringstream ostr; std::ostringstream ostr;

View File

@ -14,9 +14,9 @@
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmTarget.h"
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
class cmGeneratorTarget;
/** This class implements writing files for graphviz (dot) for graphs /** This class implements writing files for graphviz (dot) for graphs
* representing the dependencies between the targets in the project. */ * representing the dependencies between the targets in the project. */
@ -54,7 +54,8 @@ protected:
std::set<std::string>& insertedConnections, std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const; cmGeneratedFileStream& str) const;
void WriteNode(const std::string& targetName, const cmTarget* target, void WriteNode(const std::string& targetName,
const cmGeneratorTarget* target,
std::set<std::string>& insertedNodes, std::set<std::string>& insertedNodes,
cmGeneratedFileStream& str) const; cmGeneratedFileStream& str) const;
@ -73,7 +74,7 @@ protected:
const std::vector<cmLocalGenerator*>& LocalGenerators; const std::vector<cmLocalGenerator*>& LocalGenerators;
std::map<std::string, const cmTarget*> TargetPtrs; std::map<std::string, const cmGeneratorTarget*> TargetPtrs;
// maps from the actual target names to node names in dot: // maps from the actual target names to node names in dot:
std::map<std::string, std::string> TargetNamesNodes; std::map<std::string, std::string> TargetNamesNodes;