forked from qt-creator/qt-creator
CMakePM: Add "[cmake] " prefix to all output messages
With this one could easily filter the "[cmake] " messages from all the messages in the "Generate Messages" pane. Change-Id: I690650f0ccb0372c9361b95cfec41809737720d7 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#include "cmakebuildstep.h"
|
#include "cmakebuildstep.h"
|
||||||
#include "cmakebuildtarget.h"
|
#include "cmakebuildtarget.h"
|
||||||
#include "cmakekitaspect.h"
|
#include "cmakekitaspect.h"
|
||||||
|
#include "cmakeprocess.h"
|
||||||
#include "cmakeproject.h"
|
#include "cmakeproject.h"
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
@@ -1934,7 +1935,8 @@ void CMakeBuildSystem::runGenerator(Id id)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(cmakeBuildConfiguration(), return);
|
QTC_ASSERT(cmakeBuildConfiguration(), return);
|
||||||
const auto showError = [](const QString &detail) {
|
const auto showError = [](const QString &detail) {
|
||||||
Core::MessageManager::writeDisrupting(Tr::tr("cmake generator failed: %1.").arg(detail));
|
Core::MessageManager::writeDisrupting(
|
||||||
|
addCMakePrefix(Tr::tr("cmake generator failed: %1.").arg(detail)));
|
||||||
};
|
};
|
||||||
const CMakeTool * const cmakeTool
|
const CMakeTool * const cmakeTool
|
||||||
= CMakeKitAspect::cmakeTool(buildConfiguration()->target()->kit());
|
= CMakeKitAspect::cmakeTool(buildConfiguration()->target()->kit());
|
||||||
@@ -1981,16 +1983,18 @@ void CMakeBuildSystem::runGenerator(Id id)
|
|||||||
const auto proc = new Process(this);
|
const auto proc = new Process(this);
|
||||||
connect(proc, &Process::done, proc, &Process::deleteLater);
|
connect(proc, &Process::done, proc, &Process::deleteLater);
|
||||||
connect(proc, &Process::readyReadStandardOutput, this, [proc] {
|
connect(proc, &Process::readyReadStandardOutput, this, [proc] {
|
||||||
Core::MessageManager::writeFlashing(QString::fromLocal8Bit(proc->readAllRawStandardOutput()));
|
Core::MessageManager::writeFlashing(
|
||||||
|
addCMakePrefix(QString::fromLocal8Bit(proc->readAllRawStandardOutput()).split('\n')));
|
||||||
});
|
});
|
||||||
connect(proc, &Process::readyReadStandardError, this, [proc] {
|
connect(proc, &Process::readyReadStandardError, this, [proc] {
|
||||||
Core::MessageManager::writeDisrupting(QString::fromLocal8Bit(proc->readAllRawStandardError()));
|
Core::MessageManager::writeDisrupting(
|
||||||
|
addCMakePrefix(QString::fromLocal8Bit(proc->readAllRawStandardError()).split('\n')));
|
||||||
});
|
});
|
||||||
proc->setWorkingDirectory(outDir);
|
proc->setWorkingDirectory(outDir);
|
||||||
proc->setEnvironment(buildConfiguration()->environment());
|
proc->setEnvironment(buildConfiguration()->environment());
|
||||||
proc->setCommand(cmdLine);
|
proc->setCommand(cmdLine);
|
||||||
Core::MessageManager::writeFlashing(
|
Core::MessageManager::writeFlashing(addCMakePrefix(
|
||||||
Tr::tr("Running in %1: %2.").arg(outDir.toUserOutput(), cmdLine.toUserOutput()));
|
Tr::tr("Running in %1: %2.").arg(outDir.toUserOutput(), cmdLine.toUserOutput())));
|
||||||
proc->start();
|
proc->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <extensionsystem/invoker.h>
|
#include <extensionsystem/invoker.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/process.h>
|
#include <utils/process.h>
|
||||||
#include <utils/processinfo.h>
|
#include <utils/processinfo.h>
|
||||||
#include <utils/processinterface.h>
|
#include <utils/processinterface.h>
|
||||||
@@ -58,7 +59,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
const QString msg = ::CMakeProjectManager::Tr::tr(
|
const QString msg = ::CMakeProjectManager::Tr::tr(
|
||||||
"The source directory %1 is not reachable by the CMake executable %2.")
|
"The source directory %1 is not reachable by the CMake executable %2.")
|
||||||
.arg(parameters.sourceDirectory.displayName()).arg(cmakeExecutable.displayName());
|
.arg(parameters.sourceDirectory.displayName()).arg(cmakeExecutable.displayName());
|
||||||
BuildSystem::appendBuildSystemOutput(msg + '\n');
|
BuildSystem::appendBuildSystemOutput(addCMakePrefix({msg, QString()}).join('\n'));
|
||||||
emit finished(failedToStartExitCode);
|
emit finished(failedToStartExitCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -67,7 +68,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
const QString msg = ::CMakeProjectManager::Tr::tr(
|
const QString msg = ::CMakeProjectManager::Tr::tr(
|
||||||
"The build directory %1 is not reachable by the CMake executable %2.")
|
"The build directory %1 is not reachable by the CMake executable %2.")
|
||||||
.arg(parameters.buildDirectory.displayName()).arg(cmakeExecutable.displayName());
|
.arg(parameters.buildDirectory.displayName()).arg(cmakeExecutable.displayName());
|
||||||
BuildSystem::appendBuildSystemOutput(msg + '\n');
|
BuildSystem::appendBuildSystemOutput(addCMakePrefix({msg, QString()}).join('\n'));
|
||||||
emit finished(failedToStartExitCode);
|
emit finished(failedToStartExitCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -78,7 +79,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
if (!buildDirectory.exists()) {
|
if (!buildDirectory.exists()) {
|
||||||
const QString msg = ::CMakeProjectManager::Tr::tr(
|
const QString msg = ::CMakeProjectManager::Tr::tr(
|
||||||
"The build directory \"%1\" does not exist").arg(buildDirectory.toUserOutput());
|
"The build directory \"%1\" does not exist").arg(buildDirectory.toUserOutput());
|
||||||
BuildSystem::appendBuildSystemOutput(msg + '\n');
|
BuildSystem::appendBuildSystemOutput(addCMakePrefix({msg, QString()}).join('\n'));
|
||||||
emit finished(failedToStartExitCode);
|
emit finished(failedToStartExitCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -88,7 +89,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
const QString msg = ::CMakeProjectManager::Tr::tr(
|
const QString msg = ::CMakeProjectManager::Tr::tr(
|
||||||
"CMake executable \"%1\" and build directory \"%2\" must be on the same device.")
|
"CMake executable \"%1\" and build directory \"%2\" must be on the same device.")
|
||||||
.arg(cmake->cmakeExecutable().toUserOutput(), buildDirectory.toUserOutput());
|
.arg(cmake->cmakeExecutable().toUserOutput(), buildDirectory.toUserOutput());
|
||||||
BuildSystem::appendBuildSystemOutput(msg + '\n');
|
BuildSystem::appendBuildSystemOutput(addCMakePrefix({msg, QString()}).join('\n'));
|
||||||
emit finished(failedToStartExitCode);
|
emit finished(failedToStartExitCode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -117,13 +118,13 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
m_process->setEnvironment(parameters.environment);
|
m_process->setEnvironment(parameters.environment);
|
||||||
|
|
||||||
m_process->setStdOutLineCallback([this](const QString &s) {
|
m_process->setStdOutLineCallback([this](const QString &s) {
|
||||||
BuildSystem::appendBuildSystemOutput(stripTrailingNewline(s));
|
BuildSystem::appendBuildSystemOutput(addCMakePrefix(stripTrailingNewline(s)));
|
||||||
emit stdOutReady(s);
|
emit stdOutReady(s);
|
||||||
});
|
});
|
||||||
|
|
||||||
m_process->setStdErrLineCallback([this](const QString &s) {
|
m_process->setStdErrLineCallback([this](const QString &s) {
|
||||||
m_parser.appendMessage(s, StdErrFormat);
|
m_parser.appendMessage(s, StdErrFormat);
|
||||||
BuildSystem::appendBuildSystemOutput(stripTrailingNewline(s));
|
BuildSystem::appendBuildSystemOutput(addCMakePrefix(stripTrailingNewline(s)));
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_process.get(), &Process::done, this, [this] {
|
connect(m_process.get(), &Process::done, this, [this] {
|
||||||
@@ -136,8 +137,9 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
|
|
||||||
TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
||||||
|
|
||||||
BuildSystem::startNewBuildSystemOutput(::CMakeProjectManager::Tr::tr("Running %1 in %2.")
|
BuildSystem::startNewBuildSystemOutput(
|
||||||
.arg(commandLine.toUserOutput(), buildDirectory.toUserOutput()));
|
addCMakePrefix(::CMakeProjectManager::Tr::tr("Running %1 in %2.")
|
||||||
|
.arg(commandLine.toUserOutput(), buildDirectory.toUserOutput())));
|
||||||
|
|
||||||
ProcessProgress *progress = new ProcessProgress(m_process.get());
|
ProcessProgress *progress = new ProcessProgress(m_process.get());
|
||||||
progress->setDisplayName(::CMakeProjectManager::Tr::tr("Configuring \"%1\"")
|
progress->setDisplayName(::CMakeProjectManager::Tr::tr("Configuring \"%1\"")
|
||||||
@@ -170,14 +172,24 @@ void CMakeProcess::handleProcessDone(const Utils::ProcessResultData &resultData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!msg.isEmpty()) {
|
if (!msg.isEmpty()) {
|
||||||
BuildSystem::appendBuildSystemOutput(msg + '\n');
|
BuildSystem::appendBuildSystemOutput(addCMakePrefix({msg, QString()}).join('\n'));
|
||||||
TaskHub::addTask(BuildSystemTask(Task::Error, msg));
|
TaskHub::addTask(BuildSystemTask(Task::Error, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit finished(code);
|
emit finished(code);
|
||||||
|
|
||||||
const QString elapsedTime = Utils::formatElapsedTime(m_elapsed.elapsed());
|
const QString elapsedTime = Utils::formatElapsedTime(m_elapsed.elapsed());
|
||||||
BuildSystem::appendBuildSystemOutput(elapsedTime + '\n');
|
BuildSystem::appendBuildSystemOutput(addCMakePrefix({elapsedTime, QString()}).join('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString addCMakePrefix(const QString &str)
|
||||||
|
{
|
||||||
|
return QString("%1%2").arg(Constants::OUTPUT_PREFIX, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList addCMakePrefix(const QStringList &list)
|
||||||
|
{
|
||||||
|
return Utils::transform(list, [](const QString &str) { return addCMakePrefix(str); });
|
||||||
}
|
}
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
|||||||
@@ -43,4 +43,7 @@ private:
|
|||||||
QElapsedTimer m_elapsed;
|
QElapsedTimer m_elapsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString addCMakePrefix(const QString &str);
|
||||||
|
QStringList addCMakePrefix(const QStringList &list);
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
|||||||
@@ -71,5 +71,8 @@ const char TOOL_ID[] = "CMakeProjectManager.CMakeKitInformation";
|
|||||||
// Data
|
// Data
|
||||||
const char BUILD_FOLDER_ROLE[] = "CMakeProjectManager.data.buildFolder";
|
const char BUILD_FOLDER_ROLE[] = "CMakeProjectManager.data.buildFolder";
|
||||||
|
|
||||||
|
// Output
|
||||||
|
const char OUTPUT_PREFIX[] = "[cmake] ";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace CMakeProjectManager
|
} // namespace CMakeProjectManager
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "cmakebuildsystem.h"
|
#include "cmakebuildsystem.h"
|
||||||
#include "cmakekitaspect.h"
|
#include "cmakekitaspect.h"
|
||||||
|
#include "cmakeprocess.h"
|
||||||
#include "cmakeproject.h"
|
#include "cmakeproject.h"
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
@@ -411,8 +412,8 @@ void CMakeManager::buildFile(Node *node)
|
|||||||
bc->buildDirectory());
|
bc->buildDirectory());
|
||||||
targetBase = relativeBuildDir / "CMakeFiles" / (targetNode->displayName() + ".dir");
|
targetBase = relativeBuildDir / "CMakeFiles" / (targetNode->displayName() + ".dir");
|
||||||
} else if (!generator.contains("Makefiles")) {
|
} else if (!generator.contains("Makefiles")) {
|
||||||
Core::MessageManager::writeFlashing(
|
Core::MessageManager::writeFlashing(addCMakePrefix(
|
||||||
Tr::tr("Build File is not supported for generator \"%1\"").arg(generator));
|
Tr::tr("Build File is not supported for generator \"%1\"").arg(generator)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "fileapiparser.h"
|
#include "fileapiparser.h"
|
||||||
|
|
||||||
|
#include "cmakeprocess.h"
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
|
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
@@ -42,9 +43,10 @@ FilePath FileApiParser::cmakeReplyDirectory(const FilePath &buildDirectory)
|
|||||||
|
|
||||||
static void reportFileApiSetupFailure()
|
static void reportFileApiSetupFailure()
|
||||||
{
|
{
|
||||||
Core::MessageManager::writeFlashing(Tr::tr("Failed to set up CMake file API support. %1 cannot "
|
Core::MessageManager::writeFlashing(
|
||||||
"extract project information.")
|
addCMakePrefix(Tr::tr("Failed to set up CMake file API support. %1 cannot "
|
||||||
.arg(QGuiApplication::applicationDisplayName()));
|
"extract project information.")
|
||||||
|
.arg(QGuiApplication::applicationDisplayName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::pair<int, int> cmakeVersion(const QJsonObject &obj)
|
static std::pair<int, int> cmakeVersion(const QJsonObject &obj)
|
||||||
|
|||||||
@@ -303,8 +303,9 @@ void FileApiReader::makeBackupConfiguration(bool store)
|
|||||||
replyPrev.removeRecursively();
|
replyPrev.removeRecursively();
|
||||||
QTC_CHECK(!replyPrev.exists());
|
QTC_CHECK(!replyPrev.exists());
|
||||||
if (!reply.renameFile(replyPrev))
|
if (!reply.renameFile(replyPrev))
|
||||||
Core::MessageManager::writeFlashing(Tr::tr("Failed to rename \"%1\" to \"%2\".")
|
Core::MessageManager::writeFlashing(
|
||||||
.arg(reply.toString(), replyPrev.toString()));
|
addCMakePrefix(Tr::tr("Failed to rename \"%1\" to \"%2\".")
|
||||||
|
.arg(reply.toString(), replyPrev.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath cmakeCacheTxt = m_parameters.buildDirectory.pathAppended("CMakeCache.txt");
|
FilePath cmakeCacheTxt = m_parameters.buildDirectory.pathAppended("CMakeCache.txt");
|
||||||
@@ -315,8 +316,8 @@ void FileApiReader::makeBackupConfiguration(bool store)
|
|||||||
if (cmakeCacheTxt.exists())
|
if (cmakeCacheTxt.exists())
|
||||||
if (!FileUtils::copyIfDifferent(cmakeCacheTxt, cmakeCacheTxtPrev))
|
if (!FileUtils::copyIfDifferent(cmakeCacheTxt, cmakeCacheTxtPrev))
|
||||||
Core::MessageManager::writeFlashing(
|
Core::MessageManager::writeFlashing(
|
||||||
Tr::tr("Failed to copy \"%1\" to \"%2\".")
|
addCMakePrefix(Tr::tr("Failed to copy \"%1\" to \"%2\".")
|
||||||
.arg(cmakeCacheTxt.toString(), cmakeCacheTxtPrev.toString()));
|
.arg(cmakeCacheTxt.toString(), cmakeCacheTxtPrev.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &configurationArguments)
|
void FileApiReader::writeConfigurationIntoBuildDirectory(const QStringList &configurationArguments)
|
||||||
|
|||||||
Reference in New Issue
Block a user