summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-12-23 03:41:42 (GMT)
committerBrad King <brad.king@kitware.com>2007-12-23 03:41:42 (GMT)
commit4d360f7ac56939ede629e368fb282d4022f69d6c (patch)
treec4ba214154fa085fe06dfbf17d080e41661ee48d
parenta7245e47925f51b8b648b1eb075f3ecec2b5ce76 (diff)
downloadCMake-4d360f7ac56939ede629e368fb282d4022f69d6c.zip
CMake-4d360f7ac56939ede629e368fb282d4022f69d6c.tar.gz
CMake-4d360f7ac56939ede629e368fb282d4022f69d6c.tar.bz2
ENH: Convert cmDepends object interface to scan an entire target at once.
-rw-r--r--Source/cmDepends.cxx37
-rw-r--r--Source/cmDepends.h14
-rw-r--r--Source/cmDependsFortran.cxx5
-rw-r--r--Source/cmDependsFortran.h6
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx22
5 files changed, 53 insertions, 31 deletions
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 93beee6..327f508 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -16,6 +16,8 @@
=========================================================================*/
#include "cmDepends.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
#include "cmFileTimeComparison.h"
@@ -41,10 +43,39 @@ cmDepends::~cmDepends()
}
//----------------------------------------------------------------------------
-bool cmDepends::Write(const char *src, const char *obj,
- std::ostream &makeDepends, std::ostream &internalDepends)
+bool cmDepends::Write(std::ostream &makeDepends,
+ std::ostream &internalDepends)
{
- return this->WriteDependencies(src, obj, makeDepends, internalDepends);
+ // Lookup the set of sources to scan.
+ std::string srcLang = "CMAKE_DEPENDS_CHECK_";
+ srcLang += this->Language;
+ cmMakefile* mf = this->LocalGenerator->GetMakefile();
+ const char* srcStr = mf->GetSafeDefinition(srcLang.c_str());
+ std::vector<std::string> pairs;
+ cmSystemTools::ExpandListArgument(srcStr, pairs);
+
+ for(std::vector<std::string>::iterator si = pairs.begin();
+ si != pairs.end();)
+ {
+ // Get the source and object file.
+ std::string const& src = *si++;
+ if(si == pairs.end()) { break; }
+ std::string obj = *si++;
+
+ // Make sure the object file is relative to the top of the build tree.
+ obj = this->LocalGenerator->Convert(obj.c_str(),
+ cmLocalGenerator::HOME_OUTPUT,
+ cmLocalGenerator::MAKEFILE);
+
+ // Write the dependencies for this pair.
+ if(!this->WriteDependencies(src.c_str(), obj.c_str(),
+ makeDepends, internalDepends))
+ {
+ return false;
+ }
+ }
+
+ return true;
}
//----------------------------------------------------------------------------
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index 40dc59a..4f7a02b 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -45,6 +45,12 @@ public:
directory. */
void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; }
+ /** Set the specific language to be scanned. */
+ void SetLanguage(const char* lang) { this->Language = lang; }
+
+ /** Set the target build directory. */
+ void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
+
/** should this be verbose in its output */
void SetVerbose(bool verb) { this->Verbose = verb; }
@@ -52,8 +58,7 @@ public:
virtual ~cmDepends();
/** Write dependencies for the target file. */
- bool Write(const char *src, const char *obj,
- std::ostream &makeDepends, std::ostream &internalDepends);
+ bool Write(std::ostream &makeDepends, std::ostream &internalDepends);
/** Check dependencies for the target file. Returns true if
dependencies are okay and false if they must be generated. If
@@ -90,6 +95,11 @@ protected:
bool Verbose;
cmFileTimeComparison* FileComparison;
+ std::string Language;
+
+ // The full path to the target's build directory.
+ std::string TargetDirectory;
+
size_t MaxPath;
char* Dependee;
char* Depender;
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index 34aa39d..b0c666f 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -90,9 +90,8 @@ cmDependsFortran::cmDependsFortran():
}
//----------------------------------------------------------------------------
-cmDependsFortran::cmDependsFortran(std::vector<std::string> const& includes,
- std::string const& targetDirectory):
- IncludePath(&includes), TargetDirectory(targetDirectory)
+cmDependsFortran::cmDependsFortran(std::vector<std::string> const& includes):
+ IncludePath(&includes)
{
}
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index 3b35315..9ed087f 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -33,8 +33,7 @@ public:
path from the build directory to the target file, the source
file from which to start scanning, the include file search
path, and the target directory. */
- cmDependsFortran(std::vector<std::string> const& includes,
- std::string const& targetDirectory);
+ cmDependsFortran(std::vector<std::string> const& includes);
/** Virtual destructor to cleanup subclasses properly. */
virtual ~cmDependsFortran();
@@ -62,9 +61,6 @@ protected:
// The include file search path.
std::vector<std::string> const* IncludePath;
- // The full path to the target's build directory.
- std::string TargetDirectory;
-
private:
cmDependsFortran(cmDependsFortran const&); // Purposely not implemented.
void operator=(cmDependsFortran const&); // Purposely not implemented.
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 550165b..49a068c 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1412,7 +1412,7 @@ cmLocalUnixMakefileGenerator3
#ifdef CMAKE_BUILD_WITH_CMAKE
else if(lang == "Fortran")
{
- scanner = new cmDependsFortran(includes, dir);
+ scanner = new cmDependsFortran(includes);
}
else if(lang == "Java")
{
@@ -1425,23 +1425,9 @@ cmLocalUnixMakefileGenerator3
scanner->SetLocalGenerator(this);
scanner->SetFileComparison
(this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
- // for each file we need to scan
- std::string srcLang = "CMAKE_DEPENDS_CHECK_";
- srcLang += lang;
- const char *srcStr = mf->GetSafeDefinition(srcLang.c_str());
- std::vector<std::string> srcs;
- cmSystemTools::ExpandListArgument(srcStr, srcs);
- for (std::vector<std::string>::iterator si =
- srcs.begin(); si != srcs.end(); ++si)
- {
- std::string &src = *si;
- ++si;
- // make sure the object file is relative to home output
- std::string obj = *si;
- obj = this->Convert(obj.c_str(),HOME_OUTPUT,MAKEFILE);
- scanner->Write(src.c_str(),obj.c_str(),
- ruleFileStream, internalRuleFileStream);
- }
+ scanner->SetLanguage(lang.c_str());
+ scanner->SetTargetDirectory(dir.c_str());
+ scanner->Write(ruleFileStream, internalRuleFileStream);
// free the scanner for this language
delete scanner;