diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-04-22 12:23:51 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-04-22 12:28:13 (GMT) |
commit | e4a235653fbe27120f518b2a97af95d2b9831309 (patch) | |
tree | 4e3c37597761aa277b19f215b198db2e2d7a9653 /Source/cmQtAutoGenerators.cxx | |
parent | 9d9e17fa21bc184d0f11ee73e8bdcd40910d719e (diff) | |
download | CMake-e4a235653fbe27120f518b2a97af95d2b9831309.zip CMake-e4a235653fbe27120f518b2a97af95d2b9831309.tar.gz CMake-e4a235653fbe27120f518b2a97af95d2b9831309.tar.bz2 |
Autogen: New QuotedCommand function for logging
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 972daf6..0831766 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -42,6 +42,25 @@ inline static std::string Quoted(const std::string& text) return cmQtAutoGeneratorCommon::Quoted(text); } +static std::string QuotedCommand(const std::vector<std::string>& command) +{ + std::string res; + for (std::vector<std::string>::const_iterator cit = command.begin(); + cit != command.end(); ++cit) { + if (!res.empty()) { + res.push_back(' '); + } + const std::string cesc = Quoted(*cit); + if (cit->empty() || (cesc.size() > (cit->size() + 2)) || + (cesc.find(' ') != std::string::npos)) { + res += cesc; + } else { + res += *cit; + } + } + return res; +} + static void InfoGet(cmMakefile* makefile, const char* key, std::string& value) { value = makefile->GetSafeDefinition(key); @@ -1190,7 +1209,7 @@ bool cmQtAutoGenerators::MocGenerateAll( { std::ostringstream ost; ost << "AutoMoc: Error: moc predefs generation command failed\n"; - ost << "AutoMoc: Command:\n" << cmJoin(cmd, " ") << "\n"; + ost << "AutoMoc: Command:\n" << QuotedCommand(cmd) << "\n"; ost << "AutoMoc: Command output:\n" << output << "\n"; this->LogError(ost.str()); } @@ -1348,7 +1367,7 @@ bool cmQtAutoGenerators::MocGenerateFile( std::ostringstream ost; ost << "AutoMoc: Error: moc process failed for\n"; ost << Quoted(mocFileRel) << "\n"; - ost << "AutoMoc: Command:\n" << cmJoin(cmd, " ") << "\n"; + ost << "AutoMoc: Command:\n" << QuotedCommand(cmd) << "\n"; ost << "AutoMoc: Command output:\n" << output << "\n"; this->LogError(ost.str()); } @@ -1519,7 +1538,7 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName, ost << "AutoUic: Error: uic process failed for\n"; ost << Quoted(uicFileRel) << " needed by\n"; ost << Quoted(realName) << "\n"; - ost << "AutoUic: Command:\n" << cmJoin(cmd, " ") << "\n"; + ost << "AutoUic: Command:\n" << QuotedCommand(cmd) << "\n"; ost << "AutoUic: Command output:\n" << output << "\n"; this->LogError(ost.str()); } @@ -1665,7 +1684,7 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile, std::ostringstream ost; ost << "AutoRcc: Error: rcc process failed for\n"; ost << Quoted(rccOutputFile) << "\n"; - ost << "AutoRcc: Command:\n" << cmJoin(cmd, " ") << "\n"; + ost << "AutoRcc: Command:\n" << QuotedCommand(cmd) << "\n"; ost << "AutoRcc: Command output:\n" << output << "\n"; this->LogError(ost.str()); } @@ -1745,23 +1764,6 @@ void cmQtAutoGenerators::LogError(const std::string& message) const } } -void cmQtAutoGenerators::LogCommand( - const std::vector<std::string>& command) const -{ - std::vector<std::string> cmdEscaped; - typedef std::vector<std::string>::const_iterator Iter; - for (Iter cit = command.begin(); cit != command.end(); ++cit) { - const std::string cesc = Quoted(*cit); - if ((cesc.size() > (cit->size() + 2)) || - (cesc.find(' ') != std::string::npos)) { - cmdEscaped.push_back(cesc); - } else { - cmdEscaped.push_back(*cit); - } - } - this->LogInfo(cmJoin(cmdEscaped, " ")); -} - /** * @brief Collects name collisions as output/input pairs * @return True if there were collisions @@ -1881,7 +1883,7 @@ bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command, { // Log command if (this->Verbose) { - this->LogCommand(command); + this->LogInfo(QuotedCommand(command)); } // Execute command int retVal = 0; |