ENH: some changes to the depends signature to be more flexible
This commit is contained in:
parent
25d6c04add
commit
c85069b290
|
@ -22,21 +22,9 @@
|
|||
#include <assert.h>
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmDepends::cmDepends(const char* dir, const char* targetFile, bool verbose):
|
||||
m_Directory(dir),
|
||||
m_TargetFile(targetFile),
|
||||
m_DependsMakeFile(dir),
|
||||
m_DependsMarkFile(dir),
|
||||
m_Verbose(verbose)
|
||||
cmDepends::cmDepends()
|
||||
{
|
||||
// Construct the path to the make and mark files. Append
|
||||
// appropriate extensions to their names.
|
||||
m_DependsMakeFile += "/";
|
||||
m_DependsMarkFile += "/";
|
||||
m_DependsMakeFile += m_TargetFile;
|
||||
m_DependsMarkFile += m_TargetFile;
|
||||
m_DependsMakeFile += ".depends.make";
|
||||
m_DependsMarkFile += ".depends";
|
||||
m_Verbose = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -44,6 +32,25 @@ 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
|
||||
// appropriate extensions to their names.
|
||||
m_DependsMarkFile = dir;
|
||||
m_DependsMakeFile = dir;
|
||||
m_DependsMakeFile += "/";
|
||||
m_DependsMarkFile += "/";
|
||||
m_DependsMakeFile += m_TargetFile;
|
||||
m_DependsMarkFile += m_TargetFile;
|
||||
m_DependsMakeFile += makeExt;
|
||||
m_DependsMarkFile += markExt;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool cmDepends::Write()
|
||||
{
|
||||
|
|
|
@ -31,7 +31,14 @@ class cmDepends
|
|||
public:
|
||||
/** Instances need to know the build directory name and the relative
|
||||
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 ~cmDepends();
|
||||
|
|
|
@ -21,22 +21,15 @@
|
|||
#include <ctype.h> // isspace
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmDependsC::cmDependsC(const char* dir, const char* targetFile, bool verbose):
|
||||
cmDepends(dir, targetFile, verbose),
|
||||
m_SourceFile(),
|
||||
m_IncludePath(0),
|
||||
m_IncludeRegexLine(),
|
||||
m_IncludeRegexScan(),
|
||||
m_IncludeRegexComplain()
|
||||
cmDependsC::cmDependsC()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmDependsC::cmDependsC(const char* dir, const char* targetFile,
|
||||
const char* sourceFile,
|
||||
// yummy look at all those constructor arguments
|
||||
cmDependsC::cmDependsC(const char* sourceFile,
|
||||
std::vector<std::string> const& includes,
|
||||
const char* scanRegex, const char* complainRegex):
|
||||
cmDepends(dir, targetFile, false),
|
||||
m_SourceFile(sourceFile),
|
||||
m_IncludePath(&includes),
|
||||
m_IncludeRegexLine("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)([\">])"),
|
||||
|
|
|
@ -29,14 +29,15 @@ class cmDependsC: public cmDepends
|
|||
public:
|
||||
/** Checking instances need to know the build directory name and the
|
||||
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
|
||||
path from the build directory to the target file, the source
|
||||
file from which to start scanning, and the include file search
|
||||
path. It also uses the include file regular expressions. */
|
||||
cmDependsC(const char* dir, const char* targetFile,
|
||||
const char* sourceFile, std::vector<std::string> const& includes,
|
||||
path. It also uses the include file regular expressions.
|
||||
This is a good example of why constructors should not take arguments.
|
||||
*/
|
||||
cmDependsC(const char* sourceFile, std::vector<std::string> const& includes,
|
||||
const char* scanRegex, const char* complainRegex);
|
||||
|
||||
/** Virtual destructor to cleanup subclasses properly. */
|
||||
|
|
|
@ -76,19 +76,15 @@ struct cmDependsFortranParser_s
|
|||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile,
|
||||
bool verbose):
|
||||
cmDepends(dir, targetFile, verbose),
|
||||
cmDependsFortran::cmDependsFortran():
|
||||
m_SourceFile(),
|
||||
m_IncludePath(0)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmDependsFortran::cmDependsFortran(const char* dir, const char* targetFile,
|
||||
const char* sourceFile,
|
||||
cmDependsFortran::cmDependsFortran(const char* sourceFile,
|
||||
std::vector<std::string> const& includes):
|
||||
cmDepends(dir, targetFile, false),
|
||||
m_SourceFile(sourceFile),
|
||||
m_IncludePath(&includes)
|
||||
{
|
||||
|
|
|
@ -27,14 +27,13 @@ class cmDependsFortran: public cmDepends
|
|||
public:
|
||||
/** Checking instances need to know the build directory name and the
|
||||
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
|
||||
path from the build directory to the target file, the source
|
||||
file from which to start scanning, and the include file search
|
||||
path. */
|
||||
cmDependsFortran(const char* dir, const char* targetFile,
|
||||
const char* sourceFile, std::vector<std::string> const& includes);
|
||||
cmDependsFortran(const char* sourceFile, std::vector<std::string> const& includes);
|
||||
|
||||
/** Virtual destructor to cleanup subclasses properly. */
|
||||
virtual ~cmDependsFortran();
|
||||
|
|
|
@ -20,17 +20,13 @@
|
|||
#include "cmSystemTools.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmDependsJava::cmDependsJava(const char* dir, const char* targetFile,
|
||||
bool verbose):
|
||||
cmDepends(dir, targetFile, verbose),
|
||||
cmDependsJava::cmDependsJava():
|
||||
m_SourceFile()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmDependsJava::cmDependsJava(const char* dir, const char* targetFile,
|
||||
const char* sourceFile):
|
||||
cmDepends(dir, targetFile, false),
|
||||
cmDependsJava::cmDependsJava(const char* sourceFile):
|
||||
m_SourceFile(sourceFile)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -27,13 +27,12 @@ class cmDependsJava: public cmDepends
|
|||
public:
|
||||
/** Checking instances need to know the build directory name and the
|
||||
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
|
||||
path from the build directory to the target file and the source
|
||||
file to scan. */
|
||||
cmDependsJava(const char* dir, const char* targetFile,
|
||||
const char* sourceFile);
|
||||
cmDependsJava(const char* sourceFile);
|
||||
|
||||
/** Virtual destructor to cleanup subclasses properly. */
|
||||
virtual ~cmDependsJava();
|
||||
|
|
|
@ -3102,21 +3102,27 @@ cmLocalUnixMakefileGenerator2::GetDependsChecker(const std::string& lang,
|
|||
const char* objFile,
|
||||
bool verbose)
|
||||
{
|
||||
cmDepends *ret = 0;
|
||||
if(lang == "C" || lang == "CXX" || lang == "RC")
|
||||
{
|
||||
return new cmDependsC(dir, objFile, verbose);
|
||||
ret = new cmDependsC();
|
||||
}
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
else if(lang == "Fortran")
|
||||
{
|
||||
return new cmDependsFortran(dir, objFile, verbose);
|
||||
ret = new cmDependsFortran();
|
||||
}
|
||||
else if(lang == "Java")
|
||||
{
|
||||
return new cmDependsJava(dir, objFile, verbose);
|
||||
ret = new cmDependsJava();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
if (ret)
|
||||
{
|
||||
ret->SetTargetFile(dir, objFile, ".depends",".depends.make");
|
||||
ret->SetVerbose(verbose);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -3201,19 +3207,22 @@ cmLocalUnixMakefileGenerator2
|
|||
if(lang == "C" || lang == "CXX" || lang == "RC")
|
||||
{
|
||||
// TODO: Handle RC (resource files) dependencies correctly.
|
||||
cmDependsC scanner(".", objFile, srcFile, includes,
|
||||
cmDependsC scanner(srcFile, includes,
|
||||
includeRegexScan.c_str(), includeRegexComplain.c_str());
|
||||
scanner.SetTargetFile(".",objFile,".depends",".depends.make");
|
||||
return scanner.Write();
|
||||
}
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
else if(lang == "Fortran")
|
||||
{
|
||||
cmDependsFortran scanner(".", objFile, srcFile, includes);
|
||||
cmDependsFortran scanner(srcFile, includes);
|
||||
scanner.SetTargetFile(".",objFile,".depends",".depends.make");
|
||||
return scanner.Write();
|
||||
}
|
||||
else if(lang == "Java")
|
||||
{
|
||||
cmDependsJava scanner(".", objFile, srcFile);
|
||||
cmDependsJava scanner(srcFile);
|
||||
scanner.SetTargetFile(".",objFile,".depends",".depends.make");
|
||||
return scanner.Write();
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue