Commit c85069b2 authored by Ken Martin's avatar Ken Martin
Browse files

ENH: some changes to the depends signature to be more flexible

parent 25d6c04a
...@@ -22,27 +22,34 @@ ...@@ -22,27 +22,34 @@
#include <assert.h> #include <assert.h>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDepends::cmDepends(const char* dir, const char* targetFile, bool verbose): cmDepends::cmDepends()
m_Directory(dir),
m_TargetFile(targetFile),
m_DependsMakeFile(dir),
m_DependsMarkFile(dir),
m_Verbose(verbose)
{ {
m_Verbose = false;
}
//----------------------------------------------------------------------------
cmDepends::~cmDepends()
{
}
void cmDepends::SetTargetFile(const char* dir, const char* targetFile,
const char *markExt, const char *makeExt)
{
m_Directory = dir;
m_TargetFile = targetFile;
// Construct the path to the make and mark files. Append // Construct the path to the make and mark files. Append
// appropriate extensions to their names. // appropriate extensions to their names.
m_DependsMarkFile = dir;
m_DependsMakeFile = dir;
m_DependsMakeFile += "/"; m_DependsMakeFile += "/";
m_DependsMarkFile += "/"; m_DependsMarkFile += "/";
m_DependsMakeFile += m_TargetFile; m_DependsMakeFile += m_TargetFile;
m_DependsMarkFile += m_TargetFile; m_DependsMarkFile += m_TargetFile;
m_DependsMakeFile += ".depends.make"; m_DependsMakeFile += makeExt;
m_DependsMarkFile += ".depends"; m_DependsMarkFile += markExt;
} }
//----------------------------------------------------------------------------
cmDepends::~cmDepends()
{
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmDepends::Write() bool cmDepends::Write()
......
...@@ -31,8 +31,15 @@ class cmDepends ...@@ -31,8 +31,15 @@ class cmDepends
public: public:
/** Instances need to know the build directory name and the relative /** Instances need to know the build directory name and the relative
path from the build directory to the target file. */ path from the build directory to the target file. */
cmDepends(const char* dir, const char* targetFile, bool verbose); cmDepends();
/** set the name directory and extensions of the target file to scan */
void SetTargetFile(const char* dir, const char* targetFile,
const char *markExt, const char *makeExt);
/** should this be verbose in its output */
void SetVerbose(bool verb) { m_Verbose = verb; }
/** Virtual destructor to cleanup subclasses properly. */ /** Virtual destructor to cleanup subclasses properly. */
virtual ~cmDepends(); virtual ~cmDepends();
......
...@@ -21,22 +21,15 @@ ...@@ -21,22 +21,15 @@
#include <ctype.h> // isspace #include <ctype.h> // isspace
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsC::cmDependsC(const char* dir, const char* targetFile, bool verbose): cmDependsC::cmDependsC()
cmDepends(dir, targetFile, verbose),
m_SourceFile(),
m_IncludePath(0),
m_IncludeRegexLine(),
m_IncludeRegexScan(),
m_IncludeRegexComplain()
{ {
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsC::cmDependsC(const char* dir, const char* targetFile, // yummy look at all those constructor arguments
const char* sourceFile, cmDependsC::cmDependsC(const char* sourceFile,
std::vector<std::string> const& includes, std::vector<std::string> const& includes,
const char* scanRegex, const char* complainRegex): const char* scanRegex, const char* complainRegex):
cmDepends(dir, targetFile, false),
m_SourceFile(sourceFile), m_SourceFile(sourceFile),
m_IncludePath(&includes), m_IncludePath(&includes),
m_IncludeRegexLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)([\">])"), m_IncludeRegexLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)([\">])"),
......
...@@ -29,14 +29,15 @@ class cmDependsC: public cmDepends ...@@ -29,14 +29,15 @@ class cmDependsC: public cmDepends
public: public:
/** Checking instances need to know the build directory name and the /** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */ relative path from the build directory to the target file. */
cmDependsC(const char* dir, const char* targetFile, bool verbose); cmDependsC();
/** Scanning need to know the build directory name, the relative /** Scanning need to know the build directory name, the relative
path from the build directory to the target file, the source path from the build directory to the target file, the source
file from which to start scanning, and the include file search file from which to start scanning, and the include file search
path. It also uses the include file regular expressions. */ path. It also uses the include file regular expressions.
cmDependsC(const char* dir, const char* targetFile, This is a good example of why constructors should not take arguments.
const char* sourceFile, std::vector<std::string> const& includes, */
cmDependsC(const char* sourceFile, std::vector<std::string> const& includes,
const char* scanRegex, const char* complainRegex); const char* scanRegex, const char* complainRegex);
/** Virtual destructor to cleanup subclasses properly. */ /** Virtual destructor to cleanup subclasses properly. */
......
...@@ -76,19 +76,15 @@ struct cmDependsFortranParser_s ...@@ -76,19 +76,15 @@ struct cmDependsFortranParser_s
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile, cmDependsFortran::cmDependsFortran():
bool verbose):
cmDepends(dir, targetFile, verbose),
m_SourceFile(), m_SourceFile(),
m_IncludePath(0) m_IncludePath(0)
{ {
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile, cmDependsFortran::cmDependsFortran(const char* sourceFile,
const char* sourceFile,
std::vector<std::string> const& includes): std::vector<std::string> const& includes):
cmDepends(dir, targetFile, false),
m_SourceFile(sourceFile), m_SourceFile(sourceFile),
m_IncludePath(&includes) m_IncludePath(&includes)
{ {
......
...@@ -27,14 +27,13 @@ class cmDependsFortran: public cmDepends ...@@ -27,14 +27,13 @@ class cmDependsFortran: public cmDepends
public: public:
/** Checking instances need to know the build directory name and the /** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */ relative path from the build directory to the target file. */
cmDependsFortran(const char* dir, const char* targetFile, bool verbose); cmDependsFortran();
/** Scanning need to know the build directory name, the relative /** Scanning need to know the build directory name, the relative
path from the build directory to the target file, the source path from the build directory to the target file, the source
file from which to start scanning, and the include file search file from which to start scanning, and the include file search
path. */ path. */
cmDependsFortran(const char* dir, const char* targetFile, cmDependsFortran(const char* sourceFile, std::vector<std::string> const& includes);
const char* sourceFile, std::vector<std::string> const& includes);
/** Virtual destructor to cleanup subclasses properly. */ /** Virtual destructor to cleanup subclasses properly. */
virtual ~cmDependsFortran(); virtual ~cmDependsFortran();
......
...@@ -20,17 +20,13 @@ ...@@ -20,17 +20,13 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsJava::cmDependsJava(const char* dir, const char* targetFile, cmDependsJava::cmDependsJava():
bool verbose):
cmDepends(dir, targetFile, verbose),
m_SourceFile() m_SourceFile()
{ {
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmDependsJava::cmDependsJava(const char* dir, const char* targetFile, cmDependsJava::cmDependsJava(const char* sourceFile):
const char* sourceFile):
cmDepends(dir, targetFile, false),
m_SourceFile(sourceFile) m_SourceFile(sourceFile)
{ {
} }
......
...@@ -27,13 +27,12 @@ class cmDependsJava: public cmDepends ...@@ -27,13 +27,12 @@ class cmDependsJava: public cmDepends
public: public:
/** Checking instances need to know the build directory name and the /** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */ relative path from the build directory to the target file. */
cmDependsJava(const char* dir, const char* targetFile, bool verbose); cmDependsJava();
/** Scanning need to know the build directory name, the relative /** Scanning need to know the build directory name, the relative
path from the build directory to the target file and the source path from the build directory to the target file and the source
file to scan. */ file to scan. */
cmDependsJava(const char* dir, const char* targetFile, cmDependsJava(const char* sourceFile);
const char* sourceFile);
/** Virtual destructor to cleanup subclasses properly. */ /** Virtual destructor to cleanup subclasses properly. */
virtual ~cmDependsJava(); virtual ~cmDependsJava();
......
...@@ -3102,21 +3102,27 @@ cmLocalUnixMakefileGenerator2::GetDependsChecker(const std::string& lang, ...@@ -3102,21 +3102,27 @@ cmLocalUnixMakefileGenerator2::GetDependsChecker(const std::string& lang,
const char* objFile, const char* objFile,
bool verbose) bool verbose)
{ {
cmDepends *ret = 0;
if(lang == "C" || lang == "CXX" || lang == "RC") if(lang == "C" || lang == "CXX" || lang == "RC")
{ {
return new cmDependsC(dir, objFile, verbose); ret = new cmDependsC();
} }
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
else if(lang == "Fortran") else if(lang == "Fortran")
{ {
return new cmDependsFortran(dir, objFile, verbose); ret = new cmDependsFortran();
} }
else if(lang == "Java") else if(lang == "Java")
{ {
return new cmDependsJava(dir, objFile, verbose); ret = new cmDependsJava();
} }
#endif #endif
return 0; if (ret)
{
ret->SetTargetFile(dir, objFile, ".depends",".depends.make");
ret->SetVerbose(verbose);
}
return ret;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -3201,19 +3207,22 @@ cmLocalUnixMakefileGenerator2 ...@@ -3201,19 +3207,22 @@ cmLocalUnixMakefileGenerator2
if(lang == "C" || lang == "CXX" || lang == "RC") if(lang == "C" || lang == "CXX" || lang == "RC")
{ {
// TODO: Handle RC (resource files) dependencies correctly. // TODO: Handle RC (resource files) dependencies correctly.
cmDependsC scanner(".", objFile, srcFile, includes, cmDependsC scanner(srcFile, includes,
includeRegexScan.c_str(), includeRegexComplain.c_str()); includeRegexScan.c_str(), includeRegexComplain.c_str());
scanner.SetTargetFile(".",objFile,".depends",".depends.make");
return scanner.Write(); return scanner.Write();
} }
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
else if(lang == "Fortran") else if(lang == "Fortran")
{ {
cmDependsFortran scanner(".", objFile, srcFile, includes); cmDependsFortran scanner(srcFile, includes);
scanner.SetTargetFile(".",objFile,".depends",".depends.make");
return scanner.Write(); return scanner.Write();
} }
else if(lang == "Java") else if(lang == "Java")
{ {
cmDependsJava scanner(".", objFile, srcFile); cmDependsJava scanner(srcFile);
scanner.SetTargetFile(".",objFile,".depends",".depends.make");
return scanner.Write(); return scanner.Write();
} }
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment