summaryrefslogtreecommitdiff
path: root/Source/cmDependsC.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-05-08 10:09:14 -0400
committerBrad King <brad.king@kitware.com>2008-05-08 10:09:14 -0400
commit12935b1599a2186950db644ff336aca16d725da0 (patch)
treea3ca5b852b4896ab4849dba8a7fb20f1182e7d42 /Source/cmDependsC.cxx
parent92198d6b37c26ad5fa41f8cbed28e35af15db1cc (diff)
downloadcmake-12935b1599a2186950db644ff336aca16d725da0.tar.gz
ENH: Light refactoring of implicit dependency scanning configuration implementation.
- Move lookup of config variables from cmLocalUnixMakefileGenerator3 to cmDepends hierarchy.
Diffstat (limited to 'Source/cmDependsC.cxx')
-rw-r--r--Source/cmDependsC.cxx68
1 files changed, 46 insertions, 22 deletions
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 5ac98bb951..3a6c00cdbe 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -18,6 +18,7 @@
#include "cmFileTimeComparison.h"
#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
#include "cmSystemTools.h"
#include <ctype.h> // isspace
@@ -31,25 +32,53 @@
#define INCLUDE_REGEX_COMPLAIN_MARKER "#IncludeRegexComplain: "
//----------------------------------------------------------------------------
-cmDependsC::cmDependsC():
- IncludePath(0)
+cmDependsC::cmDependsC()
{
}
+
//----------------------------------------------------------------------------
-// yummy look at all those constructor arguments
-cmDependsC::cmDependsC(std::vector<std::string> const& includes,
- const char* scanRegex, const char* complainRegex,
- const cmStdString& cacheFileName):
- IncludePath(&includes),
- IncludeRegexLine(INCLUDE_REGEX_LINE),
- IncludeRegexScan(scanRegex),
- IncludeRegexComplain(complainRegex),
- IncludeRegexLineString(INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE),
- IncludeRegexScanString(std::string(INCLUDE_REGEX_SCAN_MARKER)+scanRegex),
- IncludeRegexComplainString(
- std::string(INCLUDE_REGEX_COMPLAIN_MARKER)+complainRegex),
- CacheFileName(cacheFileName)
+cmDependsC::cmDependsC(cmLocalGenerator* lg, const char* targetDir,
+ const char* lang): cmDepends(lg, targetDir)
{
+ cmMakefile* mf = lg->GetMakefile();
+
+ // Configure the include file search path.
+ this->SetIncludePathFromLanguage(lang);
+
+ // Configure regular expressions.
+ std::string scanRegex = "^.*$";
+ std::string complainRegex = "^$";
+ {
+ std::string scanRegexVar = "CMAKE_";
+ scanRegexVar += lang;
+ scanRegexVar += "_INCLUDE_REGEX_SCAN";
+ if(const char* sr = mf->GetDefinition(scanRegexVar.c_str()))
+ {
+ scanRegex = sr;
+ }
+ std::string complainRegexVar = "CMAKE_";
+ complainRegexVar += lang;
+ complainRegexVar += "_INCLUDE_REGEX_COMPLAIN";
+ if(const char* cr = mf->GetDefinition(complainRegexVar.c_str()))
+ {
+ complainRegex = cr;
+ }
+ }
+
+ this->IncludeRegexLine.compile(INCLUDE_REGEX_LINE);
+ this->IncludeRegexScan.compile(scanRegex.c_str());
+ this->IncludeRegexComplain.compile(complainRegex.c_str());
+ this->IncludeRegexLineString = INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE;
+ this->IncludeRegexScanString = INCLUDE_REGEX_SCAN_MARKER;
+ this->IncludeRegexScanString += scanRegex;
+ this->IncludeRegexComplainString = INCLUDE_REGEX_COMPLAIN_MARKER;
+ this->IncludeRegexComplainString += complainRegex;
+
+ this->CacheFileName = this->TargetDirectory;
+ this->CacheFileName += "/";
+ this->CacheFileName += lang;
+ this->CacheFileName += ".includecache";
+
this->ReadCacheFile();
}
@@ -80,11 +109,6 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
cmSystemTools::Error("Cannot scan dependencies without an object file.");
return false;
}
- if(!this->IncludePath)
- {
- cmSystemTools::Error("Cannot scan dependencies without an include path.");
- return false;
- }
// Walk the dependency graph starting with the source file.
bool first = true;
@@ -138,7 +162,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
cacheKey += current.FileName;
for(std::vector<std::string>::const_iterator i =
- this->IncludePath->begin(); i != this->IncludePath->end(); ++i)
+ this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
{
cacheKey+=*i;
}
@@ -149,7 +173,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
fullName=headerLocationIt->second;
}
else for(std::vector<std::string>::const_iterator i =
- this->IncludePath->begin(); i != this->IncludePath->end(); ++i)
+ this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
{
// Construct the name of the file as if it were in the current
// include directory. Avoid using a leading "./".