Parser: Port away from cmMakefile
It is an unneeded dependency.
This commit is contained in:
parent
421012a330
commit
1462576bcb
|
@ -12,7 +12,7 @@
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
|
|
||||||
#include "cmListFileLexer.h"
|
#include "cmListFileLexer.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMessenger.h"
|
||||||
#include "cmOutputConverter.h"
|
#include "cmOutputConverter.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmVersion.h"
|
#include "cmVersion.h"
|
||||||
|
@ -21,7 +21,8 @@
|
||||||
|
|
||||||
struct cmListFileParser
|
struct cmListFileParser
|
||||||
{
|
{
|
||||||
cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename);
|
cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt,
|
||||||
|
cmMessenger* messenger, const char* filename);
|
||||||
~cmListFileParser();
|
~cmListFileParser();
|
||||||
void IssueFileOpenError(std::string const& text) const;
|
void IssueFileOpenError(std::string const& text) const;
|
||||||
void IssueError(std::string const& text) const;
|
void IssueError(std::string const& text) const;
|
||||||
|
@ -30,8 +31,8 @@ struct cmListFileParser
|
||||||
bool AddArgument(cmListFileLexer_Token* token,
|
bool AddArgument(cmListFileLexer_Token* token,
|
||||||
cmListFileArgument::Delimiter delim);
|
cmListFileArgument::Delimiter delim);
|
||||||
cmListFile* ListFile;
|
cmListFile* ListFile;
|
||||||
cmMakefile* Makefile;
|
|
||||||
cmListFileBacktrace Backtrace;
|
cmListFileBacktrace Backtrace;
|
||||||
|
cmMessenger* Messenger;
|
||||||
const char* FileName;
|
const char* FileName;
|
||||||
cmListFileLexer* Lexer;
|
cmListFileLexer* Lexer;
|
||||||
cmListFileFunction Function;
|
cmListFileFunction Function;
|
||||||
|
@ -43,11 +44,12 @@ struct cmListFileParser
|
||||||
} Separation;
|
} Separation;
|
||||||
};
|
};
|
||||||
|
|
||||||
cmListFileParser::cmListFileParser(cmListFile* lf, cmMakefile* mf,
|
cmListFileParser::cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt,
|
||||||
|
cmMessenger* messenger,
|
||||||
const char* filename)
|
const char* filename)
|
||||||
: ListFile(lf)
|
: ListFile(lf)
|
||||||
, Makefile(mf)
|
, Backtrace(lfbt)
|
||||||
, Backtrace(mf->GetBacktrace())
|
, Messenger(messenger)
|
||||||
, FileName(filename)
|
, FileName(filename)
|
||||||
, Lexer(cmListFileLexer_New())
|
, Lexer(cmListFileLexer_New())
|
||||||
{
|
{
|
||||||
|
@ -60,7 +62,7 @@ cmListFileParser::~cmListFileParser()
|
||||||
|
|
||||||
void cmListFileParser::IssueFileOpenError(const std::string& text) const
|
void cmListFileParser::IssueFileOpenError(const std::string& text) const
|
||||||
{
|
{
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, text);
|
this->Messenger->IssueMessage(cmake::FATAL_ERROR, text, this->Backtrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmListFileParser::IssueError(const std::string& text) const
|
void cmListFileParser::IssueError(const std::string& text) const
|
||||||
|
@ -70,8 +72,7 @@ void cmListFileParser::IssueError(const std::string& text) const
|
||||||
lfc.Line = cmListFileLexer_GetCurrentLine(this->Lexer);
|
lfc.Line = cmListFileLexer_GetCurrentLine(this->Lexer);
|
||||||
cmListFileBacktrace lfbt = this->Backtrace;
|
cmListFileBacktrace lfbt = this->Backtrace;
|
||||||
lfbt = lfbt.Push(lfc);
|
lfbt = lfbt.Push(lfc);
|
||||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, text,
|
this->Messenger->IssueMessage(cmake::FATAL_ERROR, text, lfbt);
|
||||||
lfbt);
|
|
||||||
cmSystemTools::SetFatalErrorOccured();
|
cmSystemTools::SetFatalErrorOccured();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +130,8 @@ bool cmListFileParser::ParseFile()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmListFile::ParseFile(const char* filename, cmMakefile* mf)
|
bool cmListFile::ParseFile(const char* filename, cmMessenger* messenger,
|
||||||
|
cmListFileBacktrace const& lfbt)
|
||||||
{
|
{
|
||||||
if (!cmSystemTools::FileExists(filename) ||
|
if (!cmSystemTools::FileExists(filename) ||
|
||||||
cmSystemTools::FileIsDirectory(filename)) {
|
cmSystemTools::FileIsDirectory(filename)) {
|
||||||
|
@ -139,7 +141,7 @@ bool cmListFile::ParseFile(const char* filename, cmMakefile* mf)
|
||||||
bool parseError = false;
|
bool parseError = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
cmListFileParser parser(this, mf, filename);
|
cmListFileParser parser(this, lfbt, messenger, filename);
|
||||||
parseError = !parser.ParseFile();
|
parseError = !parser.ParseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,8 +244,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
|
||||||
lfbt = lfbt.Push(lfc);
|
lfbt = lfbt.Push(lfc);
|
||||||
error << "Parse error. Function missing ending \")\". "
|
error << "Parse error. Function missing ending \")\". "
|
||||||
<< "End of file reached.";
|
<< "End of file reached.";
|
||||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR,
|
this->Messenger->IssueMessage(cmake::FATAL_ERROR, error.str(), lfbt);
|
||||||
error.str(), lfbt);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,10 +270,10 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
|
||||||
<< "Argument not separated from preceding token by whitespace.";
|
<< "Argument not separated from preceding token by whitespace.";
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
if (isError) {
|
if (isError) {
|
||||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, m.str(), lfbt);
|
this->Messenger->IssueMessage(cmake::FATAL_ERROR, m.str(), lfbt);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, m.str(), lfbt);
|
this->Messenger->IssueMessage(cmake::AUTHOR_WARNING, m.str(), lfbt);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
* cmake list files.
|
* cmake list files.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class cmMakefile;
|
class cmMessenger;
|
||||||
|
|
||||||
struct cmCommandContext
|
struct cmCommandContext
|
||||||
{
|
{
|
||||||
|
@ -158,7 +158,8 @@ private:
|
||||||
|
|
||||||
struct cmListFile
|
struct cmListFile
|
||||||
{
|
{
|
||||||
bool ParseFile(const char* path, cmMakefile* mf);
|
bool ParseFile(const char* path, cmMessenger* messenger,
|
||||||
|
cmListFileBacktrace const& lfbt);
|
||||||
|
|
||||||
std::vector<cmListFileFunction> Functions;
|
std::vector<cmListFileFunction> Functions;
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
#include "cmInstallGenerator.h"
|
#include "cmInstallGenerator.h"
|
||||||
#include "cmListFileCache.h"
|
#include "cmListFileCache.h"
|
||||||
|
#include "cmMessenger.h"
|
||||||
#include "cmSourceFile.h"
|
#include "cmSourceFile.h"
|
||||||
#include "cmSourceFileLocation.h"
|
#include "cmSourceFileLocation.h"
|
||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
|
@ -457,7 +458,8 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
|
||||||
IncludeScope incScope(this, filenametoread, noPolicyScope);
|
IncludeScope incScope(this, filenametoread, noPolicyScope);
|
||||||
|
|
||||||
cmListFile listFile;
|
cmListFile listFile;
|
||||||
if (!listFile.ParseFile(filenametoread.c_str(), this)) {
|
if (!listFile.ParseFile(filenametoread.c_str(), this->GetMessenger(),
|
||||||
|
this->Backtrace)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,7 +508,8 @@ bool cmMakefile::ReadListFile(const char* filename)
|
||||||
ListFileScope scope(this, filenametoread);
|
ListFileScope scope(this, filenametoread);
|
||||||
|
|
||||||
cmListFile listFile;
|
cmListFile listFile;
|
||||||
if (!listFile.ParseFile(filenametoread.c_str(), this)) {
|
if (!listFile.ParseFile(filenametoread.c_str(), this->GetMessenger(),
|
||||||
|
this->Backtrace)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1452,7 +1455,8 @@ void cmMakefile::Configure()
|
||||||
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str());
|
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str());
|
||||||
|
|
||||||
cmListFile listFile;
|
cmListFile listFile;
|
||||||
if (!listFile.ParseFile(currentStart.c_str(), this)) {
|
if (!listFile.ParseFile(currentStart.c_str(), this->GetMessenger(),
|
||||||
|
this->Backtrace)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this->IsRootMakefile()) {
|
if (this->IsRootMakefile()) {
|
||||||
|
@ -3274,6 +3278,11 @@ cmake* cmMakefile::GetCMakeInstance() const
|
||||||
return this->GlobalGenerator->GetCMakeInstance();
|
return this->GlobalGenerator->GetCMakeInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmMessenger* cmMakefile::GetMessenger() const
|
||||||
|
{
|
||||||
|
return this->GetCMakeInstance()->GetMessenger();
|
||||||
|
}
|
||||||
|
|
||||||
cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const
|
cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const
|
||||||
{
|
{
|
||||||
return this->GlobalGenerator;
|
return this->GlobalGenerator;
|
||||||
|
|
|
@ -607,6 +607,7 @@ public:
|
||||||
* Get the instance
|
* Get the instance
|
||||||
*/
|
*/
|
||||||
cmake* GetCMakeInstance() const;
|
cmake* GetCMakeInstance() const;
|
||||||
|
cmMessenger* GetMessenger() const;
|
||||||
cmGlobalGenerator* GetGlobalGenerator() const;
|
cmGlobalGenerator* GetGlobalGenerator() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue