2010-11-09 23:37:51 +03:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
#include "cmGraphVizWriter.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char* getShapeForTarget(const cmTarget* target)
|
|
|
|
{
|
|
|
|
if (!target)
|
|
|
|
{
|
|
|
|
return "ellipse";
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( target->GetType() )
|
|
|
|
{
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
return "house";
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
return "diamond";
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
return "polygon";
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
|
|
|
return "octagon";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "box";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cmGraphVizWriter::cmGraphVizWriter(const std::vector<cmLocalGenerator*>&
|
|
|
|
localGenerators)
|
|
|
|
:GraphType("digraph")
|
|
|
|
,GraphName("GG")
|
|
|
|
,GraphHeader("node [\n fontsize = \"12\"\n];")
|
|
|
|
,GraphNodePrefix("node")
|
2010-11-14 21:30:58 +03:00
|
|
|
,GenerateForExecutables(true)
|
|
|
|
,GenerateForStaticLibs(true)
|
|
|
|
,GenerateForSharedLibs(true)
|
|
|
|
,GenerateForModuleLibs(true)
|
2011-02-05 20:43:34 +03:00
|
|
|
,GenerateForExternals(true)
|
2010-11-09 23:37:51 +03:00
|
|
|
,LocalGenerators(localGenerators)
|
2010-11-14 21:37:03 +03:00
|
|
|
,HaveTargetsAndLibs(false)
|
2010-11-09 23:37:51 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
|
|
|
|
const char* fallbackSettingsFileName)
|
|
|
|
{
|
|
|
|
cmake cm;
|
|
|
|
cmGlobalGenerator ggi;
|
|
|
|
ggi.SetCMakeInstance(&cm);
|
2012-11-21 03:56:36 +04:00
|
|
|
cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator());
|
2010-11-09 23:37:51 +03:00
|
|
|
cmMakefile *mf = lg->GetMakefile();
|
|
|
|
|
|
|
|
const char* inFileName = settingsFileName;
|
|
|
|
|
|
|
|
if ( !cmSystemTools::FileExists(inFileName) )
|
|
|
|
{
|
|
|
|
inFileName = fallbackSettingsFileName;
|
|
|
|
if ( !cmSystemTools::FileExists(inFileName) )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !mf->ReadListFile(0, inFileName) )
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("Problem opening GraphViz options file: ",
|
|
|
|
inFileName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "Reading GraphViz options file: " << inFileName << std::endl;
|
|
|
|
|
|
|
|
#define __set_if_set(var, cmakeDefinition) \
|
|
|
|
{ \
|
|
|
|
const char* value = mf->GetDefinition(cmakeDefinition); \
|
|
|
|
if ( value ) \
|
|
|
|
{ \
|
|
|
|
var = value; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
__set_if_set(this->GraphType, "GRAPHVIZ_GRAPH_TYPE");
|
|
|
|
__set_if_set(this->GraphName, "GRAPHVIZ_GRAPH_NAME");
|
|
|
|
__set_if_set(this->GraphHeader, "GRAPHVIZ_GRAPH_HEADER");
|
|
|
|
__set_if_set(this->GraphNodePrefix, "GRAPHVIZ_NODE_PREFIX");
|
|
|
|
|
2010-11-14 21:30:58 +03:00
|
|
|
#define __set_bool_if_set(var, cmakeDefinition) \
|
|
|
|
{ \
|
|
|
|
const char* value = mf->GetDefinition(cmakeDefinition); \
|
|
|
|
if ( value ) \
|
|
|
|
{ \
|
|
|
|
var = mf->IsOn(cmakeDefinition); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
__set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES");
|
|
|
|
__set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS");
|
|
|
|
__set_bool_if_set(this->GenerateForSharedLibs, "GRAPHVIZ_SHARED_LIBS");
|
2011-02-05 20:43:34 +03:00
|
|
|
__set_bool_if_set(this->GenerateForModuleLibs, "GRAPHVIZ_MODULE_LIBS");
|
|
|
|
__set_bool_if_set(this->GenerateForExternals, "GRAPHVIZ_EXTERNAL_LIBS");
|
2010-11-14 21:30:58 +03:00
|
|
|
|
2011-02-05 21:09:54 +03:00
|
|
|
cmStdString ignoreTargetsRegexes;
|
|
|
|
__set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS");
|
2010-11-14 21:47:28 +03:00
|
|
|
|
2011-02-05 21:09:54 +03:00
|
|
|
this->TargetsToIgnoreRegex.clear();
|
|
|
|
if (ignoreTargetsRegexes.size() > 0)
|
2010-11-09 23:37:51 +03:00
|
|
|
{
|
2011-02-05 21:09:54 +03:00
|
|
|
std::vector<std::string> ignoreTargetsRegExVector;
|
|
|
|
cmSystemTools::ExpandListArgument(ignoreTargetsRegexes,
|
|
|
|
ignoreTargetsRegExVector);
|
|
|
|
for(std::vector<std::string>::const_iterator itvIt
|
|
|
|
= ignoreTargetsRegExVector.begin();
|
|
|
|
itvIt != ignoreTargetsRegExVector.end();
|
2010-11-09 23:37:51 +03:00
|
|
|
++ itvIt )
|
|
|
|
{
|
2011-02-05 21:09:54 +03:00
|
|
|
cmStdString currentRegexString(*itvIt);
|
|
|
|
cmsys::RegularExpression currentRegex;
|
|
|
|
if (!currentRegex.compile(currentRegexString.c_str()))
|
|
|
|
{
|
|
|
|
std::cerr << "Could not compile bad regex \"" << currentRegexString
|
|
|
|
<< "\"" << std::endl;
|
|
|
|
}
|
|
|
|
this->TargetsToIgnoreRegex.push_back(currentRegex);
|
2010-11-09 23:37:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-06 20:34:48 +03:00
|
|
|
// Iterate over all targets and write for each one a graph which shows
|
|
|
|
// which other targets depend on it.
|
|
|
|
void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
|
|
|
|
{
|
|
|
|
this->CollectTargetsAndLibs();
|
|
|
|
|
|
|
|
for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
|
|
|
|
this->TargetPtrs.begin();
|
|
|
|
ptrIt != this->TargetPtrs.end();
|
|
|
|
++ptrIt)
|
|
|
|
{
|
|
|
|
if (ptrIt->second == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->GenerateForTargetType(ptrIt->second->GetType()) == false)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string currentFilename = fileName;
|
|
|
|
currentFilename += ".";
|
|
|
|
currentFilename += ptrIt->first;
|
|
|
|
currentFilename += ".dependers";
|
|
|
|
|
|
|
|
cmGeneratedFileStream str(currentFilename.c_str());
|
|
|
|
if ( !str )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::set<std::string> insertedConnections;
|
|
|
|
std::set<std::string> insertedNodes;
|
|
|
|
|
|
|
|
std::cout << "Writing " << currentFilename << "..." << std::endl;
|
|
|
|
this->WriteHeader(str);
|
|
|
|
|
|
|
|
this->WriteDependerConnections(ptrIt->first.c_str(),
|
|
|
|
insertedNodes, insertedConnections, str);
|
|
|
|
|
|
|
|
this->WriteFooter(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Iterate over all targets and write for each one a graph which shows
|
|
|
|
// on which targets it depends.
|
2010-11-09 23:37:51 +03:00
|
|
|
void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
|
|
|
|
{
|
2010-11-14 21:37:03 +03:00
|
|
|
this->CollectTargetsAndLibs();
|
|
|
|
|
2010-11-09 23:37:51 +03:00
|
|
|
for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
|
|
|
|
this->TargetPtrs.begin();
|
|
|
|
ptrIt != this->TargetPtrs.end();
|
|
|
|
++ptrIt)
|
|
|
|
{
|
|
|
|
if (ptrIt->second == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-11-14 21:30:58 +03:00
|
|
|
if (this->GenerateForTargetType(ptrIt->second->GetType()) == false)
|
2010-11-09 23:37:51 +03:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::set<std::string> insertedConnections;
|
|
|
|
std::set<std::string> insertedNodes;
|
|
|
|
|
|
|
|
std::string currentFilename = fileName;
|
|
|
|
currentFilename += ".";
|
|
|
|
currentFilename += ptrIt->first;
|
|
|
|
cmGeneratedFileStream str(currentFilename.c_str());
|
|
|
|
if ( !str )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-14 21:33:12 +03:00
|
|
|
std::cout << "Writing " << currentFilename << "..." << std::endl;
|
2010-11-09 23:37:51 +03:00
|
|
|
this->WriteHeader(str);
|
|
|
|
|
|
|
|
this->WriteConnections(ptrIt->first.c_str(),
|
|
|
|
insertedNodes, insertedConnections, str);
|
|
|
|
this->WriteFooter(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
|
|
|
|
{
|
2010-11-14 21:37:03 +03:00
|
|
|
this->CollectTargetsAndLibs();
|
|
|
|
|
2010-11-09 23:37:51 +03:00
|
|
|
cmGeneratedFileStream str(fileName);
|
|
|
|
if ( !str )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this->WriteHeader(str);
|
|
|
|
|
2010-11-14 21:33:12 +03:00
|
|
|
std::cout << "Writing " << fileName << "..." << std::endl;
|
|
|
|
|
2010-11-09 23:37:51 +03:00
|
|
|
std::set<std::string> insertedConnections;
|
|
|
|
std::set<std::string> insertedNodes;
|
|
|
|
|
|
|
|
for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
|
|
|
|
this->TargetPtrs.begin();
|
|
|
|
ptrIt != this->TargetPtrs.end();
|
|
|
|
++ptrIt)
|
|
|
|
{
|
|
|
|
if (ptrIt->second == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-11-14 21:30:58 +03:00
|
|
|
if (this->GenerateForTargetType(ptrIt->second->GetType()) == false)
|
2010-11-09 23:37:51 +03:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->WriteConnections(ptrIt->first.c_str(),
|
|
|
|
insertedNodes, insertedConnections, str);
|
|
|
|
}
|
|
|
|
this->WriteFooter(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmGraphVizWriter::WriteHeader(cmGeneratedFileStream& str) const
|
|
|
|
{
|
|
|
|
str << this->GraphType << " " << this->GraphName << " {" << std::endl;
|
|
|
|
str << this->GraphHeader << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmGraphVizWriter::WriteFooter(cmGeneratedFileStream& str) const
|
|
|
|
{
|
|
|
|
str << "}" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmGraphVizWriter::WriteConnections(const char* targetName,
|
|
|
|
std::set<std::string>& insertedNodes,
|
|
|
|
std::set<std::string>& insertedConnections,
|
|
|
|
cmGeneratedFileStream& str) const
|
|
|
|
{
|
|
|
|
std::map<cmStdString, const cmTarget* >::const_iterator targetPtrIt =
|
|
|
|
this->TargetPtrs.find(targetName);
|
|
|
|
|
|
|
|
if (targetPtrIt == this->TargetPtrs.end()) // not found at all
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str);
|
|
|
|
|
|
|
|
if (targetPtrIt->second == NULL) // it's an external library
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
|
|
|
|
|
|
|
|
const cmTarget::LinkLibraryVectorType* ll =
|
|
|
|
&(targetPtrIt->second->GetOriginalLinkLibraries());
|
|
|
|
|
|
|
|
for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
|
|
|
|
llit != ll->end();
|
|
|
|
++ llit )
|
|
|
|
{
|
|
|
|
const char* libName = llit->first.c_str();
|
|
|
|
std::map<cmStdString, cmStdString>::const_iterator libNameIt =
|
|
|
|
this->TargetNamesNodes.find(libName);
|
|
|
|
|
2011-02-04 22:31:18 +03:00
|
|
|
// can happen e.g. if GRAPHVIZ_TARGET_IGNORE_REGEX is used
|
|
|
|
if(libNameIt == this->TargetNamesNodes.end())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-11-09 23:37:51 +03:00
|
|
|
std::string connectionName = myNodeName;
|
|
|
|
connectionName += "-";
|
|
|
|
connectionName += libNameIt->second;
|
|
|
|
if (insertedConnections.find(connectionName) == insertedConnections.end())
|
|
|
|
{
|
|
|
|
insertedConnections.insert(connectionName);
|
|
|
|
this->WriteNode(libName, this->TargetPtrs.find(libName)->second,
|
|
|
|
insertedNodes, str);
|
|
|
|
|
|
|
|
str << " \"" << myNodeName.c_str() << "\" -> \""
|
|
|
|
<< libNameIt->second.c_str() << "\"";
|
|
|
|
str << " // " << targetName << " -> " << libName << std::endl;
|
|
|
|
this->WriteConnections(libName, insertedNodes, insertedConnections, str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-06 20:34:48 +03:00
|
|
|
void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
|
|
|
|
std::set<std::string>& insertedNodes,
|
|
|
|
std::set<std::string>& insertedConnections,
|
|
|
|
cmGeneratedFileStream& str) const
|
|
|
|
{
|
|
|
|
std::map<cmStdString, const cmTarget* >::const_iterator targetPtrIt =
|
|
|
|
this->TargetPtrs.find(targetName);
|
|
|
|
|
|
|
|
if (targetPtrIt == this->TargetPtrs.end()) // not found at all
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str);
|
|
|
|
|
|
|
|
if (targetPtrIt->second == NULL) // it's an external library
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
|
|
|
|
|
|
|
|
// now search who links against me
|
|
|
|
for(std::map<cmStdString, const cmTarget*>::const_iterator dependerIt =
|
|
|
|
this->TargetPtrs.begin();
|
|
|
|
dependerIt != this->TargetPtrs.end();
|
|
|
|
++dependerIt)
|
|
|
|
{
|
|
|
|
if (dependerIt->second == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this->GenerateForTargetType(dependerIt->second->GetType()) == false)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now we have a target, check whether it links against targetName.
|
|
|
|
// If so, draw a connection, and then continue with dependers on that one.
|
|
|
|
const cmTarget::LinkLibraryVectorType* ll =
|
|
|
|
&(dependerIt->second->GetOriginalLinkLibraries());
|
|
|
|
|
|
|
|
for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
|
|
|
|
llit != ll->end();
|
|
|
|
++ llit )
|
|
|
|
{
|
|
|
|
std::string libName = llit->first.c_str();
|
|
|
|
if (libName == targetName)
|
|
|
|
{
|
|
|
|
// So this target links against targetName.
|
|
|
|
std::map<cmStdString, cmStdString>::const_iterator dependerNodeNameIt =
|
|
|
|
this->TargetNamesNodes.find(dependerIt->first);
|
|
|
|
|
|
|
|
if(dependerNodeNameIt != this->TargetNamesNodes.end())
|
|
|
|
{
|
|
|
|
std::string connectionName = dependerNodeNameIt->second;
|
|
|
|
connectionName += "-";
|
|
|
|
connectionName += myNodeName;
|
|
|
|
|
|
|
|
if (insertedConnections.find(connectionName) ==
|
|
|
|
insertedConnections.end())
|
|
|
|
{
|
|
|
|
insertedConnections.insert(connectionName);
|
|
|
|
this->WriteNode(dependerIt->first.c_str(), dependerIt->second,
|
|
|
|
insertedNodes, str);
|
|
|
|
|
|
|
|
str << " \"" << dependerNodeNameIt->second << "\" -> \""
|
|
|
|
<< myNodeName << "\"";
|
|
|
|
str << " // " <<targetName<< " -> " <<dependerIt->first<<std::endl;
|
|
|
|
this->WriteDependerConnections(dependerIt->first.c_str(),
|
|
|
|
insertedNodes, insertedConnections, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-09 23:37:51 +03:00
|
|
|
void cmGraphVizWriter::WriteNode(const char* targetName,
|
|
|
|
const cmTarget* target,
|
|
|
|
std::set<std::string>& insertedNodes,
|
|
|
|
cmGeneratedFileStream& str) const
|
|
|
|
{
|
|
|
|
if (insertedNodes.find(targetName) == insertedNodes.end())
|
|
|
|
{
|
|
|
|
insertedNodes.insert(targetName);
|
|
|
|
std::map<cmStdString, cmStdString>::const_iterator nameIt =
|
|
|
|
this->TargetNamesNodes.find(targetName);
|
|
|
|
|
|
|
|
str << " \"" << nameIt->second.c_str() << "\" [ label=\""
|
|
|
|
<< targetName << "\" shape=\"" << getShapeForTarget(target)
|
|
|
|
<< "\"];" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-14 21:37:03 +03:00
|
|
|
void cmGraphVizWriter::CollectTargetsAndLibs()
|
|
|
|
{
|
|
|
|
if (this->HaveTargetsAndLibs == false)
|
|
|
|
{
|
|
|
|
this->HaveTargetsAndLibs = true;
|
|
|
|
int cnt = this->CollectAllTargets();
|
2011-02-05 20:43:34 +03:00
|
|
|
if (this->GenerateForExternals)
|
|
|
|
{
|
|
|
|
this->CollectAllExternalLibs(cnt);
|
|
|
|
}
|
2010-11-14 21:37:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int cmGraphVizWriter::CollectAllTargets()
|
2010-11-09 23:37:51 +03:00
|
|
|
{
|
|
|
|
int cnt = 0;
|
|
|
|
// First pass get the list of all cmake targets
|
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator lit =
|
|
|
|
this->LocalGenerators.begin();
|
|
|
|
lit != this->LocalGenerators.end();
|
|
|
|
++ lit )
|
|
|
|
{
|
|
|
|
const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets());
|
|
|
|
for ( cmTargets::const_iterator tit = targets->begin();
|
|
|
|
tit != targets->end();
|
|
|
|
++ tit )
|
|
|
|
{
|
|
|
|
const char* realTargetName = tit->first.c_str();
|
|
|
|
if(this->IgnoreThisTarget(realTargetName))
|
|
|
|
{
|
|
|
|
// Skip ignored targets
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//std::cout << "Found target: " << tit->first.c_str() << std::endl;
|
|
|
|
cmOStringStream ostr;
|
|
|
|
ostr << this->GraphNodePrefix << cnt++;
|
|
|
|
this->TargetNamesNodes[realTargetName] = ostr.str();
|
|
|
|
this->TargetPtrs[realTargetName] = &tit->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-14 21:37:03 +03:00
|
|
|
int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
|
2010-11-09 23:37:51 +03:00
|
|
|
{
|
|
|
|
// Ok, now find all the stuff we link to that is not in cmake
|
|
|
|
for (std::vector<cmLocalGenerator*>::const_iterator lit =
|
|
|
|
this->LocalGenerators.begin();
|
|
|
|
lit != this->LocalGenerators.end();
|
|
|
|
++ lit )
|
|
|
|
{
|
|
|
|
const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets());
|
|
|
|
for ( cmTargets::const_iterator tit = targets->begin();
|
|
|
|
tit != targets->end();
|
|
|
|
++ tit )
|
|
|
|
{
|
|
|
|
const char* realTargetName = tit->first.c_str();
|
|
|
|
if (this->IgnoreThisTarget(realTargetName))
|
|
|
|
{
|
|
|
|
// Skip ignored targets
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const cmTarget::LinkLibraryVectorType* ll =
|
|
|
|
&(tit->second.GetOriginalLinkLibraries());
|
|
|
|
for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
|
|
|
|
llit != ll->end();
|
|
|
|
++ llit )
|
|
|
|
{
|
|
|
|
const char* libName = llit->first.c_str();
|
|
|
|
if (this->IgnoreThisTarget(libName))
|
|
|
|
{
|
|
|
|
// Skip ignored targets
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::map<cmStdString, const cmTarget*>::const_iterator tarIt =
|
|
|
|
this->TargetPtrs.find(libName);
|
|
|
|
if ( tarIt == this->TargetPtrs.end() )
|
|
|
|
{
|
|
|
|
cmOStringStream ostr;
|
|
|
|
ostr << this->GraphNodePrefix << cnt++;
|
|
|
|
this->TargetNamesNodes[libName] = ostr.str();
|
|
|
|
this->TargetPtrs[libName] = NULL;
|
|
|
|
//str << " \"" << ostr.c_str() << "\" [ label=\"" << libName
|
|
|
|
//<< "\" shape=\"ellipse\"];" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-14 21:47:28 +03:00
|
|
|
bool cmGraphVizWriter::IgnoreThisTarget(const char* name)
|
2010-11-09 23:37:51 +03:00
|
|
|
{
|
2011-02-05 21:09:54 +03:00
|
|
|
for(std::vector<cmsys::RegularExpression>::iterator itvIt
|
|
|
|
= this->TargetsToIgnoreRegex.begin();
|
|
|
|
itvIt != this->TargetsToIgnoreRegex.end();
|
|
|
|
++ itvIt )
|
2010-11-14 21:47:28 +03:00
|
|
|
{
|
2011-02-05 21:09:54 +03:00
|
|
|
cmsys::RegularExpression& regEx = *itvIt;
|
|
|
|
if (regEx.is_valid())
|
2010-11-14 21:47:28 +03:00
|
|
|
{
|
2011-02-05 21:09:54 +03:00
|
|
|
if (regEx.find(name))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2010-11-14 21:47:28 +03:00
|
|
|
}
|
|
|
|
}
|
2011-02-05 21:09:54 +03:00
|
|
|
|
|
|
|
return false;
|
2010-11-09 23:37:51 +03:00
|
|
|
}
|
2010-11-14 21:30:58 +03:00
|
|
|
|
|
|
|
|
|
|
|
bool cmGraphVizWriter::GenerateForTargetType(cmTarget::TargetType targetType)
|
|
|
|
const
|
|
|
|
{
|
|
|
|
switch (targetType)
|
|
|
|
{
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
return this->GenerateForExecutables;
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
return this->GenerateForStaticLibs;
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
return this->GenerateForSharedLibs;
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
|
|
|
return this->GenerateForModuleLibs;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|