diff options
author | Brad King <brad.king@kitware.com> | 2001-06-21 19:02:52 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2001-06-21 19:02:52 (GMT) |
commit | cf829929649c3dc7871e653de33580679c2db558 (patch) | |
tree | 67d62b23de64b1845c7601a845d53591c96d8e32 /Source | |
parent | 8ffe832e9bc22deddef38eed1c19fe437b5d031f (diff) | |
download | CMake-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')
-rw-r--r-- | Source/cmIncludeRegularExpressionCommand.cxx | 7 | ||||
-rw-r--r-- | Source/cmIncludeRegularExpressionCommand.h | 10 | ||||
-rw-r--r-- | Source/cmMakeDepend.cxx | 49 | ||||
-rw-r--r-- | Source/cmMakeDepend.h | 1 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 7 | ||||
-rw-r--r-- | Source/cmMakefile.h | 10 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.cxx | 7 |
7 files changed, 53 insertions, 38 deletions
diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx index 39a1a65..2ccc556 100644 --- a/Source/cmIncludeRegularExpressionCommand.cxx +++ b/Source/cmIncludeRegularExpressionCommand.cxx @@ -43,13 +43,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // cmIncludeRegularExpressionCommand bool cmIncludeRegularExpressionCommand::InitialPass(std::vector<std::string>& args) { - if(args.size() != 1) + if((args.size() < 1) || (args.size() > 2)) { this->SetError("called with incorrect number of arguments"); return false; } m_Makefile->SetIncludeRegularExpression(args[0].c_str()); + if(args.size() > 1) + { + m_Makefile->SetComplainRegularExpression(args[1].c_str()); + } + return true; } diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h index 4e2b87e..fcec512 100644 --- a/Source/cmIncludeRegularExpressionCommand.h +++ b/Source/cmIncludeRegularExpressionCommand.h @@ -96,9 +96,13 @@ public: virtual const char* GetFullDocumentation() { return - "INCLUDE_REGULAR_EXPRESSION(regex)\n" - "Sets the regular expression used in dependency checking. Only\n" - "include files matching this regular expression will be traced."; + "INCLUDE_REGULAR_EXPRESSION(regex_match [regex_complain])\n" + "Set the regular expressions used in dependency checking. Only files\n" + "matching regex_match will be traced as dependencies. Only files\n" + "matching regex_complain will generate warnings if they cannot be found\n" + "(standard header paths are not searched). The defaults are:\n" + " regex_match = \"^.*$\" (match everything)\n" + " regex_complain = \"^$\" (match empty string only)\n"; } cmTypeMacro(cmIncludeRegularExpressionCommand, cmCommand); 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); } diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h index 574bc6a..b49f8cd 100644 --- a/Source/cmMakeDepend.h +++ b/Source/cmMakeDepend.h @@ -180,6 +180,7 @@ protected: const cmMakefile* m_Makefile; bool m_Verbose; cmRegularExpression m_IncludeFileRegularExpression; + cmRegularExpression m_ComplainFileRegularExpression; DependArray m_DependInformation; std::vector<std::string> m_IncludeDirectories; }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index bca29eb..eedeb45 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -53,9 +53,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // default is not to be building executables cmMakefile::cmMakefile() { - // Setup the default include file regular expression. - // Should be changed to something like "\\.(h|hh|hpp|hxx)$" or "^.*$" - m_IncludeFileRegularExpression = "^itk|^vtk|^vnl|^vcl|^f2c"; + // Setup the default include file regular expression (match everything). + m_IncludeFileRegularExpression = "^.*$"; + // Setup the default include complaint regular expression (match nothing). + m_ComplainFileRegularExpression = "^$"; m_DefineFlags = " "; m_MakefileGenerator = 0; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index a71fb20..bce13ac 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -346,6 +346,15 @@ public: m_IncludeFileRegularExpression = regex; } + /** + * Set a regular expression that include files that are not found + * must match in order to be considered a problem. + */ + void SetComplainRegularExpression(const char* regex) + { + m_ComplainFileRegularExpression = regex; + } + /** * Get the list of targets */ @@ -493,6 +502,7 @@ protected: cmTarget::LinkLibraries m_LinkLibraries; std::string m_IncludeFileRegularExpression; + std::string m_ComplainFileRegularExpression; std::string m_DefineFlags; std::vector<cmSourceGroup> m_SourceGroups; typedef std::map<std::string, cmCommand*> RegisteredCommandsMap; diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index 1216e19..b7a0309 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -128,7 +128,12 @@ void cmUnixMakefileGenerator::ProcessDepends(const cmMakeDepend &md) info->m_IndexSet.begin(); indx != info->m_IndexSet.end(); ++indx) { - i->GetDepends().push_back(md.GetDependInformation()[*indx]->m_FullPath); + // Make sure the full path is given. If not, the dependency was + // not found. + if(md.GetDependInformation()[*indx]->m_FullPath != "") + { + i->GetDepends().push_back(md.GetDependInformation()[*indx]->m_FullPath); + } } } } |