diff options
author | Brad King <brad.king@kitware.com> | 2005-05-06 13:58:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-05-06 13:58:58 (GMT) |
commit | e8911705d6a790904f0c98f303de6ae370c60595 (patch) | |
tree | 3d612ebce8ed229dcb773797a8fc709005197df1 | |
parent | 6f35a272a71a3eb642ddfa378dd6a1c4f1e9476a (diff) | |
download | CMake-e8911705d6a790904f0c98f303de6ae370c60595.zip CMake-e8911705d6a790904f0c98f303de6ae370c60595.tar.gz CMake-e8911705d6a790904f0c98f303de6ae370c60595.tar.bz2 |
ENH: Added optional verbose output to build system dependency check.
-rw-r--r-- | Source/cmDepends.cxx | 13 | ||||
-rw-r--r-- | Source/cmDepends.h | 5 | ||||
-rw-r--r-- | Source/cmDependsC.cxx | 49 | ||||
-rw-r--r-- | Source/cmDependsC.h | 2 | ||||
-rw-r--r-- | Source/cmDependsFortran.cxx | 7 | ||||
-rw-r--r-- | Source/cmDependsFortran.h | 2 | ||||
-rw-r--r-- | Source/cmDependsJava.cxx | 7 | ||||
-rw-r--r-- | Source/cmDependsJava.h | 2 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.cxx | 16 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.h | 5 | ||||
-rw-r--r-- | Source/cmake.cxx | 7 |
11 files changed, 84 insertions, 31 deletions
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 0972341..d2375fd 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -22,11 +22,12 @@ #include <assert.h> //---------------------------------------------------------------------------- -cmDepends::cmDepends(const char* dir, const char* targetFile): +cmDepends::cmDepends(const char* dir, const char* targetFile, bool verbose): m_Directory(dir), m_TargetFile(targetFile), m_DependsMakeFile(dir), - m_DependsMarkFile(dir) + m_DependsMarkFile(dir), + m_Verbose(verbose) { // Construct the path to the make and mark files. Append // appropriate extensions to their names. @@ -97,6 +98,14 @@ void cmDepends::Check() //---------------------------------------------------------------------------- void cmDepends::Clear() { + // Print verbose output. + if(m_Verbose) + { + cmOStringStream msg; + msg << "Clearing dependencies for \"" << m_TargetFile << "\"." << std::endl; + cmSystemTools::Stdout(msg.str().c_str()); + } + // Remove the dependency mark file to be sure dependencies will be // regenerated. cmSystemTools::RemoveFile(m_DependsMarkFile.c_str()); diff --git a/Source/cmDepends.h b/Source/cmDepends.h index dab1aac..f48c325 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -31,7 +31,7 @@ class cmDepends public: /** Instances need to know the build directory name and the relative path from the build directory to the target file. */ - cmDepends(const char* dir, const char* targetFile); + cmDepends(const char* dir, const char* targetFile, bool verbose); /** Virtual destructor to cleanup subclasses properly. */ virtual ~cmDepends(); @@ -74,6 +74,9 @@ protected: // The name of the .depends file marking when dependencies were generated. std::string m_DependsMarkFile; + // Flag for verbose output. + bool m_Verbose; + private: cmDepends(cmDepends const&); // Purposely not implemented. void operator=(cmDepends const&); // Purposely not implemented. diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index be7de45..6a64b6a 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -19,8 +19,8 @@ #include "cmSystemTools.h" //---------------------------------------------------------------------------- -cmDependsC::cmDependsC(const char* dir, const char* targetFile): - cmDepends(dir, targetFile), +cmDependsC::cmDependsC(const char* dir, const char* targetFile, bool verbose): + cmDepends(dir, targetFile, verbose), m_SourceFile(), m_IncludePath(0), m_IncludeRegexLine(), @@ -34,7 +34,7 @@ cmDependsC::cmDependsC(const char* dir, const char* targetFile, const char* sourceFile, std::vector<std::string> const& includes, const char* scanRegex, const char* complainRegex): - cmDepends(dir, targetFile), + cmDepends(dir, targetFile, false), m_SourceFile(sourceFile), m_IncludePath(&includes), m_IncludeRegexLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)([\">])"), @@ -231,11 +231,44 @@ bool cmDependsC::CheckDependencies(std::istream& is) // Dependencies must be regenerated if the dependee does not exist // or if the depender exists and is older than the dependee. - int result = 0; - if(!cmSystemTools::FileExists(dependee.c_str()) || - (cmSystemTools::FileExists(depender.c_str()) && - (!cmSystemTools::FileTimeCompare(depender.c_str(), dependee.c_str(), - &result) || result < 0))) + bool regenerate = false; + if(!cmSystemTools::FileExists(dependee.c_str())) + { + // The dependee does not exist. + regenerate = true; + + // Print verbose output. + if(m_Verbose) + { + cmOStringStream msg; + msg << "Dependee \"" << dependee + << "\" does not exist for depender \"" + << depender << "\"." << std::endl; + cmSystemTools::Stdout(msg.str().c_str()); + } + } + else if(cmSystemTools::FileExists(depender.c_str())) + { + // The dependee and depender both exist. Compare file times. + int result = 0; + if((!cmSystemTools::FileTimeCompare(depender.c_str(), dependee.c_str(), + &result) || result < 0)) + { + // The depender is older than the dependee. + regenerate = true; + + // Print verbose output. + if(m_Verbose) + { + cmOStringStream msg; + msg << "Dependee \"" << dependee + << "\" is newer than depender \"" + << depender << "\"." << std::endl; + cmSystemTools::Stdout(msg.str().c_str()); + } + } + } + if(regenerate) { // Dependencies must be regenerated. okay = false; diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index 229c7e9..8cc8842 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -29,7 +29,7 @@ class cmDependsC: public cmDepends public: /** Checking instances need to know the build directory name and the relative path from the build directory to the target file. */ - cmDependsC(const char* dir, const char* targetFile); + cmDependsC(const char* dir, const char* targetFile, bool verbose); /** Scanning need to know the build directory name, the relative path from the build directory to the target file, the source diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index eaae7bb..f063f29 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -76,8 +76,9 @@ struct cmDependsFortranParser_s }; //---------------------------------------------------------------------------- -cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile): - cmDepends(dir, targetFile), +cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile, + bool verbose): + cmDepends(dir, targetFile, verbose), m_SourceFile(), m_IncludePath(0) { @@ -87,7 +88,7 @@ cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile): cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile, const char* sourceFile, std::vector<std::string> const& includes): - cmDepends(dir, targetFile), + cmDepends(dir, targetFile, false), m_SourceFile(sourceFile), m_IncludePath(&includes) { diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h index 12456d7..8b09005 100644 --- a/Source/cmDependsFortran.h +++ b/Source/cmDependsFortran.h @@ -27,7 +27,7 @@ class cmDependsFortran: public cmDepends public: /** Checking instances need to know the build directory name and the relative path from the build directory to the target file. */ - cmDependsFortran(const char* dir, const char* targetFile); + cmDependsFortran(const char* dir, const char* targetFile, bool verbose); /** Scanning need to know the build directory name, the relative path from the build directory to the target file, the source diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx index 0d121f9..bf1ff21 100644 --- a/Source/cmDependsJava.cxx +++ b/Source/cmDependsJava.cxx @@ -20,8 +20,9 @@ #include "cmSystemTools.h" //---------------------------------------------------------------------------- -cmDependsJava::cmDependsJava(const char* dir, const char* targetFile): - cmDepends(dir, targetFile), +cmDependsJava::cmDependsJava(const char* dir, const char* targetFile, + bool verbose): + cmDepends(dir, targetFile, verbose), m_SourceFile() { } @@ -29,7 +30,7 @@ cmDependsJava::cmDependsJava(const char* dir, const char* targetFile): //---------------------------------------------------------------------------- cmDependsJava::cmDependsJava(const char* dir, const char* targetFile, const char* sourceFile): - cmDepends(dir, targetFile), + cmDepends(dir, targetFile, false), m_SourceFile(sourceFile) { } diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h index 4904fe1..579dad2 100644 --- a/Source/cmDependsJava.h +++ b/Source/cmDependsJava.h @@ -27,7 +27,7 @@ class cmDependsJava: public cmDepends public: /** Checking instances need to know the build directory name and the relative path from the build directory to the target file. */ - cmDependsJava(const char* dir, const char* targetFile); + cmDependsJava(const char* dir, const char* targetFile, bool verbose); /** Scanning need to know the build directory name, the relative path from the build directory to the target file and the source diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx index e8183ee..bf2a3c5 100644 --- a/Source/cmLocalUnixMakefileGenerator2.cxx +++ b/Source/cmLocalUnixMakefileGenerator2.cxx @@ -822,7 +822,7 @@ cmLocalUnixMakefileGenerator2 std::auto_ptr<cmDepends> checker(this->GetDependsChecker(lang, m_Makefile->GetStartOutputDirectory(), - objFile)); + objFile, false)); if(checker.get()) { // Save the make and mark file names. @@ -3099,20 +3099,21 @@ cmLocalUnixMakefileGenerator2 cmDepends* cmLocalUnixMakefileGenerator2::GetDependsChecker(const std::string& lang, const char* dir, - const char* objFile) + const char* objFile, + bool verbose) { if(lang == "C" || lang == "CXX" || lang == "RC") { - return new cmDependsC(dir, objFile); + return new cmDependsC(dir, objFile, verbose); } #ifdef CMAKE_BUILD_WITH_CMAKE else if(lang == "Fortran") { - return new cmDependsFortran(dir, objFile); + return new cmDependsFortran(dir, objFile, verbose); } else if(lang == "Java") { - return new cmDependsJava(dir, objFile); + return new cmDependsJava(dir, objFile, verbose); } #endif return 0; @@ -3220,7 +3221,8 @@ cmLocalUnixMakefileGenerator2 } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator2::CheckDependencies(cmMakefile* mf) +void cmLocalUnixMakefileGenerator2::CheckDependencies(cmMakefile* mf, + bool verbose) { // Get the list of languages that may have sources to check. const char* langDef = mf->GetDefinition("CMAKE_DEPENDS_LANGUAGES"); @@ -3249,7 +3251,7 @@ void cmLocalUnixMakefileGenerator2::CheckDependencies(cmMakefile* mf) // Construct a checker for the given language. std::auto_ptr<cmDepends> checker(cmLocalUnixMakefileGenerator2 - ::GetDependsChecker(*l, ".", f->c_str())); + ::GetDependsChecker(*l, ".", f->c_str(), verbose)); if(checker.get()) { checker->Check(); diff --git a/Source/cmLocalUnixMakefileGenerator2.h b/Source/cmLocalUnixMakefileGenerator2.h index 61ea950..645bb9e 100644 --- a/Source/cmLocalUnixMakefileGenerator2.h +++ b/Source/cmLocalUnixMakefileGenerator2.h @@ -97,7 +97,7 @@ public: static bool ScanDependencies(std::vector<std::string> const& args); /** Called from command-line hook to check dependencies. */ - static void CheckDependencies(cmMakefile* mf); + static void CheckDependencies(cmMakefile* mf, bool verbose); protected: @@ -235,7 +235,8 @@ protected: static cmDepends* GetDependsChecker(const std::string& lang, const char* dir, - const char* objFile); + const char* objFile, + bool verbose); private: // Map from target name to build directory containing it for diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 90a3dde..e9b5a17 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1614,8 +1614,11 @@ int cmake::CheckBuildSystem() } } - // We do not need to rerun CMake. Check dependency integrity. - cmLocalUnixMakefileGenerator2::CheckDependencies(mf); + // We do not need to rerun CMake. Check dependency integrity. Use + // the make system's VERBOSE environment variable to enable verbose + // output. + bool verbose = cmSystemTools::GetEnv("VERBOSE"); + cmLocalUnixMakefileGenerator2::CheckDependencies(mf, verbose); // No need to rerun. return 0; |