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