diff options
-rw-r--r-- | Source/cmGraphVizWriter.cxx | 190 | ||||
-rw-r--r-- | Source/cmGraphVizWriter.h | 11 | ||||
-rw-r--r-- | Source/cmake.cxx | 1 | ||||
-rw-r--r-- | Source/kwsys/CheckCXXSourceRuns.cmake | 62 | ||||
-rw-r--r-- | Source/kwsys/kwsysDateStamp.cmake | 2 |
5 files changed, 178 insertions, 88 deletions
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index de95aa5..15bad52 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -54,6 +54,7 @@ cmGraphVizWriter::cmGraphVizWriter(const std::vector<cmLocalGenerator*>& ,GenerateForStaticLibs(true) ,GenerateForSharedLibs(true) ,GenerateForModuleLibs(true) +,GenerateForExternals(true) ,LocalGenerators(localGenerators) ,HaveTargetsAndLibs(false) { @@ -115,36 +116,85 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, __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"); - __set_bool_if_set(this->GenerateForModuleLibs , "GRAPHVIZ_MODULE_LIBS"); + __set_bool_if_set(this->GenerateForModuleLibs, "GRAPHVIZ_MODULE_LIBS"); + __set_bool_if_set(this->GenerateForExternals, "GRAPHVIZ_EXTERNAL_LIBS"); - cmStdString tmpRegexString; - __set_if_set(tmpRegexString, "GRAPHVIZ_TARGET_IGNORE_REGEX"); - if (tmpRegexString.size() > 0) + cmStdString ignoreTargetsRegexes; + __set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS"); + + this->TargetsToIgnoreRegex.clear(); + if (ignoreTargetsRegexes.size() > 0) { - if (!this->TargetIgnoreRegex.compile(tmpRegexString.c_str())) + std::vector<std::string> ignoreTargetsRegExVector; + cmSystemTools::ExpandListArgument(ignoreTargetsRegexes, + ignoreTargetsRegExVector); + for(std::vector<std::string>::const_iterator itvIt + = ignoreTargetsRegExVector.begin(); + itvIt != ignoreTargetsRegExVector.end(); + ++ itvIt ) { - std::cerr << "Could not compile bad regex \"" << tmpRegexString << "\"" - << std::endl; + 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); } } - this->TargetsToIgnore.clear(); - const char* ignoreTargets = mf->GetDefinition("GRAPHVIZ_IGNORE_TARGETS"); - if ( ignoreTargets ) +} + + +// 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) { - std::vector<std::string> ignoreTargetsVector; - cmSystemTools::ExpandListArgument(ignoreTargets,ignoreTargetsVector); - for(std::vector<std::string>::iterator itvIt = ignoreTargetsVector.begin(); - itvIt != ignoreTargetsVector.end(); - ++ itvIt ) + if (ptrIt->second == NULL) { - this->TargetsToIgnore.insert(itvIt->c_str()); + 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. void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) { this->CollectTargetsAndLibs(); @@ -297,6 +347,91 @@ void cmGraphVizWriter::WriteConnections(const char* targetName, } +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; + } + } + } + +} + + void cmGraphVizWriter::WriteNode(const char* targetName, const cmTarget* target, std::set<std::string>& insertedNodes, @@ -321,7 +456,10 @@ void cmGraphVizWriter::CollectTargetsAndLibs() { this->HaveTargetsAndLibs = true; int cnt = this->CollectAllTargets(); - this->CollectAllExternalLibs(cnt); + if (this->GenerateForExternals) + { + this->CollectAllExternalLibs(cnt); + } } } @@ -410,14 +548,22 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) bool cmGraphVizWriter::IgnoreThisTarget(const char* name) { - if (this->TargetIgnoreRegex.is_valid()) + for(std::vector<cmsys::RegularExpression>::iterator itvIt + = this->TargetsToIgnoreRegex.begin(); + itvIt != this->TargetsToIgnoreRegex.end(); + ++ itvIt ) { - if (this->TargetIgnoreRegex.find(name)) + cmsys::RegularExpression& regEx = *itvIt; + if (regEx.is_valid()) { - return true; + if (regEx.find(name)) + { + return true; + } } } - return (this->TargetsToIgnore.find(name) != this->TargetsToIgnore.end()); + + return false; } diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 105eb96..f784aa0 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -30,6 +30,7 @@ public: const char* fallbackSettingsFileName); void WritePerTargetFiles(const char* fileName); + void WriteTargetDependersFiles(const char* fileName); void WriteGlobalFile(const char* fileName); @@ -48,6 +49,11 @@ protected: std::set<std::string>& insertedConnections, cmGeneratedFileStream& str) const; + void WriteDependerConnections(const char* targetName, + std::set<std::string>& insertedNodes, + std::set<std::string>& insertedConnections, + cmGeneratedFileStream& str) const; + void WriteNode(const char* targetName, const cmTarget* target, std::set<std::string>& insertedNodes, cmGeneratedFileStream& str) const; @@ -67,10 +73,9 @@ protected: bool GenerateForStaticLibs; bool GenerateForSharedLibs; bool GenerateForModuleLibs; + bool GenerateForExternals; - cmsys::RegularExpression TargetIgnoreRegex; - - std::set<cmStdString> TargetsToIgnore; + std::vector<cmsys::RegularExpression> TargetsToIgnoreRegex; const std::vector<cmLocalGenerator*>& LocalGenerators; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 4eef7dd..45927cb 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2932,6 +2932,7 @@ void cmake::GenerateGraphViz(const char* fileName) const gvWriter->ReadSettings(settingsFile.c_str(), fallbackSettingsFile.c_str()); gvWriter->WritePerTargetFiles(fileName); + gvWriter->WriteTargetDependersFiles(fileName); gvWriter->WriteGlobalFile(fileName); #endif diff --git a/Source/kwsys/CheckCXXSourceRuns.cmake b/Source/kwsys/CheckCXXSourceRuns.cmake deleted file mode 100644 index 7bcc873..0000000 --- a/Source/kwsys/CheckCXXSourceRuns.cmake +++ /dev/null @@ -1,62 +0,0 @@ -# - Check if the source code provided in the SOURCE argument compiles. -# CHECK_CXX_SOURCE_COMPILES(SOURCE VAR) -# - macro which checks if the source code compiles\ -# SOURCE - source code to try to compile -# VAR - variable to store size if the type exists. -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -MACRO(CHECK_CXX_SOURCE_RUNS SOURCE VAR COMMENT) - IF("HAVE_${VAR}" MATCHES "^HAVE_${VAR}$") - SET(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") - IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - ELSE(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES) - ENDIF(CMAKE_REQUIRED_LIBRARIES) - IF(CMAKE_REQUIRED_INCLUDES) - SET(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - ELSE(CMAKE_REQUIRED_INCLUDES) - SET(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES) - ENDIF(CMAKE_REQUIRED_INCLUDES) - SET(CMAKE_EMPTY_INPUT_FILE_CONTENT "${SOURCE}") - CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/CMakeEmptyInputFile.in" - "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx" IMMEDIATE) - - MESSAGE(STATUS "Performing Test ${COMMENT}") - TRY_RUN(${VAR} HAVE_${VAR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}" - "${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - IF(HAVE_${VAR}) - SET(${VAR} 1 CACHE INTERNAL "Test ${COMMENT}") - MESSAGE(STATUS "Performing Test ${COMMENT} - Success") - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log - "Performing C++ SOURCE FILE Test ${COMMENT} succeded with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - ELSE(HAVE_${VAR}) - MESSAGE(STATUS "Performing Test ${COMMENT} - Failed") - SET(${VAR} "" CACHE INTERNAL "Test ${COMMENT}") - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log - "Performing C++ SOURCE FILE Test ${COMMENT} failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - ENDIF(HAVE_${VAR}) - ENDIF("HAVE_${VAR}" MATCHES "^HAVE_${VAR}$") -ENDMACRO(CHECK_CXX_SOURCE_RUNS) - - diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index cae4bbd..8bba471 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 04) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 12) +SET(KWSYS_DATE_STAMP_DAY 19) |