From 00750ece6a5dbfd51a8dd789c4d7dc1246f63ec3 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 30 Nov 2016 21:08:54 +0100 Subject: QtAutogen: Error and warning log method tweaks --- Source/cmQtAutoGenerators.cxx | 36 +++++++++++++++++++++++------------- Source/cmQtAutoGenerators.h | 6 ++++-- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a0302cb..a6099fa 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -195,7 +196,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( if (!makefile->ReadListFile(filename.c_str())) { std::ostringstream err; - err << "AUTOGEN: Error processing file: " << filename << std::endl; + err << "AUTOGEN: error processing file: " << filename << std::endl; this->LogError(err.str()); return false; } @@ -582,7 +583,7 @@ void cmQtAutoGenerators::ParseCppFile( std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; - this->LogError(err.str()); + this->LogWarning(err.str()); return; } this->ParseForUic(absFilename, contentsString, includedUis); @@ -673,7 +674,7 @@ void cmQtAutoGenerators::ParseCppFile( << ".cpp\" for a compatibility with " "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" << std::endl; - this->LogError(err.str()); + this->LogWarning(err.str()); } else { std::ostringstream err; err << "AUTOGEN: warning: " << absFilename @@ -686,7 +687,7 @@ void cmQtAutoGenerators::ParseCppFile( << ".cpp\" for compatibility with " "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" << std::endl; - this->LogError(err.str()); + this->LogWarning(err.str()); } } else { std::ostringstream err; @@ -730,7 +731,7 @@ void cmQtAutoGenerators::ParseCppFile( << ".moc\" for compatibility with " "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" << std::endl; - this->LogError(err.str()); + this->LogWarning(err.str()); includedMocs[absFilename] = ownMocUnderscoreFile; includedMocs.erase(ownMocHeaderFile); @@ -764,7 +765,7 @@ void cmQtAutoGenerators::StrictParseCppFile( std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; - this->LogError(err.str()); + this->LogWarning(err.str()); return; } this->ParseForUic(absFilename, contentsString, includedUis); @@ -876,7 +877,7 @@ void cmQtAutoGenerators::ParseForUic( std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; - this->LogError(err.str()); + this->LogWarning(err.str()); return; } this->ParseForUic(absFilename, contentsString, includedUis); @@ -997,7 +998,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( << "To avoid this error either" << std::endl << "- rename the source files or" << std::endl << "- do not include the (moc_NAME.cpp|NAME.moc) file" << std::endl; - this->NameCollisionLog(err.str(), collisions); + this->LogErrorNameCollision(err.str(), collisions); return false; } } @@ -1176,7 +1177,7 @@ bool cmQtAutoGenerators::GenerateUiFiles( "from different sources." << std::endl << "To avoid this error rename the source files." << std::endl; - this->NameCollisionLog(err.str(), collisions); + this->LogErrorNameCollision(err.str(), collisions); return false; } } @@ -1310,7 +1311,7 @@ bool cmQtAutoGenerators::GenerateQrcFiles() " will be generated from different sources." << std::endl << "To avoid this error rename the source .qrc files." << std::endl; - this->NameCollisionLog(err.str(), collisions); + this->LogErrorNameCollision(err.str(), collisions); return false; } } @@ -1435,7 +1436,7 @@ bool cmQtAutoGenerators::NameCollisionTest( return !collisions.empty(); } -void cmQtAutoGenerators::NameCollisionLog( +void cmQtAutoGenerators::LogErrorNameCollision( const std::string& message, const std::multimap& collisions) { @@ -1453,12 +1454,21 @@ void cmQtAutoGenerators::NameCollisionLog( void cmQtAutoGenerators::LogInfo(const std::string& message) { - cmSystemTools::Message(message.c_str()); + std::cout << message.c_str(); +} + +void cmQtAutoGenerators::LogWarning(const std::string& message) +{ + std::ostringstream ostr; + ostr << message << "\n"; + std::cout << message.c_str(); } void cmQtAutoGenerators::LogError(const std::string& message) { - cmSystemTools::Error(message.c_str()); + std::ostringstream ostr; + ostr << message << "\n\n"; + std::cerr << ostr.str(); } void cmQtAutoGenerators::LogCommand(const std::vector& command) diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 47f3289..816c380 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -76,13 +76,15 @@ private: bool NameCollisionTest(const std::map& genFiles, std::multimap& collisions); - void NameCollisionLog( + + void LogErrorNameCollision( const std::string& message, const std::multimap& collisions); - void LogInfo(const std::string& message); + void LogWarning(const std::string& message); void LogError(const std::string& message); void LogCommand(const std::vector& command); + std::string JoinExts(const std::vector& lst); static void MergeUicOptions(std::vector& opts, -- cgit v0.12