Improve compilation speed

This commit is contained in:
Alexey Rybalchenko
2018-05-16 18:06:57 +02:00
committed by Dennis Klein
parent 436f79bee5
commit e4c349888d
24 changed files with 985 additions and 812 deletions

View File

@@ -9,8 +9,6 @@
#ifndef FAIR_MQ_TOOLS_PROCESS_H
#define FAIR_MQ_TOOLS_PROCESS_H
#include <boost/process.hpp>
#include <string>
namespace fair
@@ -37,43 +35,7 @@ struct execute_result
* @param[in] log_prefix How to prefix each captured output line with
* @return Captured stdout output and exit code
*/
inline execute_result execute(std::string cmd, std::string prefix = "")
{
execute_result result;
std::stringstream out;
// print full line thread-safe
std::stringstream printCmd;
printCmd << prefix << cmd << "\n";
std::cout << printCmd.str() << std::flush;
out << prefix << cmd << std::endl;
// Execute command and capture stdout, add prefix line by line
boost::process::ipstream stdout;
boost::process::child c(cmd, boost::process::std_out > stdout);
std::string line;
while (getline(stdout, line))
{
// print full line thread-safe
std::stringstream printLine;
printLine << prefix << line << "\n";
std::cout << printLine.str() << std::flush;
out << prefix << line << "\n";
}
c.wait();
// Capture exit code
result.exit_code = c.exit_code();
out << prefix << " Exit code: " << result.exit_code << std::endl;
result.console_out = out.str();
// Return result
return result;
}
execute_result execute(std::string cmd, std::string prefix = "");
} /* namespace tools */
} /* namespace mq */