ENH: Convert cmDepends object interface to scan an entire target at once.
This commit is contained in:
parent
a7245e4792
commit
4d360f7ac5
|
@ -16,6 +16,8 @@
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
#include "cmDepends.h"
|
#include "cmDepends.h"
|
||||||
|
|
||||||
|
#include "cmLocalGenerator.h"
|
||||||
|
#include "cmMakefile.h"
|
||||||
#include "cmGeneratedFileStream.h"
|
#include "cmGeneratedFileStream.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmFileTimeComparison.h"
|
#include "cmFileTimeComparison.h"
|
||||||
|
@ -41,10 +43,39 @@ cmDepends::~cmDepends()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmDepends::Write(const char *src, const char *obj,
|
bool cmDepends::Write(std::ostream &makeDepends,
|
||||||
std::ostream &makeDepends, std::ostream &internalDepends)
|
std::ostream &internalDepends)
|
||||||
{
|
{
|
||||||
return this->WriteDependencies(src, obj, makeDepends, internalDepends);
|
// Lookup the set of sources to scan.
|
||||||
|
std::string srcLang = "CMAKE_DEPENDS_CHECK_";
|
||||||
|
srcLang += this->Language;
|
||||||
|
cmMakefile* mf = this->LocalGenerator->GetMakefile();
|
||||||
|
const char* srcStr = mf->GetSafeDefinition(srcLang.c_str());
|
||||||
|
std::vector<std::string> pairs;
|
||||||
|
cmSystemTools::ExpandListArgument(srcStr, pairs);
|
||||||
|
|
||||||
|
for(std::vector<std::string>::iterator si = pairs.begin();
|
||||||
|
si != pairs.end();)
|
||||||
|
{
|
||||||
|
// Get the source and object file.
|
||||||
|
std::string const& src = *si++;
|
||||||
|
if(si == pairs.end()) { break; }
|
||||||
|
std::string obj = *si++;
|
||||||
|
|
||||||
|
// Make sure the object file is relative to the top of the build tree.
|
||||||
|
obj = this->LocalGenerator->Convert(obj.c_str(),
|
||||||
|
cmLocalGenerator::HOME_OUTPUT,
|
||||||
|
cmLocalGenerator::MAKEFILE);
|
||||||
|
|
||||||
|
// Write the dependencies for this pair.
|
||||||
|
if(!this->WriteDependencies(src.c_str(), obj.c_str(),
|
||||||
|
makeDepends, internalDepends))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -45,6 +45,12 @@ public:
|
||||||
directory. */
|
directory. */
|
||||||
void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; }
|
void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; }
|
||||||
|
|
||||||
|
/** Set the specific language to be scanned. */
|
||||||
|
void SetLanguage(const char* lang) { this->Language = lang; }
|
||||||
|
|
||||||
|
/** Set the target build directory. */
|
||||||
|
void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
|
||||||
|
|
||||||
/** should this be verbose in its output */
|
/** should this be verbose in its output */
|
||||||
void SetVerbose(bool verb) { this->Verbose = verb; }
|
void SetVerbose(bool verb) { this->Verbose = verb; }
|
||||||
|
|
||||||
|
@ -52,8 +58,7 @@ public:
|
||||||
virtual ~cmDepends();
|
virtual ~cmDepends();
|
||||||
|
|
||||||
/** Write dependencies for the target file. */
|
/** Write dependencies for the target file. */
|
||||||
bool Write(const char *src, const char *obj,
|
bool Write(std::ostream &makeDepends, std::ostream &internalDepends);
|
||||||
std::ostream &makeDepends, std::ostream &internalDepends);
|
|
||||||
|
|
||||||
/** Check dependencies for the target file. Returns true if
|
/** Check dependencies for the target file. Returns true if
|
||||||
dependencies are okay and false if they must be generated. If
|
dependencies are okay and false if they must be generated. If
|
||||||
|
@ -90,6 +95,11 @@ protected:
|
||||||
bool Verbose;
|
bool Verbose;
|
||||||
cmFileTimeComparison* FileComparison;
|
cmFileTimeComparison* FileComparison;
|
||||||
|
|
||||||
|
std::string Language;
|
||||||
|
|
||||||
|
// The full path to the target's build directory.
|
||||||
|
std::string TargetDirectory;
|
||||||
|
|
||||||
size_t MaxPath;
|
size_t MaxPath;
|
||||||
char* Dependee;
|
char* Dependee;
|
||||||
char* Depender;
|
char* Depender;
|
||||||
|
|
|
@ -90,9 +90,8 @@ cmDependsFortran::cmDependsFortran():
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmDependsFortran::cmDependsFortran(std::vector<std::string> const& includes,
|
cmDependsFortran::cmDependsFortran(std::vector<std::string> const& includes):
|
||||||
std::string const& targetDirectory):
|
IncludePath(&includes)
|
||||||
IncludePath(&includes), TargetDirectory(targetDirectory)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@ public:
|
||||||
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, the include file search
|
file from which to start scanning, the include file search
|
||||||
path, and the target directory. */
|
path, and the target directory. */
|
||||||
cmDependsFortran(std::vector<std::string> const& includes,
|
cmDependsFortran(std::vector<std::string> const& includes);
|
||||||
std::string const& targetDirectory);
|
|
||||||
|
|
||||||
/** Virtual destructor to cleanup subclasses properly. */
|
/** Virtual destructor to cleanup subclasses properly. */
|
||||||
virtual ~cmDependsFortran();
|
virtual ~cmDependsFortran();
|
||||||
|
@ -62,9 +61,6 @@ protected:
|
||||||
// The include file search path.
|
// The include file search path.
|
||||||
std::vector<std::string> const* IncludePath;
|
std::vector<std::string> const* IncludePath;
|
||||||
|
|
||||||
// The full path to the target's build directory.
|
|
||||||
std::string TargetDirectory;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cmDependsFortran(cmDependsFortran const&); // Purposely not implemented.
|
cmDependsFortran(cmDependsFortran const&); // Purposely not implemented.
|
||||||
void operator=(cmDependsFortran const&); // Purposely not implemented.
|
void operator=(cmDependsFortran const&); // Purposely not implemented.
|
||||||
|
|
|
@ -1412,7 +1412,7 @@ cmLocalUnixMakefileGenerator3
|
||||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||||
else if(lang == "Fortran")
|
else if(lang == "Fortran")
|
||||||
{
|
{
|
||||||
scanner = new cmDependsFortran(includes, dir);
|
scanner = new cmDependsFortran(includes);
|
||||||
}
|
}
|
||||||
else if(lang == "Java")
|
else if(lang == "Java")
|
||||||
{
|
{
|
||||||
|
@ -1425,23 +1425,9 @@ cmLocalUnixMakefileGenerator3
|
||||||
scanner->SetLocalGenerator(this);
|
scanner->SetLocalGenerator(this);
|
||||||
scanner->SetFileComparison
|
scanner->SetFileComparison
|
||||||
(this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
|
(this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
|
||||||
// for each file we need to scan
|
scanner->SetLanguage(lang.c_str());
|
||||||
std::string srcLang = "CMAKE_DEPENDS_CHECK_";
|
scanner->SetTargetDirectory(dir.c_str());
|
||||||
srcLang += lang;
|
scanner->Write(ruleFileStream, internalRuleFileStream);
|
||||||
const char *srcStr = mf->GetSafeDefinition(srcLang.c_str());
|
|
||||||
std::vector<std::string> srcs;
|
|
||||||
cmSystemTools::ExpandListArgument(srcStr, srcs);
|
|
||||||
for (std::vector<std::string>::iterator si =
|
|
||||||
srcs.begin(); si != srcs.end(); ++si)
|
|
||||||
{
|
|
||||||
std::string &src = *si;
|
|
||||||
++si;
|
|
||||||
// make sure the object file is relative to home output
|
|
||||||
std::string obj = *si;
|
|
||||||
obj = this->Convert(obj.c_str(),HOME_OUTPUT,MAKEFILE);
|
|
||||||
scanner->Write(src.c_str(),obj.c_str(),
|
|
||||||
ruleFileStream, internalRuleFileStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
// free the scanner for this language
|
// free the scanner for this language
|
||||||
delete scanner;
|
delete scanner;
|
||||||
|
|
Loading…
Reference in New Issue