ENH: Added optional verbose output to build system dependency check.

This commit is contained in:
Brad King 2005-05-06 09:58:58 -04:00
parent 6f35a272a7
commit e8911705d6
11 changed files with 84 additions and 31 deletions

View File

@ -22,11 +22,12 @@
#include <assert.h> #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_Directory(dir),
m_TargetFile(targetFile), m_TargetFile(targetFile),
m_DependsMakeFile(dir), m_DependsMakeFile(dir),
m_DependsMarkFile(dir) m_DependsMarkFile(dir),
m_Verbose(verbose)
{ {
// Construct the path to the make and mark files. Append // Construct the path to the make and mark files. Append
// appropriate extensions to their names. // appropriate extensions to their names.
@ -97,6 +98,14 @@ void cmDepends::Check()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmDepends::Clear() 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 // Remove the dependency mark file to be sure dependencies will be
// regenerated. // regenerated.
cmSystemTools::RemoveFile(m_DependsMarkFile.c_str()); cmSystemTools::RemoveFile(m_DependsMarkFile.c_str());

View File

@ -31,7 +31,7 @@ class cmDepends
public: public:
/** Instances need to know the build directory name and the relative /** Instances need to know the build directory name and the relative
path from the build directory to the target file. */ 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 destructor to cleanup subclasses properly. */
virtual ~cmDepends(); virtual ~cmDepends();
@ -74,6 +74,9 @@ protected:
// The name of the .depends file marking when dependencies were generated. // The name of the .depends file marking when dependencies were generated.
std::string m_DependsMarkFile; std::string m_DependsMarkFile;
// Flag for verbose output.
bool m_Verbose;
private: private:
cmDepends(cmDepends const&); // Purposely not implemented. cmDepends(cmDepends const&); // Purposely not implemented.
void operator=(cmDepends const&); // Purposely not implemented. void operator=(cmDepends const&); // Purposely not implemented.

View File

@ -19,8 +19,8 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsC::cmDependsC(const char* dir, const char* targetFile): cmDependsC::cmDependsC(const char* dir, const char* targetFile, bool verbose):
cmDepends(dir, targetFile), cmDepends(dir, targetFile, verbose),
m_SourceFile(), m_SourceFile(),
m_IncludePath(0), m_IncludePath(0),
m_IncludeRegexLine(), m_IncludeRegexLine(),
@ -34,7 +34,7 @@ cmDependsC::cmDependsC(const char* dir, const char* targetFile,
const char* sourceFile, const char* sourceFile,
std::vector<std::string> const& includes, std::vector<std::string> const& includes,
const char* scanRegex, const char* complainRegex): const char* scanRegex, const char* complainRegex):
cmDepends(dir, targetFile), cmDepends(dir, targetFile, false),
m_SourceFile(sourceFile), m_SourceFile(sourceFile),
m_IncludePath(&includes), m_IncludePath(&includes),
m_IncludeRegexLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)([\">])"), 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 // Dependencies must be regenerated if the dependee does not exist
// or if the depender exists and is older than the dependee. // or if the depender exists and is older than the dependee.
int result = 0; bool regenerate = false;
if(!cmSystemTools::FileExists(dependee.c_str()) || if(!cmSystemTools::FileExists(dependee.c_str()))
(cmSystemTools::FileExists(depender.c_str()) && {
(!cmSystemTools::FileTimeCompare(depender.c_str(), dependee.c_str(), // The dependee does not exist.
&result) || result < 0))) 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. // Dependencies must be regenerated.
okay = false; okay = false;

View File

@ -29,7 +29,7 @@ class cmDependsC: public cmDepends
public: public:
/** Checking instances need to know the build directory name and the /** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */ 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 /** Scanning need to know the build directory name, the relative
path from the build directory to the target file, the source path from the build directory to the target file, the source

View File

@ -76,8 +76,9 @@ struct cmDependsFortranParser_s
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile): cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile,
cmDepends(dir, targetFile), bool verbose):
cmDepends(dir, targetFile, verbose),
m_SourceFile(), m_SourceFile(),
m_IncludePath(0) m_IncludePath(0)
{ {
@ -87,7 +88,7 @@ cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile):
cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile, cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile,
const char* sourceFile, const char* sourceFile,
std::vector<std::string> const& includes): std::vector<std::string> const& includes):
cmDepends(dir, targetFile), cmDepends(dir, targetFile, false),
m_SourceFile(sourceFile), m_SourceFile(sourceFile),
m_IncludePath(&includes) m_IncludePath(&includes)
{ {

View File

@ -27,7 +27,7 @@ class cmDependsFortran: public cmDepends
public: public:
/** Checking instances need to know the build directory name and the /** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */ 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 /** Scanning need to know the build directory name, the relative
path from the build directory to the target file, the source path from the build directory to the target file, the source

View File

@ -20,8 +20,9 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsJava::cmDependsJava(const char* dir, const char* targetFile): cmDependsJava::cmDependsJava(const char* dir, const char* targetFile,
cmDepends(dir, targetFile), bool verbose):
cmDepends(dir, targetFile, verbose),
m_SourceFile() m_SourceFile()
{ {
} }
@ -29,7 +30,7 @@ cmDependsJava::cmDependsJava(const char* dir, const char* targetFile):
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsJava::cmDependsJava(const char* dir, const char* targetFile, cmDependsJava::cmDependsJava(const char* dir, const char* targetFile,
const char* sourceFile): const char* sourceFile):
cmDepends(dir, targetFile), cmDepends(dir, targetFile, false),
m_SourceFile(sourceFile) m_SourceFile(sourceFile)
{ {
} }

View File

@ -27,7 +27,7 @@ class cmDependsJava: public cmDepends
public: public:
/** Checking instances need to know the build directory name and the /** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */ 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 /** Scanning need to know the build directory name, the relative
path from the build directory to the target file and the source path from the build directory to the target file and the source

View File

@ -822,7 +822,7 @@ cmLocalUnixMakefileGenerator2
std::auto_ptr<cmDepends> std::auto_ptr<cmDepends>
checker(this->GetDependsChecker(lang, checker(this->GetDependsChecker(lang,
m_Makefile->GetStartOutputDirectory(), m_Makefile->GetStartOutputDirectory(),
objFile)); objFile, false));
if(checker.get()) if(checker.get())
{ {
// Save the make and mark file names. // Save the make and mark file names.
@ -3099,20 +3099,21 @@ cmLocalUnixMakefileGenerator2
cmDepends* cmDepends*
cmLocalUnixMakefileGenerator2::GetDependsChecker(const std::string& lang, cmLocalUnixMakefileGenerator2::GetDependsChecker(const std::string& lang,
const char* dir, const char* dir,
const char* objFile) const char* objFile,
bool verbose)
{ {
if(lang == "C" || lang == "CXX" || lang == "RC") if(lang == "C" || lang == "CXX" || lang == "RC")
{ {
return new cmDependsC(dir, objFile); return new cmDependsC(dir, objFile, verbose);
} }
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
else if(lang == "Fortran") else if(lang == "Fortran")
{ {
return new cmDependsFortran(dir, objFile); return new cmDependsFortran(dir, objFile, verbose);
} }
else if(lang == "Java") else if(lang == "Java")
{ {
return new cmDependsJava(dir, objFile); return new cmDependsJava(dir, objFile, verbose);
} }
#endif #endif
return 0; 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. // Get the list of languages that may have sources to check.
const char* langDef = mf->GetDefinition("CMAKE_DEPENDS_LANGUAGES"); const char* langDef = mf->GetDefinition("CMAKE_DEPENDS_LANGUAGES");
@ -3249,7 +3251,7 @@ void cmLocalUnixMakefileGenerator2::CheckDependencies(cmMakefile* mf)
// Construct a checker for the given language. // Construct a checker for the given language.
std::auto_ptr<cmDepends> std::auto_ptr<cmDepends>
checker(cmLocalUnixMakefileGenerator2 checker(cmLocalUnixMakefileGenerator2
::GetDependsChecker(*l, ".", f->c_str())); ::GetDependsChecker(*l, ".", f->c_str(), verbose));
if(checker.get()) if(checker.get())
{ {
checker->Check(); checker->Check();

View File

@ -97,7 +97,7 @@ public:
static bool ScanDependencies(std::vector<std::string> const& args); static bool ScanDependencies(std::vector<std::string> const& args);
/** Called from command-line hook to check dependencies. */ /** Called from command-line hook to check dependencies. */
static void CheckDependencies(cmMakefile* mf); static void CheckDependencies(cmMakefile* mf, bool verbose);
protected: protected:
@ -235,7 +235,8 @@ protected:
static cmDepends* GetDependsChecker(const std::string& lang, static cmDepends* GetDependsChecker(const std::string& lang,
const char* dir, const char* dir,
const char* objFile); const char* objFile,
bool verbose);
private: private:
// Map from target name to build directory containing it for // Map from target name to build directory containing it for

View File

@ -1614,8 +1614,11 @@ int cmake::CheckBuildSystem()
} }
} }
// We do not need to rerun CMake. Check dependency integrity. // We do not need to rerun CMake. Check dependency integrity. Use
cmLocalUnixMakefileGenerator2::CheckDependencies(mf); // the make system's VERBOSE environment variable to enable verbose
// output.
bool verbose = cmSystemTools::GetEnv("VERBOSE");
cmLocalUnixMakefileGenerator2::CheckDependencies(mf, verbose);
// No need to rerun. // No need to rerun.
return 0; return 0;