fix #13474: also rescan dependencies if the depender does not exist

If the depender (e.g. foo.o) does not exist, also rescan dependencies if
one of the dependees (e.g. foo.cxx) is older than the already existing
depend.internal file, since this means it can be out of date.

Alex
This commit is contained in:
Alex Neundorf 2012-08-16 22:46:33 +02:00
parent c4306dc805
commit 87fe4286bd
2 changed files with 48 additions and 18 deletions

View File

@ -98,7 +98,7 @@ bool cmDepends::Check(const char *makeFile, const char *internalFile,
// Check whether dependencies must be regenerated. // Check whether dependencies must be regenerated.
bool okay = true; bool okay = true;
std::ifstream fin(internalFile); std::ifstream fin(internalFile);
if(!(fin && this->CheckDependencies(fin, validDeps))) if(!(fin && this->CheckDependencies(fin, internalFile, validDeps)))
{ {
// Clear all dependencies so they will be regenerated. // Clear all dependencies so they will be regenerated.
this->Clear(makeFile); this->Clear(makeFile);
@ -143,6 +143,7 @@ bool cmDepends::WriteDependencies(const char*, const char*,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmDepends::CheckDependencies(std::istream& internalDepends, bool cmDepends::CheckDependencies(std::istream& internalDepends,
const char* internalDependsFileName,
std::map<std::string, DependencyVector>& validDeps) std::map<std::string, DependencyVector>& validDeps)
{ {
// Parse dependencies from the stream. If any dependee is missing // Parse dependencies from the stream. If any dependee is missing
@ -186,8 +187,11 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
} }
*/ */
// Dependencies must be regenerated if the dependee does not exist // Dependencies must be regenerated
// or if the depender exists and is older than the dependee. // * if the dependee does not exist
// * if the depender exists and is older than the dependee.
// * if the depender does not exist, but the dependee is newer than the
// depends file
bool regenerate = false; bool regenerate = false;
const char* dependee = this->Dependee+1; const char* dependee = this->Dependee+1;
const char* depender = this->Depender; const char* depender = this->Depender;
@ -211,24 +215,49 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
cmSystemTools::Stdout(msg.str().c_str()); cmSystemTools::Stdout(msg.str().c_str());
} }
} }
else if(dependerExists) else
{ {
// The dependee and depender both exist. Compare file times. if(dependerExists)
int result = 0;
if((!this->FileComparison->FileTimeCompare(depender, dependee,
&result) || result < 0))
{ {
// The depender is older than the dependee. // The dependee and depender both exist. Compare file times.
regenerate = true; int result = 0;
if((!this->FileComparison->FileTimeCompare(depender, dependee,
// Print verbose output. &result) || result < 0))
if(this->Verbose)
{ {
cmOStringStream msg; // The depender is older than the dependee.
msg << "Dependee \"" << dependee regenerate = true;
<< "\" is newer than depender \""
<< depender << "\"." << std::endl; // Print verbose output.
cmSystemTools::Stdout(msg.str().c_str()); if(this->Verbose)
{
cmOStringStream msg;
msg << "Dependee \"" << dependee
<< "\" is newer than depender \""
<< depender << "\"." << std::endl;
cmSystemTools::Stdout(msg.str().c_str());
}
}
}
else
{
// The dependee exists, but the depender doesn't. Regenerate if the
// internalDepends file is older than the dependee.
int result = 0;
if((!this->FileComparison->FileTimeCompare(internalDependsFileName, dependee,
&result) || result < 0))
{
// The depends-file is older than the dependee.
regenerate = true;
// Print verbose output.
if(this->Verbose)
{
cmOStringStream msg;
msg << "Dependee \"" << dependee
<< "\" is newer than depends file \""
<< internalDependsFileName << "\"." << std::endl;
cmSystemTools::Stdout(msg.str().c_str());
}
} }
} }
} }

View File

@ -83,6 +83,7 @@ protected:
// Return false if dependencies must be regenerated and true // Return false if dependencies must be regenerated and true
// otherwise. // otherwise.
virtual bool CheckDependencies(std::istream& internalDepends, virtual bool CheckDependencies(std::istream& internalDepends,
const char* internalDependsFileName,
std::map<std::string, DependencyVector>& validDeps); std::map<std::string, DependencyVector>& validDeps);
// Finalize the dependency information for the target. // Finalize the dependency information for the target.