automoc: improved diagnostics

Error/warning messages now look like:
AUTOMOC: (error|warning): <filename>: the actual text...

Alex
This commit is contained in:
Alex Neundorf 2011-11-10 22:02:41 +01:00
parent 69cf480cd6
commit f98e6151dc
1 changed files with 11 additions and 10 deletions

View File

@ -512,7 +512,8 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
const std::string contentsString = this->ReadAll(absFilename); const std::string contentsString = this->ReadAll(absFilename);
if (contentsString.empty()) if (contentsString.empty())
{ {
std::cerr << "AUTOMOC: empty source file: " << absFilename << std::endl; std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty"
<< std::endl;
return; return;
} }
const std::string absPath = cmsys::SystemTools::GetFilenamePath( const std::string absPath = cmsys::SystemTools::GetFilenamePath(
@ -592,9 +593,9 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
} }
else else
{ {
std::cerr << "AUTOMOC: The file \"" << absFilename std::cerr << "AUTOMOC: error: " << absFilename << " The file "
<< "\" includes the moc file \"" << currentMoc << "includes the moc file \"" << currentMoc << "\", "
<< "\", but could not find header \"" << basename << "but could not find header \"" << basename
<< '{' << this->Join(headerExtensions, ',') << "}\" "; << '{' << this->Join(headerExtensions, ',') << "}\" ";
if (mocSubDir.empty()) if (mocSubDir.empty())
{ {
@ -613,8 +614,8 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
{ {
if (basename != scannedFileBasename) if (basename != scannedFileBasename)
{ {
std::cerr << "AUTOMOC: The file \"" << absFilename std::cerr << "AUTOMOC: error: " << absFilename << ": The file "
<< "\" includes the moc file \"" << currentMoc << "includes the moc file \"" << currentMoc
<< "\", which seems to be the moc file from a different " << "\", which seems to be the moc file from a different "
<< "source file. This is not supported. " << "source file. This is not supported. "
<< "Include \"" << scannedFileBasename << ".moc\" to run " << "Include \"" << scannedFileBasename << ".moc\" to run "
@ -637,12 +638,12 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
if (qObjectRegExp.find(contentsString)) if (qObjectRegExp.find(contentsString))
{ {
std::cerr << "AUTOMOC: The file \"" << absFilename std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
<< "\" contains a Q_OBJECT macro, but does not include " << "contains a Q_OBJECT macro, but does not include "
<< "\"" << scannedFileBasename << ".moc\", but instead includes " << "\"" << scannedFileBasename << ".moc\", but instead includes "
<< "\"" << ownMocUnderscoreFile << "\". Running moc on " << "\"" << ownMocUnderscoreFile << "\". Running moc on "
<< "\"" << absFilename << "\" ! Better include \"" << "\"" << absFilename << "\" ! Better include \""
<< scannedFileBasename << ".moc\" to get a robust build." << scannedFileBasename << ".moc\" for a robust build."
<< std::endl; << std::endl;
includedMocs[absFilename] = ownMocUnderscoreFile; includedMocs[absFilename] = ownMocUnderscoreFile;
includedMocs.erase(ownMocHeaderFile); includedMocs.erase(ownMocHeaderFile);
@ -772,7 +773,7 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile,
bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal);
if (!result || retVal) if (!result || retVal)
{ {
std::cerr << "AUTOMOC: process for " << mocFilePath << " failed:\n" std::cerr << "AUTOMOC: error: process for " << mocFilePath <<" failed:\n"
<< output << std::endl; << output << std::endl;
this->RunMocFailed = true; this->RunMocFailed = true;
cmSystemTools::RemoveFile(mocFilePath.c_str()); cmSystemTools::RemoveFile(mocFilePath.c_str());