aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/customtoolchain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/projectexplorer/customtoolchain.cpp')
-rw-r--r--src/plugins/projectexplorer/customtoolchain.cpp186
1 files changed, 82 insertions, 104 deletions
diff --git a/src/plugins/projectexplorer/customtoolchain.cpp b/src/plugins/projectexplorer/customtoolchain.cpp
index 654337ab2c..afb824105c 100644
--- a/src/plugins/projectexplorer/customtoolchain.cpp
+++ b/src/plugins/projectexplorer/customtoolchain.cpp
@@ -30,7 +30,7 @@
#include "linuxiccparser.h"
#include "msvcparser.h"
#include "customparser.h"
-#include "customparserconfigdialog.h"
+#include "projectexplorer.h"
#include "projectexplorerconstants.h"
#include "projectmacro.h"
#include "toolchainmanager.h"
@@ -40,13 +40,14 @@
#include <utils/environment.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
+#include <utils/stringutils.h>
+#include <QComboBox>
#include <QFormLayout>
-#include <QPlainTextEdit>
-#include <QLineEdit>
#include <QHBoxLayout>
-#include <QComboBox>
-#include <QPushButton>
+#include <QLineEdit>
+#include <QPlainTextEdit>
+#include <QUuid>
using namespace Utils;
@@ -64,18 +65,6 @@ static const char headerPathsKeyC[] = "ProjectExplorer.CustomToolChain.HeaderPat
static const char cxx11FlagsKeyC[] = "ProjectExplorer.CustomToolChain.Cxx11Flags";
static const char mkspecsKeyC[] = "ProjectExplorer.CustomToolChain.Mkspecs";
static const char outputParserKeyC[] = "ProjectExplorer.CustomToolChain.OutputParser";
-static const char errorPatternKeyC[] = "ProjectExplorer.CustomToolChain.ErrorPattern";
-static const char errorLineNumberCapKeyC[] = "ProjectExplorer.CustomToolChain.ErrorLineNumberCap";
-static const char errorFileNameCapKeyC[] = "ProjectExplorer.CustomToolChain.ErrorFileNameCap";
-static const char errorMessageCapKeyC[] = "ProjectExplorer.CustomToolChain.ErrorMessageCap";
-static const char errorChannelKeyC[] = "ProjectExplorer.CustomToolChain.ErrorChannel";
-static const char errorExampleKeyC[] = "ProjectExplorer.CustomToolChain.ErrorExample";
-static const char warningPatternKeyC[] = "ProjectExplorer.CustomToolChain.WarningPattern";
-static const char warningLineNumberCapKeyC[] = "ProjectExplorer.CustomToolChain.WarningLineNumberCap";
-static const char warningFileNameCapKeyC[] = "ProjectExplorer.CustomToolChain.WarningFileNameCap";
-static const char warningMessageCapKeyC[] = "ProjectExplorer.CustomToolChain.WarningMessageCap";
-static const char warningChannelKeyC[] = "ProjectExplorer.CustomToolChain.WarningChannel";
-static const char warningExampleKeyC[] = "ProjectExplorer.CustomToolChain.WarningExample";
// --------------------------------------------------------------------------
// CustomToolChain
@@ -85,7 +74,15 @@ CustomToolChain::CustomToolChain() :
ToolChain(Constants::CUSTOM_TOOLCHAIN_TYPEID),
m_outputParserId(GccParser::id())
{
- setTypeDisplayName(Internal::CustomToolChainFactory::tr("Custom"));
+ setTypeDisplayName(tr("Custom"));
+}
+
+Internal::CustomParserSettings CustomToolChain::customParserSettings() const
+{
+ return findOrDefault(ProjectExplorerPlugin::customParsers(),
+ [this](const Internal::CustomParserSettings &s) {
+ return s.id == outputParserId();
+ });
}
Abi CustomToolChain::targetAbi() const
@@ -110,7 +107,7 @@ bool CustomToolChain::isValid() const
ToolChain::MacroInspectionRunner CustomToolChain::createMacroInspectionRunner() const
{
const Macros theMacros = m_predefinedMacros;
- const Core::Id lang = language();
+ const Utils::Id lang = language();
// This runner must be thread-safe!
return [theMacros, lang](const QStringList &cxxflags){
@@ -196,19 +193,18 @@ QStringList CustomToolChain::suggestedMkspecList() const
return m_mkspecs;
}
-IOutputParser *CustomToolChain::outputParser() const
+QList<Utils::OutputLineParser *> CustomToolChain::createOutputParsers() const
{
if (m_outputParserId == GccParser::id())
- return new GccParser;
+ return GccParser::gccParserSuite();
if (m_outputParserId == ClangParser::id())
- return new ClangParser;
+ return ClangParser::clangParserSuite();
if (m_outputParserId == LinuxIccParser::id())
- return new LinuxIccParser;
+ return LinuxIccParser::iccParserSuite();
if (m_outputParserId == MsvcParser::id())
- return new MsvcParser;
- if (m_outputParserId == CustomParser::id())
- return new CustomParser(m_customParserSettings);
- return nullptr;
+ return {new MsvcParser};
+ return {new Internal::CustomParser(customParserSettings())};
+ return {};
}
QStringList CustomToolChain::headerPathsList() const
@@ -293,18 +289,6 @@ QVariantMap CustomToolChain::toMap() const
data.insert(QLatin1String(cxx11FlagsKeyC), m_cxx11Flags);
data.insert(QLatin1String(mkspecsKeyC), mkspecs());
data.insert(QLatin1String(outputParserKeyC), m_outputParserId.toSetting());
- data.insert(QLatin1String(errorPatternKeyC), m_customParserSettings.error.pattern());
- data.insert(QLatin1String(errorFileNameCapKeyC), m_customParserSettings.error.fileNameCap());
- data.insert(QLatin1String(errorLineNumberCapKeyC), m_customParserSettings.error.lineNumberCap());
- data.insert(QLatin1String(errorMessageCapKeyC), m_customParserSettings.error.messageCap());
- data.insert(QLatin1String(errorChannelKeyC), m_customParserSettings.error.channel());
- data.insert(QLatin1String(errorExampleKeyC), m_customParserSettings.error.example());
- data.insert(QLatin1String(warningPatternKeyC), m_customParserSettings.warning.pattern());
- data.insert(QLatin1String(warningFileNameCapKeyC), m_customParserSettings.warning.fileNameCap());
- data.insert(QLatin1String(warningLineNumberCapKeyC), m_customParserSettings.warning.lineNumberCap());
- data.insert(QLatin1String(warningMessageCapKeyC), m_customParserSettings.warning.messageCap());
- data.insert(QLatin1String(warningChannelKeyC), m_customParserSettings.warning.channel());
- data.insert(QLatin1String(warningExampleKeyC), m_customParserSettings.warning.example());
return data;
}
@@ -322,21 +306,49 @@ bool CustomToolChain::fromMap(const QVariantMap &data)
setHeaderPaths(data.value(QLatin1String(headerPathsKeyC)).toStringList());
m_cxx11Flags = data.value(QLatin1String(cxx11FlagsKeyC)).toStringList();
setMkspecs(data.value(QLatin1String(mkspecsKeyC)).toString());
- setOutputParserId(Core::Id::fromSetting(data.value(QLatin1String(outputParserKeyC))));
- m_customParserSettings.error.setPattern(data.value(QLatin1String(errorPatternKeyC)).toString());
- m_customParserSettings.error.setFileNameCap(data.value(QLatin1String(errorFileNameCapKeyC)).toInt());
- m_customParserSettings.error.setLineNumberCap(data.value(QLatin1String(errorLineNumberCapKeyC)).toInt());
- m_customParserSettings.error.setMessageCap(data.value(QLatin1String(errorMessageCapKeyC)).toInt());
- m_customParserSettings.error.setChannel(
- static_cast<CustomParserExpression::CustomParserChannel>(data.value(QLatin1String(errorChannelKeyC)).toInt()));
- m_customParserSettings.error.setExample(data.value(QLatin1String(errorExampleKeyC)).toString());
- m_customParserSettings.warning.setPattern(data.value(QLatin1String(warningPatternKeyC)).toString());
- m_customParserSettings.warning.setFileNameCap(data.value(QLatin1String(warningFileNameCapKeyC)).toInt());
- m_customParserSettings.warning.setLineNumberCap(data.value(QLatin1String(warningLineNumberCapKeyC)).toInt());
- m_customParserSettings.warning.setMessageCap(data.value(QLatin1String(warningMessageCapKeyC)).toInt());
- m_customParserSettings.warning.setChannel(
- static_cast<CustomParserExpression::CustomParserChannel>(data.value(QLatin1String(warningChannelKeyC)).toInt()));
- m_customParserSettings.warning.setExample(data.value(QLatin1String(warningExampleKeyC)).toString());
+ setOutputParserId(Utils::Id::fromSetting(data.value(QLatin1String(outputParserKeyC))));
+
+ // Restore Pre-4.13 settings.
+ if (outputParserId() == Internal::CustomParser::id()) {
+ Internal::CustomParserSettings customParserSettings;
+ customParserSettings.error.setPattern(
+ data.value("ProjectExplorer.CustomToolChain.ErrorPattern").toString());
+ customParserSettings.error.setFileNameCap(
+ data.value("ProjectExplorer.CustomToolChain.ErrorLineNumberCap").toInt());
+ customParserSettings.error.setLineNumberCap(
+ data.value("ProjectExplorer.CustomToolChain.ErrorFileNameCap").toInt());
+ customParserSettings.error.setMessageCap(
+ data.value("ProjectExplorer.CustomToolChain.ErrorMessageCap").toInt());
+ customParserSettings.error.setChannel(
+ static_cast<Internal::CustomParserExpression::CustomParserChannel>(
+ data.value("ProjectExplorer.CustomToolChain.ErrorChannel").toInt()));
+ customParserSettings.error.setExample(
+ data.value("ProjectExplorer.CustomToolChain.ErrorExample").toString());
+ customParserSettings.warning.setPattern(
+ data.value("ProjectExplorer.CustomToolChain.WarningPattern").toString());
+ customParserSettings.warning.setFileNameCap(
+ data.value("ProjectExplorer.CustomToolChain.WarningLineNumberCap").toInt());
+ customParserSettings.warning.setLineNumberCap(
+ data.value("ProjectExplorer.CustomToolChain.WarningFileNameCap").toInt());
+ customParserSettings.warning.setMessageCap(
+ data.value("ProjectExplorer.CustomToolChain.WarningMessageCap").toInt());
+ customParserSettings.warning.setChannel(
+ static_cast<Internal::CustomParserExpression::CustomParserChannel>(
+ data.value("ProjectExplorer.CustomToolChain.WarningChannel").toInt()));
+ customParserSettings.warning.setExample(
+ data.value("ProjectExplorer.CustomToolChain.WarningExample").toString());
+ if (!customParserSettings.error.pattern().isEmpty()
+ || !customParserSettings.error.pattern().isEmpty()) {
+ // Found custom parser in old settings, move to new place.
+ customParserSettings.id = Utils::Id::fromString(QUuid::createUuid().toString());
+ setOutputParserId(customParserSettings.id);
+ customParserSettings.displayName = tr("Parser for toolchain %1").arg(displayName());
+ QList<Internal::CustomParserSettings> settings
+ = ProjectExplorerPlugin::customParsers();
+ settings << customParserSettings;
+ ProjectExplorerPlugin::setCustomParsers(settings);
+ }
+ }
return true;
}
@@ -354,12 +366,12 @@ bool CustomToolChain::operator ==(const ToolChain &other) const
&& m_builtInHeaderPaths == customTc->m_builtInHeaderPaths;
}
-Core::Id CustomToolChain::outputParserId() const
+Utils::Id CustomToolChain::outputParserId() const
{
return m_outputParserId;
}
-void CustomToolChain::setOutputParserId(Core::Id parserId)
+void CustomToolChain::setOutputParserId(Utils::Id parserId)
{
if (m_outputParserId == parserId)
return;
@@ -367,19 +379,6 @@ void CustomToolChain::setOutputParserId(Core::Id parserId)
toolChainUpdated();
}
-CustomParserSettings CustomToolChain::customParserSettings() const
-{
- return m_customParserSettings;
-}
-
-void CustomToolChain::setCustomParserSettings(const CustomParserSettings &settings)
-{
- if (m_customParserSettings == settings)
- return;
- m_customParserSettings = settings;
- toolChainUpdated();
-}
-
QList<CustomToolChain::Parser> CustomToolChain::parsers()
{
QList<CustomToolChain::Parser> result;
@@ -387,8 +386,6 @@ QList<CustomToolChain::Parser> CustomToolChain::parsers()
result.append({ClangParser::id(), tr("Clang")});
result.append({LinuxIccParser::id(), tr("ICC")});
result.append({MsvcParser::id(), tr("MSVC")});
- result.append({CustomParser::id(), tr("Custom")});
-
return result;
}
@@ -405,7 +402,7 @@ namespace Internal {
CustomToolChainFactory::CustomToolChainFactory()
{
- setDisplayName(tr("Custom"));
+ setDisplayName(CustomToolChain::tr("Custom"));
setSupportedToolChainType(Constants::CUSTOM_TOOLCHAIN_TYPEID);
setSupportsAllLanguages(true);
setToolchainConstructor([] { return new CustomToolChain; });
@@ -432,7 +429,7 @@ public:
QStringList entries() const
{
- return textEditWidget()->toPlainText().split(QLatin1Char('\n'), QString::SkipEmptyParts);
+ return textEditWidget()->toPlainText().split(QLatin1Char('\n'), Utils::SkipEmptyParts);
}
QString text() const
@@ -472,14 +469,15 @@ CustomToolChainConfigWidget::CustomToolChainConfigWidget(CustomToolChain *tc) :
m_headerDetails(new TextEditDetailsWidget(m_headerPaths)),
m_cxx11Flags(new QLineEdit),
m_mkspecs(new QLineEdit),
- m_errorParserComboBox(new QComboBox),
- m_customParserSettingsButton(new QPushButton(tr("Custom Parser Settings...")))
+ m_errorParserComboBox(new QComboBox)
{
Q_ASSERT(tc);
const QList<CustomToolChain::Parser> parsers = CustomToolChain::parsers();
for (const auto &parser : parsers)
m_errorParserComboBox->addItem(parser.displayName, parser.parserId.toString());
+ for (const Internal::CustomParserSettings &s : ProjectExplorerPlugin::customParsers())
+ m_errorParserComboBox->addItem(s.displayName, s.id.toString());
auto parserLayoutWidget = new QWidget;
auto parserLayout = new QHBoxLayout(parserLayoutWidget);
@@ -503,7 +501,6 @@ CustomToolChainConfigWidget::CustomToolChainConfigWidget(CustomToolChain *tc) :
m_mainLayout->addRow(tr("C++11 &flags:"), m_cxx11Flags);
m_mainLayout->addRow(tr("&Qt mkspecs:"), m_mkspecs);
parserLayout->addWidget(m_errorParserComboBox);
- parserLayout->addWidget(m_customParserSettingsButton);
m_mainLayout->addRow(tr("&Error parser:"), parserLayoutWidget);
addErrorLabel();
@@ -522,8 +519,6 @@ CustomToolChainConfigWidget::CustomToolChainConfigWidget(CustomToolChain *tc) :
connect(m_mkspecs, &QLineEdit::textChanged, this, &ToolChainConfigWidget::dirty);
connect(m_errorParserComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &CustomToolChainConfigWidget::errorParserChanged);
- connect(m_customParserSettingsButton, &QAbstractButton::clicked,
- this, &CustomToolChainConfigWidget::openCustomParserSettingsDialog);
errorParserChanged();
}
@@ -538,23 +533,9 @@ void CustomToolChainConfigWidget::updateSummaries()
void CustomToolChainConfigWidget::errorParserChanged(int )
{
- const auto currentId = Core::Id::fromSetting(m_errorParserComboBox->currentData());
- m_customParserSettingsButton->setEnabled(currentId == CustomParser::id());
emit dirty();
}
-void CustomToolChainConfigWidget::openCustomParserSettingsDialog()
-{
- CustomParserConfigDialog dialog;
- dialog.setSettings(m_customParserSettings);
-
- if (dialog.exec() == QDialog::Accepted) {
- m_customParserSettings = dialog.settings();
- if (dialog.isDirty())
- emit dirty();
- }
-}
-
void CustomToolChainConfigWidget::applyImpl()
{
if (toolChain()->isAutoDetected())
@@ -563,11 +544,11 @@ void CustomToolChainConfigWidget::applyImpl()
auto tc = static_cast<CustomToolChain *>(toolChain());
Q_ASSERT(tc);
QString displayName = tc->displayName();
- tc->setCompilerCommand(m_compilerCommand->fileName());
- tc->setMakeCommand(m_makeCommand->fileName());
+ tc->setCompilerCommand(m_compilerCommand->filePath());
+ tc->setMakeCommand(m_makeCommand->filePath());
tc->setTargetAbi(m_abiWidget->currentAbi());
Macros macros = Utils::transform<QVector>(
- m_predefinedDetails->text().split('\n', QString::SkipEmptyParts),
+ m_predefinedDetails->text().split('\n', Utils::SkipEmptyParts),
[](const QString &m) {
return Macro::fromKeyValue(m);
});
@@ -576,8 +557,7 @@ void CustomToolChainConfigWidget::applyImpl()
tc->setCxx11Flags(m_cxx11Flags->text().split(QLatin1Char(',')));
tc->setMkspecs(m_mkspecs->text());
tc->setDisplayName(displayName); // reset display name
- tc->setOutputParserId(Core::Id::fromSetting(m_errorParserComboBox->currentData()));
- tc->setCustomParserSettings(m_customParserSettings);
+ tc->setOutputParserId(Utils::Id::fromSetting(m_errorParserComboBox->currentData()));
setFromToolchain(); // Refresh with actual data from the toolchain. This shows what e.g. the
// macro parser did with the input.
@@ -588,8 +568,8 @@ void CustomToolChainConfigWidget::setFromToolchain()
// subwidgets are not yet connected!
QSignalBlocker blocker(this);
auto tc = static_cast<CustomToolChain *>(toolChain());
- m_compilerCommand->setFileName(tc->compilerCommand());
- m_makeCommand->setFileName(tc->makeCommand(Environment()));
+ m_compilerCommand->setFilePath(tc->compilerCommand());
+ m_makeCommand->setFilePath(tc->makeCommand(Environment()));
m_abiWidget->setAbis(Abis(), tc->targetAbi());
const QStringList macroLines = Utils::transform<QList>(tc->rawPredefinedMacros(), [](const Macro &m) {
return QString::fromUtf8(m.toKeyValue(QByteArray()));
@@ -600,22 +580,20 @@ void CustomToolChainConfigWidget::setFromToolchain()
m_mkspecs->setText(tc->mkspecs());
int index = m_errorParserComboBox->findData(tc->outputParserId().toSetting());
m_errorParserComboBox->setCurrentIndex(index);
- m_customParserSettings = tc->customParserSettings();
}
bool CustomToolChainConfigWidget::isDirtyImpl() const
{
auto tc = static_cast<CustomToolChain *>(toolChain());
Q_ASSERT(tc);
- return m_compilerCommand->fileName() != tc->compilerCommand()
- || m_makeCommand->path() != tc->makeCommand(Environment()).toString()
+ return m_compilerCommand->filePath() != tc->compilerCommand()
+ || m_makeCommand->filePath().toString() != tc->makeCommand(Environment()).toString()
|| m_abiWidget->currentAbi() != tc->targetAbi()
|| Macro::toMacros(m_predefinedDetails->text().toUtf8()) != tc->rawPredefinedMacros()
|| m_headerDetails->entries() != tc->headerPathsList()
|| m_cxx11Flags->text().split(QLatin1Char(',')) != tc->cxx11Flags()
|| m_mkspecs->text() != tc->mkspecs()
- || Core::Id::fromSetting(m_errorParserComboBox->currentData()) == tc->outputParserId()
- || m_customParserSettings != tc->customParserSettings();
+ || Utils::Id::fromSetting(m_errorParserComboBox->currentData()) == tc->outputParserId();
}
void CustomToolChainConfigWidget::makeReadOnlyImpl()