summaryrefslogtreecommitdiffstats
path: root/Source/cmDependsC.cxx
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2012-09-30 08:57:59 (GMT)
committerAlex Neundorf <neundorf@kde.org>2012-11-03 17:45:34 (GMT)
commit3e7d97d45d167ddab5ebef6a6fd936df3441c4c9 (patch)
treec66eba11df2ce757432a2a528452fc8ff8e03c8b /Source/cmDependsC.cxx
parentb4e8f49b95bc13939347623b2b9f236e22bd37ec (diff)
downloadCMake-3e7d97d45d167ddab5ebef6a6fd936df3441c4c9.zip
CMake-3e7d97d45d167ddab5ebef6a6fd936df3441c4c9.tar.gz
CMake-3e7d97d45d167ddab5ebef6a6fd936df3441c4c9.tar.bz2
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>
Diffstat (limited to 'Source/cmDependsC.cxx')
-rw-r--r--Source/cmDependsC.cxx22
1 files changed, 8 insertions, 14 deletions
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 44841a9..b760429 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -113,32 +113,26 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
return false;
}
+ std::set<cmStdString> dependencies;
+ bool haveDeps = false;
+
if (this->ValidDeps != 0)
{
std::map<std::string, DependencyVector>::const_iterator tmpIt =
this->ValidDeps->find(obj);
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();
i != tmpIt->second.end(); ++i)
{
- makeDepends << obj << ": " <<
- this->LocalGenerator->Convert(i->c_str(),
- cmLocalGenerator::HOME_OUTPUT,
- cmLocalGenerator::MAKEFILE)
- << std::endl;
- internalDepends << " " << i->c_str() << std::endl;
+ dependencies.insert(*i);
}
- makeDepends << std::endl;
- return true;
+ haveDeps = true;
}
}
+ if (!haveDeps)
+ {
// Walk the dependency graph starting with the source file.
bool first = true;
UnscannedEntry root;
@@ -146,7 +140,6 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
this->Unscanned.push(root);
this->Encountered.clear();
this->Encountered.insert(src);
- std::set<cmStdString> dependencies;
std::set<cmStdString> scanned;
// Use reserve to allocate enough memory for tempPathStr
@@ -269,6 +262,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
first = false;
}
+ }
// Write the dependencies to the output stream. Makefile rules
// written by the original local generator for this directory