summaryrefslogtreecommitdiffstats
path: root/Source/cmMakeDepend.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2001-06-21 19:02:52 (GMT)
committerBrad King <brad.king@kitware.com>2001-06-21 19:02:52 (GMT)
commitcf829929649c3dc7871e653de33580679c2db558 (patch)
tree67d62b23de64b1845c7601a845d53591c96d8e32 /Source/cmMakeDepend.cxx
parent8ffe832e9bc22deddef38eed1c19fe437b5d031f (diff)
downloadCMake-cf829929649c3dc7871e653de33580679c2db558.zip
CMake-cf829929649c3dc7871e653de33580679c2db558.tar.gz
CMake-cf829929649c3dc7871e653de33580679c2db558.tar.bz2
ENH: Extended INCLUDE_REGULAR_EXPRESSION to allow selective complaints about missing dependencies.
Diffstat (limited to 'Source/cmMakeDepend.cxx')
-rw-r--r--Source/cmMakeDepend.cxx49
1 files changed, 19 insertions, 30 deletions
diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx
index fe26219..55b3d90 100644
--- a/Source/cmMakeDepend.cxx
+++ b/Source/cmMakeDepend.cxx
@@ -45,7 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmMakeDepend::cmMakeDepend()
{
m_Verbose = false;
- m_IncludeFileRegularExpression.compile("");
+ m_IncludeFileRegularExpression.compile("^.*$");
+ m_ComplainFileRegularExpression.compile("^$");
}
@@ -71,6 +72,8 @@ void cmMakeDepend::SetMakefile(const cmMakefile* makefile)
// Now extract the include file regular expression from the makefile.
m_IncludeFileRegularExpression.compile(
m_Makefile->m_IncludeFileRegularExpression.c_str());
+ m_ComplainFileRegularExpression.compile(
+ m_Makefile->m_ComplainFileRegularExpression.c_str());
// Now extract any include paths from the makefile flags
const std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
@@ -200,7 +203,16 @@ void cmMakeDepend::Depend(cmDependInformation* info)
}
// Couldn't find any dependency information.
- cmSystemTools::Error("error cannot find dependencies for ", path);
+ if(m_ComplainFileRegularExpression.find(info->m_IncludeName.c_str()))
+ {
+ cmSystemTools::Error("error cannot find dependencies for ", path);
+ }
+ else
+ {
+ // Destroy the name of the file so that it won't be output as a
+ // dependency.
+ info->m_FullPath = "";
+ }
}
@@ -208,6 +220,7 @@ void cmMakeDepend::Depend(cmDependInformation* info)
// #include directives
void cmMakeDepend::DependWalk(cmDependInformation* info, const char* file)
{
+ cmRegularExpression includeLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]");
std::ifstream fin(file);
if(!fin)
{
@@ -216,37 +229,12 @@ void cmMakeDepend::DependWalk(cmDependInformation* info, const char* file)
}
char line[255];
- while(!fin.eof() && !fin.fail())
+ for(fin.getline(line, 255); !fin.eof()&&!fin.fail(); fin.getline(line, 255))
{
- fin.getline(line, 255);
- if(!strncmp(line, "#include", 8))
+ if(includeLine.find(line))
{
- // if it is an include line then create a string class
- std::string currentline = line;
- size_t qstart = currentline.find('\"', 8);
- size_t qend;
- // if a quote is not found look for a <
- if(qstart == std::string::npos)
- {
- qstart = currentline.find('<', 8);
- // if a < is not found then move on
- if(qstart == std::string::npos)
- {
- cmSystemTools::Error("unknown include directive ",
- currentline.c_str() );
- continue;
- }
- else
- {
- qend = currentline.find('>', qstart+1);
- }
- }
- else
- {
- qend = currentline.find('\"', qstart+1);
- }
// extract the file being included
- std::string includeFile = currentline.substr(qstart+1, qend - qstart-1);
+ std::string includeFile = includeLine.match(1);
// see if the include matches the regular expression
if(!m_IncludeFileRegularExpression.find(includeFile))
{
@@ -352,6 +340,7 @@ std::string cmMakeDepend::FullPath(const char* fname)
}
}
+ // Couldn't find the file.
return std::string(fname);
}