forked from qt-creator/qt-creator
CMakePM: Allow usage of custom output parsers for CMake output
Fixes: QTCREATORBUG-29992 Change-Id: Ia84871cc963263c34054d17742556b38a1f1934e Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -8,16 +8,19 @@
|
||||
#include "cmakekitaspect.h"
|
||||
#include "cmaketoolmanager.h"
|
||||
|
||||
#include <projectexplorer/customparser.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/aspects.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
@@ -70,6 +73,15 @@ BuildDirParameters::BuildDirParameters(CMakeBuildSystem *buildSystem)
|
||||
environment.setFallback("CLICOLOR_FORCE", "1");
|
||||
|
||||
cmakeToolId = CMakeKitAspect::cmakeToolId(k);
|
||||
|
||||
outputParserGenerator = [k, bc]() {
|
||||
QList<OutputLineParser *> outputParsers = k->createOutputParsers();
|
||||
for (const Id id : bc->customParsers()) {
|
||||
if (auto parser = createCustomParserFromId(id))
|
||||
outputParsers << parser;
|
||||
}
|
||||
return outputParsers;
|
||||
};
|
||||
}
|
||||
|
||||
bool BuildDirParameters::isValid() const
|
||||
@@ -82,4 +94,10 @@ CMakeTool *BuildDirParameters::cmakeTool() const
|
||||
return CMakeToolManager::findById(cmakeToolId);
|
||||
}
|
||||
|
||||
QList<OutputLineParser *> BuildDirParameters::outputParsers() const
|
||||
{
|
||||
QTC_ASSERT(outputParserGenerator, return {});
|
||||
return outputParserGenerator();
|
||||
}
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
#include <utils/environment.h>
|
||||
#include <utils/filepath.h>
|
||||
|
||||
namespace Utils { class MacroExpander; }
|
||||
#include <functional>
|
||||
|
||||
namespace Utils {
|
||||
class MacroExpander;
|
||||
class OutputLineParser;
|
||||
} // namespace Utils
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
@@ -38,6 +43,12 @@ public:
|
||||
QStringList additionalCMakeArguments;
|
||||
|
||||
Utils::MacroExpander* expander = nullptr;
|
||||
|
||||
QList<Utils::OutputLineParser*> outputParsers() const;
|
||||
|
||||
private:
|
||||
using OutputParserGenerator = std::function<QList<Utils::OutputLineParser*>()>;
|
||||
OutputParserGenerator outputParserGenerator;
|
||||
};
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -110,6 +110,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
||||
const auto parser = new CMakeParser;
|
||||
parser->setSourceDirectory(parameters.sourceDirectory);
|
||||
m_parser.addLineParser(parser);
|
||||
m_parser.addLineParsers(parameters.outputParsers());
|
||||
|
||||
// Always use the sourceDir: If we are triggered because the build directory is getting deleted
|
||||
// then we are racing against CMakeCache.txt also getting deleted.
|
||||
|
||||
Reference in New Issue
Block a user