Parser: Issue messages through cmake, not cmSystemTools
Make these messages uniform with regard to other messages issued by cmake.
This commit is contained in:
parent
db7de303c2
commit
33bb9cfa36
|
@ -24,6 +24,7 @@ struct cmListFileParser
|
|||
cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename);
|
||||
~cmListFileParser();
|
||||
void IssueFileOpenError(std::string const& text) const;
|
||||
void IssueError(std::string const& text) const;
|
||||
bool ParseFile();
|
||||
bool ParseFunction(const char* name, long line);
|
||||
bool AddArgument(cmListFileLexer_Token* token,
|
||||
|
@ -62,6 +63,18 @@ void cmListFileParser::IssueFileOpenError(const std::string& text) const
|
|||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, text);
|
||||
}
|
||||
|
||||
void cmListFileParser::IssueError(const std::string& text) const
|
||||
{
|
||||
cmListFileContext lfc;
|
||||
lfc.FilePath = this->FileName;
|
||||
lfc.Line = cmListFileLexer_GetCurrentLine(this->Lexer);
|
||||
cmListFileBacktrace lfbt = this->Backtrace;
|
||||
lfbt = lfbt.Push(lfc);
|
||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, text,
|
||||
lfbt);
|
||||
cmSystemTools::SetFatalErrorOccured();
|
||||
}
|
||||
|
||||
bool cmListFileParser::ParseFile()
|
||||
{
|
||||
// Open the file.
|
||||
|
@ -98,22 +111,18 @@ bool cmListFileParser::ParseFile()
|
|||
}
|
||||
} else {
|
||||
std::ostringstream error;
|
||||
error << "Error in cmake code at\n"
|
||||
<< this->FileName << ":" << token->line << ":\n"
|
||||
<< "Parse error. Expected a newline, got "
|
||||
error << "Parse error. Expected a newline, got "
|
||||
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
||||
<< " with text \"" << token->text << "\".";
|
||||
cmSystemTools::Error(error.str().c_str());
|
||||
this->IssueError(error.str());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
std::ostringstream error;
|
||||
error << "Error in cmake code at\n"
|
||||
<< this->FileName << ":" << token->line << ":\n"
|
||||
<< "Parse error. Expected a command name, got "
|
||||
error << "Parse error. Expected a command name, got "
|
||||
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
||||
<< " with text \"" << token->text << "\".";
|
||||
cmSystemTools::Error(error.str().c_str());
|
||||
this->IssueError(error.str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -156,18 +165,15 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
|
|||
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
||||
<< "Parse error. Function missing opening \"(\".";
|
||||
/* clang-format on */
|
||||
cmSystemTools::Error(error.str().c_str());
|
||||
this->IssueError(error.str());
|
||||
return false;
|
||||
}
|
||||
if (token->type != cmListFileLexer_Token_ParenLeft) {
|
||||
std::ostringstream error;
|
||||
error << "Error in cmake code at\n"
|
||||
<< this->FileName << ":"
|
||||
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
||||
<< "Parse error. Expected \"(\", got "
|
||||
error << "Parse error. Expected \"(\", got "
|
||||
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
||||
<< " with text \"" << token->text << "\".";
|
||||
cmSystemTools::Error(error.str().c_str());
|
||||
this->IssueError(error.str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -219,25 +225,25 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
|
|||
} else {
|
||||
// Error.
|
||||
std::ostringstream error;
|
||||
error << "Error in cmake code at\n"
|
||||
<< this->FileName << ":"
|
||||
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
|
||||
<< "Parse error. Function missing ending \")\". "
|
||||
error << "Parse error. Function missing ending \")\". "
|
||||
<< "Instead found "
|
||||
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
|
||||
<< " with text \"" << token->text << "\".";
|
||||
cmSystemTools::Error(error.str().c_str());
|
||||
this->IssueError(error.str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream error;
|
||||
error << "Error in cmake code at\n"
|
||||
<< this->FileName << ":" << lastLine << ":\n"
|
||||
<< "Parse error. Function missing ending \")\". "
|
||||
cmListFileContext lfc;
|
||||
lfc.FilePath = this->FileName;
|
||||
lfc.Line = lastLine;
|
||||
cmListFileBacktrace lfbt = this->Backtrace;
|
||||
lfbt = lfbt.Push(lfc);
|
||||
error << "Parse error. Function missing ending \")\". "
|
||||
<< "End of file reached.";
|
||||
cmSystemTools::Error(error.str().c_str());
|
||||
|
||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR,
|
||||
error.str(), lfbt);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -252,17 +258,21 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
|
|||
bool isError = (this->Separation == SeparationError ||
|
||||
delim == cmListFileArgument::Bracket);
|
||||
std::ostringstream m;
|
||||
/* clang-format off */
|
||||
m << "Syntax " << (isError? "Error":"Warning") << " in cmake code at\n"
|
||||
<< " " << this->FileName << ":" << token->line << ":"
|
||||
<< token->column << "\n"
|
||||
cmListFileContext lfc;
|
||||
lfc.FilePath = this->FileName;
|
||||
lfc.Line = token->line;
|
||||
cmListFileBacktrace lfbt = this->Backtrace;
|
||||
lfbt = lfbt.Push(lfc);
|
||||
|
||||
m << "Syntax " << (isError ? "Error" : "Warning") << " in cmake code at "
|
||||
<< "column " << token->column << "\n"
|
||||
<< "Argument not separated from preceding token by whitespace.";
|
||||
/* clang-format on */
|
||||
if (isError) {
|
||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
|
||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, m.str(), lfbt);
|
||||
return false;
|
||||
}
|
||||
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
|
||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, m.str(), lfbt);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Tests/RunCMake/Syntax/BracketComment4.cmake:3:
|
||||
Parse error. Expected a newline, got identifier with text "message".
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
|
||||
BracketComment4.cmake
|
||||
CMake Error at BracketComment4.cmake:3:
|
||||
Parse error. Expected a newline, got identifier with text "message".
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
CMake Error in BracketNoSpace0.cmake:
|
||||
Syntax Error in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/BracketNoSpace0.cmake:1:27
|
||||
CMake Error at BracketNoSpace0.cmake:1:
|
||||
Syntax Error in cmake code at column 27
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
CMake Error in BracketNoSpace1.cmake:
|
||||
Syntax Error in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/BracketNoSpace1.cmake:1:24
|
||||
CMake Error at BracketNoSpace1.cmake:1:
|
||||
Syntax Error in cmake code at column 24
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
CMake Error in BracketNoSpace2.cmake:
|
||||
Syntax Error in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/BracketNoSpace2.cmake:1:44
|
||||
CMake Error at BracketNoSpace2.cmake:1:
|
||||
Syntax Error in cmake code at column 44
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
CMake Error in BracketNoSpace3.cmake:
|
||||
Syntax Error in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/BracketNoSpace3.cmake:1:45
|
||||
CMake Error at BracketNoSpace3.cmake:1:
|
||||
Syntax Error in cmake code at column 45
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
CMake Error in BracketNoSpace4.cmake:
|
||||
Syntax Error in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/BracketNoSpace4.cmake:1:44
|
||||
CMake Error at BracketNoSpace4.cmake:1:
|
||||
Syntax Error in cmake code at column 44
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
CMake Error in BracketNoSpace5.cmake:
|
||||
Syntax Error in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/BracketNoSpace5.cmake:1:45
|
||||
CMake Error at BracketNoSpace5.cmake:1:
|
||||
Syntax Error in cmake code at column 45
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Tests/RunCMake/Syntax/CommandError0.cmake:2:
|
||||
Parse error. Expected "\(", got newline with text "
|
||||
".
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
CMake Error at CommandError0.cmake:2:
|
||||
Parse error. Expected "\(", got newline with text "
|
||||
|
||||
CommandError0.cmake
|
||||
".
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Tests/RunCMake/Syntax/CommandError1.cmake:1:
|
||||
Parse error. Expected a newline, got identifier with text "message".
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
|
||||
CommandError1.cmake
|
||||
CMake Error at CommandError1.cmake:1:
|
||||
Parse error. Expected a newline, got identifier with text "message".
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Tests/RunCMake/Syntax/CommandError2.cmake:1:
|
||||
Parse error. Expected a command name, got bracket argument with text "oops-not-a-comment".
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
|
||||
CommandError2.cmake
|
||||
CMake Error at CommandError2.cmake:1:
|
||||
Parse error. Expected a command name, got bracket argument with text
|
||||
"oops-not-a-comment".
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
CMake Warning \(dev\) in ParenInENV.cmake:
|
||||
Syntax Warning in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/ParenInENV.cmake:2:21
|
||||
CMake Warning \(dev\) at ParenInENV.cmake:2:
|
||||
Syntax Warning in cmake code at column 21
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
|
@ -11,7 +9,7 @@ This warning is for project developers. Use -Wno-dev to suppress it.
|
|||
CMake Error at ParenInENV.cmake:2 \(message\):
|
||||
Syntax error in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/ParenInENV.cmake:2
|
||||
.*Tests/RunCMake/Syntax/ParenInENV.cmake:2
|
||||
|
||||
when parsing string
|
||||
|
||||
|
|
|
@ -1,27 +1,21 @@
|
|||
CMake Warning \(dev\) in ParenNoSpace1.cmake:
|
||||
Syntax Warning in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:1:26
|
||||
CMake Warning \(dev\) at ParenNoSpace1.cmake:1:
|
||||
Syntax Warning in cmake code at column 26
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
CMake Warning \(dev\) in ParenNoSpace1.cmake:
|
||||
Syntax Warning in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:2:26
|
||||
CMake Warning \(dev\) at ParenNoSpace1.cmake:2:
|
||||
Syntax Warning in cmake code at column 26
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
CMake Error in ParenNoSpace1.cmake:
|
||||
Syntax Error in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:3:29
|
||||
CMake Error at ParenNoSpace1.cmake:3:
|
||||
Syntax Error in cmake code at column 29
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
CMake Warning \(dev\) in StringNoSpace.cmake:
|
||||
Syntax Warning in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/StringNoSpace.cmake:2:28
|
||||
CMake Warning \(dev\) at StringNoSpace.cmake:2:
|
||||
Syntax Warning in cmake code at column 28
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
CMake Warning \(dev\) in StringNoSpace.cmake:
|
||||
Syntax Warning in cmake code at
|
||||
|
||||
.*/Tests/RunCMake/Syntax/StringNoSpace.cmake:2:31
|
||||
CMake Warning \(dev\) at StringNoSpace.cmake:2:
|
||||
Syntax Warning in cmake code at column 31
|
||||
|
||||
Argument not separated from preceding token by whitespace.
|
||||
Call Stack \(most recent call first\):
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Syntax/UnterminatedBracket0.cmake:2:
|
||||
Parse error. Function missing ending "\)". Instead found unterminated bracket with text "\)
|
||||
".
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
CMake Error at UnterminatedBracket0.cmake:2:
|
||||
Parse error. Function missing ending "\)". Instead found unterminated
|
||||
bracket with text "\)
|
||||
|
||||
UnterminatedBracket0.cmake$
|
||||
".
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Syntax/UnterminatedBracket1.cmake:2:
|
||||
Parse error. Function missing ending "\)". Instead found unterminated bracket with text "\]\]\)
|
||||
".
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
CMake Error at UnterminatedBracket1.cmake:2:
|
||||
Parse error. Function missing ending "\)". Instead found unterminated
|
||||
bracket with text "]]\)
|
||||
|
||||
UnterminatedBracket1.cmake$
|
||||
".
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Syntax/UnterminatedBracketComment.cmake:1:
|
||||
Parse error. Expected a command name, got unterminated bracket with text "#\]\]
|
||||
".
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
CMake Error at UnterminatedBracketComment.cmake:3:
|
||||
Parse error. Expected a command name, got unterminated bracket with text
|
||||
"#]]
|
||||
|
||||
UnterminatedBracketComment.cmake
|
||||
".
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Syntax/UnterminatedCall1.cmake:2:
|
||||
Parse error. Function missing ending "\)". End of file reached.
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
|
||||
UnterminatedCall1.cmake
|
||||
CMake Error at UnterminatedCall1.cmake:2:
|
||||
Parse error. Function missing ending "\)". End of file reached.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Syntax/UnterminatedCall2.cmake:4:
|
||||
Parse error. Function missing ending "\)". End of file reached.
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
|
||||
UnterminatedCall2.cmake
|
||||
CMake Error at UnterminatedCall2.cmake:4:
|
||||
Parse error. Function missing ending "\)". End of file reached.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
CMake Error: Error in cmake code at
|
||||
.*/Syntax/UnterminatedString.cmake:2:
|
||||
Parse error. Function missing ending "\)". Instead found unterminated string with text "\)
|
||||
".
|
||||
CMake Error at CMakeLists.txt:3 \(include\):
|
||||
include could not find load file:
|
||||
CMake Error at UnterminatedString.cmake:2:
|
||||
Parse error. Function missing ending "\)". Instead found unterminated
|
||||
string with text "\)
|
||||
|
||||
UnterminatedString.cmake$
|
||||
".
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
|
Loading…
Reference in New Issue