Nim: Added support for the Nim compiler inside Kits

Change-Id: I6f9761aac0b0fc02a6974b284a7d600c1ece5b8b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Filippo Cucchetto
2017-01-21 23:36:14 +01:00
parent bb916860ca
commit 28d9c305ad
11 changed files with 545 additions and 16 deletions

View File

@@ -37,7 +37,9 @@ HEADERS += \
settings/nimcodestylepreferencesfactory.h \ settings/nimcodestylepreferencesfactory.h \
settings/nimsettings.h \ settings/nimsettings.h \
settings/nimsnippetprovider.h \ settings/nimsnippetprovider.h \
settings/nimcodestylepreferenceswidget.h settings/nimcodestylepreferenceswidget.h \
project/nimtoolchain.h \
project/nimtoolchainfactory.h
SOURCES += \ SOURCES += \
nimplugin.cpp \ nimplugin.cpp \
@@ -66,7 +68,9 @@ SOURCES += \
settings/nimcodestylepreferencesfactory.cpp \ settings/nimcodestylepreferencesfactory.cpp \
settings/nimsettings.cpp \ settings/nimsettings.cpp \
settings/nimsnippetprovider.cpp \ settings/nimsnippetprovider.cpp \
settings/nimcodestylepreferenceswidget.cpp settings/nimcodestylepreferenceswidget.cpp \
project/nimtoolchain.cpp \
project/nimtoolchainfactory.cpp
FORMS += \ FORMS += \
project/nimcompilerbuildstepconfigwidget.ui \ project/nimcompilerbuildstepconfigwidget.ui \

View File

@@ -36,6 +36,10 @@ const char C_NIMEDITOR_ID[] = "Nim.NimEditor";
const char C_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "Nim Editor"); const char C_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "Nim Editor");
const char C_NIM_ICON_PATH[] = ":/images/nim.png"; const char C_NIM_ICON_PATH[] = ":/images/nim.png";
// NimToolChain
const char C_NIMTOOLCHAIN_TYPEID[] = "Nim.NimToolChain";
const char C_NIMTOOLCHAIN_COMPILER_COMMAND_KEY[] = "Nim.NimToolChain.CompilerCommand";
// NimRunConfiguration // NimRunConfiguration
const char C_NIMRUNCONFIGURATION_ID[] = "Nim.NimRunConfiguration"; const char C_NIMRUNCONFIGURATION_ID[] = "Nim.NimRunConfiguration";
const char C_NIMRUNCONFIGURATION_DISPLAY[] = QT_TRANSLATE_NOOP("NimRunConfiguration", "Current Build Target"); const char C_NIMRUNCONFIGURATION_DISPLAY[] = QT_TRANSLATE_NOOP("NimRunConfiguration", "Current Build Target");

View File

@@ -34,12 +34,14 @@
#include "project/nimprojectmanager.h" #include "project/nimprojectmanager.h"
#include "project/nimrunconfigurationfactory.h" #include "project/nimrunconfigurationfactory.h"
#include "project/nimruncontrolfactory.h" #include "project/nimruncontrolfactory.h"
#include "project/nimtoolchainfactory.h"
#include "settings/nimcodestylepreferencesfactory.h" #include "settings/nimcodestylepreferencesfactory.h"
#include "settings/nimcodestylesettingspage.h" #include "settings/nimcodestylesettingspage.h"
#include "settings/nimsettings.h" #include "settings/nimsettings.h"
#include "settings/nimsnippetprovider.h" #include "settings/nimsnippetprovider.h"
#include <coreplugin/fileiconprovider.h> #include <coreplugin/fileiconprovider.h>
#include <projectexplorer/toolchainmanager.h>
#include <utils/mimetypes/mimedatabase.h> #include <utils/mimetypes/mimedatabase.h>
#include <QtPlugin> #include <QtPlugin>
@@ -65,6 +67,8 @@ bool NimPlugin::initialize(const QStringList &arguments, QString *errorMessage)
Q_UNUSED(arguments) Q_UNUSED(arguments)
Q_UNUSED(errorMessage) Q_UNUSED(errorMessage)
ProjectExplorer::ToolChainManager::registerLanguage(Constants::C_NIMLANGUAGE_ID, Constants::C_NIMLANGUAGE_NAME);
MimeDatabase::addMimeTypes(QLatin1String(":/Nim.mimetypes.xml")); MimeDatabase::addMimeTypes(QLatin1String(":/Nim.mimetypes.xml"));
addAutoReleasedObject(new NimSettings); addAutoReleasedObject(new NimSettings);
@@ -78,6 +82,7 @@ bool NimPlugin::initialize(const QStringList &arguments, QString *errorMessage)
addAutoReleasedObject(new NimRunControlFactory); addAutoReleasedObject(new NimRunControlFactory);
addAutoReleasedObject(new NimCodeStyleSettingsPage); addAutoReleasedObject(new NimCodeStyleSettingsPage);
addAutoReleasedObject(new NimCodeStylePreferencesFactory); addAutoReleasedObject(new NimCodeStylePreferencesFactory);
addAutoReleasedObject(new NimToolChainFactory);
return true; return true;
} }

View File

@@ -126,6 +126,8 @@ BuildConfiguration *NimBuildConfigurationFactory::create(Target *parent, const B
bool NimBuildConfigurationFactory::canRestore(const Target *parent, const QVariantMap &map) const bool NimBuildConfigurationFactory::canRestore(const Target *parent, const QVariantMap &map) const
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
if (!canHandle(parent))
return false;
return NimBuildConfiguration::canRestore(map); return NimBuildConfiguration::canRestore(map);
} }
@@ -147,6 +149,8 @@ bool NimBuildConfigurationFactory::canClone(const Target *parent, BuildConfigura
{ {
QTC_ASSERT(parent, return false); QTC_ASSERT(parent, return false);
QTC_ASSERT(product, return false); QTC_ASSERT(product, return false);
if (!canHandle(parent))
return false;
return product->id() == Constants::C_NIMBUILDCONFIGURATION_ID; return product->id() == Constants::C_NIMBUILDCONFIGURATION_ID;
} }

View File

@@ -25,12 +25,13 @@
#include "nimcompilerbuildstep.h" #include "nimcompilerbuildstep.h"
#include "nimbuildconfiguration.h" #include "nimbuildconfiguration.h"
#include "nimconstants.h"
#include "nimcompilerbuildstepconfigwidget.h" #include "nimcompilerbuildstepconfigwidget.h"
#include "nimproject.h" #include "nimproject.h"
#include "nimtoolchain.h"
#include "../nimconstants.h"
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/kitinformation.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDir> #include <QDir>
@@ -154,7 +155,12 @@ void NimCompilerBuildStep::updateOutFilePath()
void NimCompilerBuildStep::updateCommand() void NimCompilerBuildStep::updateCommand()
{ {
processParameters()->setCommand(QStringLiteral("nim")); QTC_ASSERT(target(), return);
QTC_ASSERT(target()->kit(), return);
Kit *kit = target()->kit();
auto tc = dynamic_cast<NimToolChain*>(ToolChainKitInformation::toolChain(kit, Constants::C_NIMLANGUAGE_ID));
QTC_ASSERT(tc, return);
processParameters()->setCommand(tc->compilerCommand().toString());
} }
void NimCompilerBuildStep::updateWorkingDirectory() void NimCompilerBuildStep::updateWorkingDirectory()

View File

@@ -27,6 +27,7 @@
#include "nimbuildconfiguration.h" #include "nimbuildconfiguration.h"
#include "nimprojectnode.h" #include "nimprojectnode.h"
#include "nimprojectmanager.h" #include "nimprojectmanager.h"
#include "nimtoolchain.h"
#include "../nimconstants.h" #include "../nimconstants.h"
@@ -35,6 +36,8 @@
#include <projectexplorer/kit.h> #include <projectexplorer/kit.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/kitinformation.h>
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
@@ -163,9 +166,20 @@ void NimProject::updateProject()
emit parsingFinished(); emit parsingFinished();
} }
bool NimProject::supportsKit(Kit *k, QString *) const bool NimProject::supportsKit(Kit *k, QString *errorMessage) const
{ {
return k->isValid(); auto tc = dynamic_cast<NimToolChain*>(ToolChainKitInformation::toolChain(k, Constants::C_NIMLANGUAGE_ID));
if (!tc) {
if (errorMessage)
*errorMessage = tr("No nim compiler set.");
return false;
}
if (!tc->compilerCommand().exists()) {
if (errorMessage)
*errorMessage = tr("Nim compiler doesn't exist");
return false;
}
return true;
} }
FileNameList NimProject::nimFiles() const FileNameList NimProject::nimFiles() const

View File

@@ -39,22 +39,21 @@ using namespace ProjectExplorer;
namespace Nim { namespace Nim {
NimRunConfigurationFactory::NimRunConfigurationFactory() NimRunConfigurationFactory::NimRunConfigurationFactory()
{ {}
}
QList<Core::Id> NimRunConfigurationFactory::availableCreationIds(Target *parent, QList<Core::Id> NimRunConfigurationFactory::availableCreationIds(Target *parent,
IRunConfigurationFactory::CreationMode mode) const IRunConfigurationFactory::CreationMode mode) const
{ {
Q_UNUSED(mode); Q_UNUSED(mode);
QList<Core::Id> result;
if (canHandle(parent)) if (canHandle(parent))
return { Constants::C_NIMRUNCONFIGURATION_ID }; result.append(Constants::C_NIMRUNCONFIGURATION_ID);
return {}; return result;
} }
QString NimRunConfigurationFactory::displayNameForId(Core::Id id) const QString NimRunConfigurationFactory::displayNameForId(Core::Id id) const
{ {
QString result = id.toString() + QStringLiteral("-TempRunConf"); return id.toString() + QStringLiteral("-TempRunConf");
return result;
} }
bool NimRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const bool NimRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
@@ -74,7 +73,7 @@ bool NimRunConfigurationFactory::canClone(Target *parent, RunConfiguration *prod
{ {
QTC_ASSERT(parent, return false); QTC_ASSERT(parent, return false);
QTC_ASSERT(product, return false); QTC_ASSERT(product, return false);
return true; return canHandle(parent);
} }
RunConfiguration *NimRunConfigurationFactory::clone(Target *parent, RunConfiguration *product) RunConfiguration *NimRunConfigurationFactory::clone(Target *parent, RunConfiguration *product)
@@ -88,14 +87,15 @@ RunConfiguration *NimRunConfigurationFactory::clone(Target *parent, RunConfigura
bool NimRunConfigurationFactory::canHandle(Target *parent) const bool NimRunConfigurationFactory::canHandle(Target *parent) const
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
if (!parent->project()->supportsKit(parent->kit()))
return false;
return qobject_cast<NimProject *>(parent->project()); return qobject_cast<NimProject *>(parent->project());
} }
RunConfiguration *NimRunConfigurationFactory::doCreate(Target *parent, Core::Id id) RunConfiguration *NimRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
{ {
Q_UNUSED(id); Q_UNUSED(id);
auto result = new NimRunConfiguration(parent, id); return new NimRunConfiguration(parent, id);
return result;
} }
RunConfiguration *NimRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map) RunConfiguration *NimRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)

View File

@@ -0,0 +1,183 @@
/****************************************************************************
**
** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "nimtoolchain.h"
#include "nimconstants.h"
#include "nimtoolchainfactory.h"
#include <projectexplorer/abi.h>
#include <utils/environment.h>
#include <QFileInfo>
#include <QProcess>
using namespace ProjectExplorer;
using namespace Utils;
namespace Nim {
NimToolChain::NimToolChain(ToolChain::Detection d)
: NimToolChain(Constants::C_NIMTOOLCHAIN_TYPEID, d)
{}
NimToolChain::NimToolChain(Core::Id typeId, ToolChain::Detection d)
: ToolChain(typeId, d)
, m_compilerCommand(FileName())
, m_version(std::make_tuple(-1,-1,-1))
{
setLanguage(Constants::C_NIMLANGUAGE_ID);
}
NimToolChain::NimToolChain(const NimToolChain &other)
: ToolChain(other.typeId(), other.detection())
, m_compilerCommand(other.m_compilerCommand)
, m_version(other.m_version)
{
setLanguage(Constants::C_NIMLANGUAGE_ID);
}
QString NimToolChain::typeDisplayName() const
{
return NimToolChainFactory::tr("Nim");
}
Abi NimToolChain::targetAbi() const
{
return Abi();
}
bool NimToolChain::isValid() const
{
if (m_compilerCommand.isNull())
return false;
QFileInfo fi = compilerCommand().toFileInfo();
return fi.isExecutable();
}
QByteArray NimToolChain::predefinedMacros(const QStringList &) const
{
return QByteArray();
}
ToolChain::CompilerFlags NimToolChain::compilerFlags(const QStringList &) const
{
return CompilerFlag::NoFlags;
}
WarningFlags NimToolChain::warningFlags(const QStringList &) const
{
return WarningFlags::NoWarnings;
}
QList<HeaderPath> NimToolChain::systemHeaderPaths(const QStringList &, const FileName &) const
{
return QList<HeaderPath>();
}
void NimToolChain::addToEnvironment(Environment &env) const
{
if (isValid())
env.prependOrSetPath(compilerCommand().parentDir().toString());
}
QString NimToolChain::makeCommand(const Environment &env) const
{
QString make = "make";
FileName tmp = env.searchInPath(make);
return tmp.isEmpty() ? make : tmp.toString();
}
FileName NimToolChain::compilerCommand() const
{
return m_compilerCommand;
}
void NimToolChain::setCompilerCommand(const FileName &compilerCommand)
{
m_compilerCommand = compilerCommand;
parseVersion(compilerCommand, m_version);
}
IOutputParser *NimToolChain::outputParser() const
{
return nullptr;
}
ToolChainConfigWidget *NimToolChain::configurationWidget()
{
return new NimToolChainConfigWidget(this);
}
ToolChain *NimToolChain::clone() const
{
return new NimToolChain(*this);
}
QVariantMap NimToolChain::toMap() const
{
QVariantMap data = ToolChain::toMap();
data[Constants::C_NIMTOOLCHAIN_COMPILER_COMMAND_KEY] = m_compilerCommand.toString();
return data;
}
QString NimToolChain::compilerVersion() const
{
return m_compilerCommand.isEmpty() || m_version == std::make_tuple(-1,-1,-1)
? QString()
: QString::asprintf("%d.%d.%d",
std::get<0>(m_version),
std::get<1>(m_version),
std::get<2>(m_version));
}
bool NimToolChain::fromMap(const QVariantMap &data)
{
if (!ToolChain::fromMap(data))
return false;
setCompilerCommand(FileName::fromString(data.value(Constants::C_NIMTOOLCHAIN_COMPILER_COMMAND_KEY).toString()));
return true;
}
bool NimToolChain::parseVersion(const FileName &path, std::tuple<int, int, int> &result)
{
QProcess process;
process.setReadChannel(QProcess::StandardError);
process.start(path.toString(), {"--version"});
if (!process.waitForFinished())
return false;
const QString version = QString::fromUtf8(process.readLine());
if (version.isEmpty())
return false;
const QRegExp regex("(\\d+)\\.(\\d+)\\.(\\d+)");
if (regex.indexIn(version) == -1)
return false;
const QStringList text = regex.capturedTexts();
if (text.length() != 4)
return false;
result = std::make_tuple(text[1].toInt(), text[2].toInt(), text[3].toInt());
return true;
}
}

View File

@@ -0,0 +1,70 @@
/****************************************************************************
**
** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/toolchain.h>
#include <projectexplorer/headerpath.h>
namespace Nim {
class NimToolChain : public ProjectExplorer::ToolChain
{
public:
NimToolChain(Detection d);
NimToolChain(Core::Id typeId, Detection d);
QString typeDisplayName() const override;
ProjectExplorer::Abi targetAbi() const override;
bool isValid() const override;
QByteArray predefinedMacros(const QStringList &flags) const override;
CompilerFlags compilerFlags(const QStringList &flags) const;
ProjectExplorer::WarningFlags warningFlags(const QStringList &flags) const;
QList<ProjectExplorer::HeaderPath> systemHeaderPaths(const QStringList &flags,
const Utils::FileName &sysRoot) const override;
void addToEnvironment(Utils::Environment &env) const override;
QString makeCommand(const Utils::Environment &env) const override;
Utils::FileName compilerCommand() const override;
QString compilerVersion() const;
void setCompilerCommand(const Utils::FileName &compilerCommand);
ProjectExplorer::IOutputParser *outputParser() const override;
ProjectExplorer::ToolChainConfigWidget *configurationWidget() override;
ProjectExplorer::ToolChain *clone() const override;
QVariantMap toMap() const override;
bool fromMap(const QVariantMap &data) override;
static bool parseVersion(const Utils::FileName &path, std::tuple<int, int, int> &version);
private:
NimToolChain(const NimToolChain &other);
Utils::FileName m_compilerCommand;
std::tuple<int, int, int> m_version;
};
}

View File

@@ -0,0 +1,166 @@
/****************************************************************************
**
** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "nimtoolchainfactory.h"
#include "nimconstants.h"
#include "nimtoolchain.h"
#include <utils/algorithm.h>
#include <utils/environment.h>
#include <utils/pathchooser.h>
#include <QFormLayout>
#include <QProcess>
using namespace ProjectExplorer;
using namespace Utils;
namespace Nim {
NimToolChainFactory::NimToolChainFactory()
{
setDisplayName(tr("Nim"));
}
bool NimToolChainFactory::canCreate()
{
return true;
}
ToolChain *NimToolChainFactory::create(Core::Id l)
{
if (l != Constants::C_NIMLANGUAGE_ID)
return nullptr;
auto result = new NimToolChain(ToolChain::ManualDetection);
result->setLanguage(l);
return result;
}
bool NimToolChainFactory::canRestore(const QVariantMap &data)
{
return typeIdFromMap(data) == Constants::C_NIMTOOLCHAIN_TYPEID;
}
ToolChain *NimToolChainFactory::restore(const QVariantMap &data)
{
auto tc = new NimToolChain(ToolChain::AutoDetection);
if (tc->fromMap(data))
return tc;
delete tc;
return nullptr;
}
QSet<Core::Id> NimToolChainFactory::supportedLanguages() const
{
return { Constants::C_NIMLANGUAGE_ID };
}
QList<ToolChain *> NimToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
{
QList<ToolChain *> result;
Environment systemEnvironment = Environment::systemEnvironment();
const FileName compilerPath = systemEnvironment.searchInPath("nim");
if (compilerPath.isEmpty())
return result;
result = Utils::filtered(alreadyKnown, [compilerPath](ToolChain *tc) {
return tc->typeId() == Constants::C_NIMTOOLCHAIN_TYPEID
&& tc->compilerCommand() == compilerPath;
});
if (!result.empty())
return result;
auto tc = new NimToolChain(ToolChain::AutoDetection);
tc->setCompilerCommand(compilerPath);
result.append(tc);
return result;
}
NimToolChainConfigWidget::NimToolChainConfigWidget(NimToolChain *tc)
: ToolChainConfigWidget(tc)
, m_compilerCommand(new PathChooser)
, m_compilerVersion(new QLineEdit)
{
// Create ui
const auto gnuVersionArgs = QStringList("--version");
m_compilerCommand->setExpectedKind(PathChooser::ExistingCommand);
m_compilerCommand->setCommandVersionArguments(gnuVersionArgs);
m_mainLayout->addRow(tr("&Compiler path:"), m_compilerCommand);
m_compilerVersion->setReadOnly(true);
m_mainLayout->addRow(tr("&Compiler version:"), m_compilerVersion);
// Fill
fillUI();
// Connect
connect(m_compilerCommand, &PathChooser::pathChanged, this, &NimToolChainConfigWidget::onCompilerCommandChanged);
}
void NimToolChainConfigWidget::applyImpl()
{
auto tc = static_cast<NimToolChain *>(toolChain());
Q_ASSERT(tc);
if (tc->isAutoDetected())
return;
tc->setCompilerCommand(m_compilerCommand->fileName());
}
void NimToolChainConfigWidget::discardImpl()
{
fillUI();
}
bool NimToolChainConfigWidget::isDirtyImpl() const
{
auto tc = static_cast<NimToolChain *>(toolChain());
Q_ASSERT(tc);
return tc->compilerCommand().toString() != m_compilerCommand->path();
}
void NimToolChainConfigWidget::makeReadOnlyImpl()
{
m_compilerCommand->setReadOnly(true);
}
void NimToolChainConfigWidget::fillUI()
{
auto tc = static_cast<NimToolChain *>(toolChain());
Q_ASSERT(tc);
m_compilerCommand->setPath(tc->compilerCommand().toString());
m_compilerVersion->setText(tc->compilerVersion());
}
void NimToolChainConfigWidget::onCompilerCommandChanged(const QString &path)
{
auto tc = static_cast<NimToolChain *>(toolChain());
Q_ASSERT(tc);
tc->setCompilerCommand(FileName::fromString(path));
fillUI();
}
}

View File

@@ -0,0 +1,73 @@
/****************************************************************************
**
** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/toolchain.h>
#include <projectexplorer/toolchainconfigwidget.h>
namespace Utils { class PathChooser; }
namespace Nim {
class NimToolChain;
class NimToolChainFactory : public ProjectExplorer::ToolChainFactory
{
Q_OBJECT
public:
NimToolChainFactory();
bool canCreate() override;
ProjectExplorer::ToolChain *create(Core::Id l) override;
bool canRestore(const QVariantMap &data) override;
ProjectExplorer::ToolChain *restore(const QVariantMap &data) override;
QSet<Core::Id> supportedLanguages() const override;
QList<ProjectExplorer::ToolChain *> autoDetect(const QList<ProjectExplorer::ToolChain *> &alreadyKnown) override;
};
class NimToolChainConfigWidget : public ProjectExplorer::ToolChainConfigWidget
{
Q_OBJECT
public:
explicit NimToolChainConfigWidget(NimToolChain *tc);
protected:
void applyImpl() override;
void discardImpl() override;
bool isDirtyImpl() const override;
void makeReadOnlyImpl() override;
private:
void fillUI();
void onCompilerCommandChanged(const QString &path);
Utils::PathChooser *m_compilerCommand;
QLineEdit *m_compilerVersion;
};
}