cmDependsC: remove code duplication
This patch reduces a bit code duplication by changing the way how the case that we already have valid dependencies for a file is handled. Instead of having the code for writing the depend-files twice, we now fill the existing dependencies into the same set and then write it out once at the end of cmDependsC::WriteDependencies() Alex Inspired-by: Michael Wild <themiwi@users.sourceforge.net>
This commit is contained in:
parent
b4e8f49b95
commit
3e7d97d45d
|
@ -113,32 +113,26 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<cmStdString> dependencies;
|
||||||
|
bool haveDeps = false;
|
||||||
|
|
||||||
if (this->ValidDeps != 0)
|
if (this->ValidDeps != 0)
|
||||||
{
|
{
|
||||||
std::map<std::string, DependencyVector>::const_iterator tmpIt =
|
std::map<std::string, DependencyVector>::const_iterator tmpIt =
|
||||||
this->ValidDeps->find(obj);
|
this->ValidDeps->find(obj);
|
||||||
if (tmpIt!= this->ValidDeps->end())
|
if (tmpIt!= this->ValidDeps->end())
|
||||||
{
|
{
|
||||||
// Write the dependencies to the output stream. Makefile rules
|
|
||||||
// written by the original local generator for this directory
|
|
||||||
// convert the dependencies to paths relative to the home output
|
|
||||||
// directory. We must do the same here.
|
|
||||||
internalDepends << obj << std::endl;
|
|
||||||
for(DependencyVector::const_iterator i=tmpIt->second.begin();
|
for(DependencyVector::const_iterator i=tmpIt->second.begin();
|
||||||
i != tmpIt->second.end(); ++i)
|
i != tmpIt->second.end(); ++i)
|
||||||
{
|
{
|
||||||
makeDepends << obj << ": " <<
|
dependencies.insert(*i);
|
||||||
this->LocalGenerator->Convert(i->c_str(),
|
|
||||||
cmLocalGenerator::HOME_OUTPUT,
|
|
||||||
cmLocalGenerator::MAKEFILE)
|
|
||||||
<< std::endl;
|
|
||||||
internalDepends << " " << i->c_str() << std::endl;
|
|
||||||
}
|
}
|
||||||
makeDepends << std::endl;
|
haveDeps = true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!haveDeps)
|
||||||
|
{
|
||||||
// Walk the dependency graph starting with the source file.
|
// Walk the dependency graph starting with the source file.
|
||||||
bool first = true;
|
bool first = true;
|
||||||
UnscannedEntry root;
|
UnscannedEntry root;
|
||||||
|
@ -146,7 +140,6 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
|
||||||
this->Unscanned.push(root);
|
this->Unscanned.push(root);
|
||||||
this->Encountered.clear();
|
this->Encountered.clear();
|
||||||
this->Encountered.insert(src);
|
this->Encountered.insert(src);
|
||||||
std::set<cmStdString> dependencies;
|
|
||||||
std::set<cmStdString> scanned;
|
std::set<cmStdString> scanned;
|
||||||
|
|
||||||
// Use reserve to allocate enough memory for tempPathStr
|
// Use reserve to allocate enough memory for tempPathStr
|
||||||
|
@ -269,6 +262,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Write the dependencies to the output stream. Makefile rules
|
// Write the dependencies to the output stream. Makefile rules
|
||||||
// written by the original local generator for this directory
|
// written by the original local generator for this directory
|
||||||
|
|
Loading…
Reference in New Issue