mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
ENH: Added optional verbose output to build system dependency check.
This commit is contained in:
parent
6f35a272a7
commit
e8911705d6
@ -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());
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user