forked from qt-creator/qt-creator
ProjectExplorer: Use ToolChainFactories to clone ToolChains
Centrally. Change-Id: Ie832c5ad0eb282192440d9d4d058d082d9513cc2 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -388,11 +388,6 @@ FileName IarToolChain::makeCommand(const Environment &env) const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *IarToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new IarToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// IarToolChainFactory
|
// IarToolChainFactory
|
||||||
|
|
||||||
IarToolChainFactory::IarToolChainFactory()
|
IarToolChainFactory::IarToolChainFactory()
|
||||||
|
|||||||
@@ -83,11 +83,6 @@ public:
|
|||||||
|
|
||||||
Utils::FileName makeCommand(const Utils::Environment &env) const final;
|
Utils::FileName makeCommand(const Utils::Environment &env) const final;
|
||||||
|
|
||||||
ToolChain *clone() const final;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
IarToolChain(const IarToolChain &tc) = default;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IarToolChain();
|
IarToolChain();
|
||||||
|
|
||||||
|
|||||||
@@ -393,11 +393,6 @@ FileName KeilToolchain::makeCommand(const Environment &env) const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *KeilToolchain::clone() const
|
|
||||||
{
|
|
||||||
return new KeilToolchain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// KeilToolchainFactory
|
// KeilToolchainFactory
|
||||||
|
|
||||||
KeilToolchainFactory::KeilToolchainFactory()
|
KeilToolchainFactory::KeilToolchainFactory()
|
||||||
|
|||||||
@@ -83,11 +83,6 @@ public:
|
|||||||
|
|
||||||
Utils::FileName makeCommand(const Utils::Environment &env) const final;
|
Utils::FileName makeCommand(const Utils::Environment &env) const final;
|
||||||
|
|
||||||
ToolChain *clone() const final;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
KeilToolchain(const KeilToolchain &tc) = default;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeilToolchain();
|
KeilToolchain();
|
||||||
|
|
||||||
|
|||||||
@@ -378,11 +378,6 @@ FileName SdccToolChain::makeCommand(const Environment &env) const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *SdccToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new SdccToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// SdccToolChainFactory
|
// SdccToolChainFactory
|
||||||
|
|
||||||
SdccToolChainFactory::SdccToolChainFactory()
|
SdccToolChainFactory::SdccToolChainFactory()
|
||||||
|
|||||||
@@ -83,11 +83,6 @@ public:
|
|||||||
|
|
||||||
Utils::FileName makeCommand(const Utils::Environment &env) const final;
|
Utils::FileName makeCommand(const Utils::Environment &env) const final;
|
||||||
|
|
||||||
ToolChain *clone() const final;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SdccToolChain(const SdccToolChain &tc) = default;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SdccToolChain();
|
SdccToolChain();
|
||||||
|
|
||||||
|
|||||||
@@ -140,11 +140,6 @@ std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> NimToolChain::createConf
|
|||||||
return std::make_unique<NimToolChainConfigWidget>(this);
|
return std::make_unique<NimToolChainConfigWidget>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *NimToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new NimToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap NimToolChain::toMap() const
|
QVariantMap NimToolChain::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap data = ToolChain::toMap();
|
QVariantMap data = ToolChain::toMap();
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ public:
|
|||||||
void setCompilerCommand(const Utils::FileName &compilerCommand);
|
void setCompilerCommand(const Utils::FileName &compilerCommand);
|
||||||
ProjectExplorer::IOutputParser *outputParser() const final;
|
ProjectExplorer::IOutputParser *outputParser() const final;
|
||||||
std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() final;
|
std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() final;
|
||||||
ProjectExplorer::ToolChain *clone() const final;
|
|
||||||
|
|
||||||
QVariantMap toMap() const final;
|
QVariantMap toMap() const final;
|
||||||
bool fromMap(const QVariantMap &data) final;
|
bool fromMap(const QVariantMap &data) final;
|
||||||
|
|||||||
@@ -289,11 +289,6 @@ QString CustomToolChain::mkspecs() const
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *CustomToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new CustomToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap CustomToolChain::toMap() const
|
QVariantMap CustomToolChain::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap data = ToolChain::toMap();
|
QVariantMap data = ToolChain::toMap();
|
||||||
|
|||||||
@@ -105,17 +105,12 @@ public:
|
|||||||
void setMkspecs(const QString &);
|
void setMkspecs(const QString &);
|
||||||
QString mkspecs() const;
|
QString mkspecs() const;
|
||||||
|
|
||||||
ToolChain *clone() const override;
|
|
||||||
|
|
||||||
Core::Id outputParserId() const;
|
Core::Id outputParserId() const;
|
||||||
void setOutputParserId(Core::Id parserId);
|
void setOutputParserId(Core::Id parserId);
|
||||||
CustomParserSettings customParserSettings() const;
|
CustomParserSettings customParserSettings() const;
|
||||||
void setCustomParserSettings(const CustomParserSettings &settings);
|
void setCustomParserSettings(const CustomParserSettings &settings);
|
||||||
static QList<CustomToolChain::Parser> parsers();
|
static QList<CustomToolChain::Parser> parsers();
|
||||||
|
|
||||||
protected:
|
|
||||||
CustomToolChain(const CustomToolChain &) = default;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CustomToolChain();
|
CustomToolChain();
|
||||||
|
|
||||||
|
|||||||
@@ -646,8 +646,6 @@ void GccToolChain::addCommandPathToEnvironment(const FileName &command, Environm
|
|||||||
env.prependOrSetPath(compilerDir.toString());
|
env.prependOrSetPath(compilerDir.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
GccToolChain::GccToolChain(const GccToolChain &) = default;
|
|
||||||
|
|
||||||
void GccToolChain::addToEnvironment(Environment &env) const
|
void GccToolChain::addToEnvironment(Environment &env) const
|
||||||
{
|
{
|
||||||
// On Windows gcc invokes cc1plus which is in libexec directory.
|
// On Windows gcc invokes cc1plus which is in libexec directory.
|
||||||
@@ -775,11 +773,6 @@ QStringList GccToolChain::platformLinkerFlags() const
|
|||||||
return m_platformLinkerFlags;
|
return m_platformLinkerFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *GccToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new GccToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap GccToolChain::toMap() const
|
QVariantMap GccToolChain::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap data = ToolChain::toMap();
|
QVariantMap data = ToolChain::toMap();
|
||||||
@@ -1279,11 +1272,6 @@ ClangToolChain::ClangToolChain(Core::Id typeId) :
|
|||||||
syncAutodetectedWithParentToolchains();
|
syncAutodetectedWithParentToolchains();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangToolChain::ClangToolChain(const ClangToolChain &other)
|
|
||||||
: GccToolChain(other)
|
|
||||||
, m_parentToolChainId(other.m_parentToolChainId)
|
|
||||||
{}
|
|
||||||
|
|
||||||
ClangToolChain::~ClangToolChain()
|
ClangToolChain::~ClangToolChain()
|
||||||
{
|
{
|
||||||
QObject::disconnect(m_thisToolchainRemovedConnection);
|
QObject::disconnect(m_thisToolchainRemovedConnection);
|
||||||
@@ -1447,11 +1435,6 @@ IOutputParser *ClangToolChain::outputParser() const
|
|||||||
return new ClangParser;
|
return new ClangParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *ClangToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new ClangToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// ClangToolChainFactory
|
// ClangToolChainFactory
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -1652,11 +1635,6 @@ FileName MingwToolChain::makeCommand(const Environment &environment) const
|
|||||||
return FileName::fromString(makes.first());
|
return FileName::fromString(makes.first());
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *MingwToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new MingwToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// MingwToolChainFactory
|
// MingwToolChainFactory
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -1743,11 +1721,6 @@ FileNameList LinuxIccToolChain::suggestedMkspecList() const
|
|||||||
<< FileName::fromString(QString::fromLatin1("linux-icc-") + QString::number(targetAbi().wordWidth()));
|
<< FileName::fromString(QString::fromLatin1("linux-icc-") + QString::number(targetAbi().wordWidth()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *LinuxIccToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new LinuxIccToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// LinuxIccToolChainFactory
|
// LinuxIccToolChainFactory
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -107,8 +107,6 @@ public:
|
|||||||
void setPlatformLinkerFlags(const QStringList &);
|
void setPlatformLinkerFlags(const QStringList &);
|
||||||
QStringList platformLinkerFlags() const;
|
QStringList platformLinkerFlags() const;
|
||||||
|
|
||||||
ToolChain *clone() const override;
|
|
||||||
|
|
||||||
static void addCommandPathToEnvironment(const Utils::FileName &command, Utils::Environment &env);
|
static void addCommandPathToEnvironment(const Utils::FileName &command, Utils::Environment &env);
|
||||||
|
|
||||||
class DetectedAbisResult {
|
class DetectedAbisResult {
|
||||||
@@ -128,8 +126,6 @@ protected:
|
|||||||
using CacheItem = QPair<QStringList, Macros>;
|
using CacheItem = QPair<QStringList, Macros>;
|
||||||
using GccCache = QVector<CacheItem>;
|
using GccCache = QVector<CacheItem>;
|
||||||
|
|
||||||
GccToolChain(const GccToolChain &);
|
|
||||||
|
|
||||||
void setCompilerCommand(const Utils::FileName &path);
|
void setCompilerCommand(const Utils::FileName &path);
|
||||||
void setSupportedAbis(const QList<Abi> &m_abis);
|
void setSupportedAbis(const QList<Abi> &m_abis);
|
||||||
void setOriginalTargetTriple(const QString &targetTriple);
|
void setOriginalTargetTriple(const QString &targetTriple);
|
||||||
@@ -227,8 +223,6 @@ public:
|
|||||||
|
|
||||||
IOutputParser *outputParser() const override;
|
IOutputParser *outputParser() const override;
|
||||||
|
|
||||||
ToolChain *clone() const override;
|
|
||||||
|
|
||||||
Utils::FileNameList suggestedMkspecList() const override;
|
Utils::FileNameList suggestedMkspecList() const override;
|
||||||
void addToEnvironment(Utils::Environment &env) const override;
|
void addToEnvironment(Utils::Environment &env) const override;
|
||||||
|
|
||||||
@@ -266,8 +260,6 @@ public:
|
|||||||
QString typeDisplayName() const override;
|
QString typeDisplayName() const override;
|
||||||
Utils::FileName makeCommand(const Utils::Environment &environment) const override;
|
Utils::FileName makeCommand(const Utils::Environment &environment) const override;
|
||||||
|
|
||||||
ToolChain *clone() const override;
|
|
||||||
|
|
||||||
Utils::FileNameList suggestedMkspecList() const override;
|
Utils::FileNameList suggestedMkspecList() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -289,8 +281,6 @@ public:
|
|||||||
Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const override;
|
Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const override;
|
||||||
IOutputParser *outputParser() const override;
|
IOutputParser *outputParser() const override;
|
||||||
|
|
||||||
ToolChain *clone() const override;
|
|
||||||
|
|
||||||
Utils::FileNameList suggestedMkspecList() const override;
|
Utils::FileNameList suggestedMkspecList() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -841,36 +841,6 @@ MsvcToolChain::MsvcToolChain(const QString &name,
|
|||||||
: MsvcToolChain(Constants::MSVC_TOOLCHAIN_TYPEID, name, abi, varsBat, varsBatArg)
|
: MsvcToolChain(Constants::MSVC_TOOLCHAIN_TYPEID, name, abi, varsBat, varsBatArg)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
MsvcToolChain::MsvcToolChain(const MsvcToolChain &other)
|
|
||||||
: ToolChain(other)
|
|
||||||
, m_headerPathsMutex(new QMutex)
|
|
||||||
, m_environmentModifications(other.m_environmentModifications)
|
|
||||||
, m_debuggerCommand(other.m_debuggerCommand)
|
|
||||||
, m_lastEnvironment(other.m_lastEnvironment)
|
|
||||||
, m_resultEnvironment(other.m_resultEnvironment)
|
|
||||||
, m_abi(other.m_abi)
|
|
||||||
, m_supportedAbis(other.m_supportedAbis)
|
|
||||||
, m_vcvarsBat(other.m_vcvarsBat)
|
|
||||||
, m_varsBatArg(other.m_varsBatArg)
|
|
||||||
{
|
|
||||||
if (other.m_envModWatcher.isRunning()) {
|
|
||||||
initEnvModWatcher(other.m_envModWatcher.future());
|
|
||||||
} else if (m_environmentModifications.isEmpty() && other.m_envModWatcher.future().isFinished()
|
|
||||||
&& !other.m_envModWatcher.future().isCanceled()) {
|
|
||||||
const GenerateEnvResult &result = m_envModWatcher.result();
|
|
||||||
if (result.error) {
|
|
||||||
const QString &errorMessage = *result.error;
|
|
||||||
if (!errorMessage.isEmpty())
|
|
||||||
TaskHub::addTask(Task::Error, errorMessage, Constants::TASK_CATEGORY_COMPILE);
|
|
||||||
} else {
|
|
||||||
updateEnvironmentModifications(result.environmentItems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setDisplayName(QCoreApplication::translate("ProjectExplorer::ToolChain", "Clone of %1")
|
|
||||||
.arg(other.displayName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void addToAvailableMsvcToolchains(const MsvcToolChain *toolchain)
|
static void addToAvailableMsvcToolchains(const MsvcToolChain *toolchain)
|
||||||
{
|
{
|
||||||
if (toolchain->typeId() != Constants::MSVC_TOOLCHAIN_TYPEID)
|
if (toolchain->typeId() != Constants::MSVC_TOOLCHAIN_TYPEID)
|
||||||
@@ -1081,11 +1051,6 @@ std::unique_ptr<ToolChainConfigWidget> MsvcToolChain::createConfigurationWidget(
|
|||||||
return std::make_unique<MsvcToolChainConfigWidget>(this);
|
return std::make_unique<MsvcToolChainConfigWidget>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *MsvcToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new MsvcToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool static hasFlagEffectOnMacros(const QString &flag)
|
bool static hasFlagEffectOnMacros(const QString &flag)
|
||||||
{
|
{
|
||||||
if (flag.startsWith("-") || flag.startsWith("/")) {
|
if (flag.startsWith("-") || flag.startsWith("/")) {
|
||||||
@@ -1748,11 +1713,6 @@ IOutputParser *ClangClToolChain::outputParser() const
|
|||||||
return new ClangClParser;
|
return new ClangClParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain *ClangClToolChain::clone() const
|
|
||||||
{
|
|
||||||
return new ClangClToolChain(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline QString llvmDirKey()
|
static inline QString llvmDirKey()
|
||||||
{
|
{
|
||||||
return QStringLiteral("ProjectExplorer.ClangClToolChain.LlvmDir");
|
return QStringLiteral("ProjectExplorer.ClangClToolChain.LlvmDir");
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ public:
|
|||||||
const Abi &abi,
|
const Abi &abi,
|
||||||
const QString &varsBat,
|
const QString &varsBat,
|
||||||
const QString &varsBatArg);
|
const QString &varsBatArg);
|
||||||
MsvcToolChain(const MsvcToolChain &other);
|
|
||||||
MsvcToolChain();
|
MsvcToolChain();
|
||||||
~MsvcToolChain() override;
|
~MsvcToolChain() override;
|
||||||
|
|
||||||
@@ -81,8 +80,6 @@ public:
|
|||||||
|
|
||||||
std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() override;
|
std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() override;
|
||||||
|
|
||||||
ToolChain *clone() const override;
|
|
||||||
|
|
||||||
MacroInspectionRunner createMacroInspectionRunner() const override;
|
MacroInspectionRunner createMacroInspectionRunner() const override;
|
||||||
Macros predefinedMacros(const QStringList &cxxflags) const override;
|
Macros predefinedMacros(const QStringList &cxxflags) const override;
|
||||||
Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const override;
|
Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const override;
|
||||||
@@ -191,7 +188,6 @@ public:
|
|||||||
void addToEnvironment(Utils::Environment &env) const override;
|
void addToEnvironment(Utils::Environment &env) const override;
|
||||||
Utils::FileName compilerCommand() const override;
|
Utils::FileName compilerCommand() const override;
|
||||||
IOutputParser *outputParser() const override;
|
IOutputParser *outputParser() const override;
|
||||||
ToolChain *clone() const override;
|
|
||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
bool fromMap(const QVariantMap &data) override;
|
bool fromMap(const QVariantMap &data) override;
|
||||||
std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() override;
|
std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() override;
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ static const char LANGUAGE_KEY_V2[] = "ProjectExplorer.ToolChain.LanguageV2"; //
|
|||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
static QList<ToolChainFactory *> g_toolChainFactories;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// ToolChainPrivate
|
// ToolChainPrivate
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -125,17 +127,6 @@ ToolChain::ToolChain(Core::Id typeId) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain::ToolChain(const ToolChain &other) : ToolChain(other.d->m_typeId)
|
|
||||||
{
|
|
||||||
d->m_language = other.d->m_language;
|
|
||||||
|
|
||||||
// leave the autodetection bit at false. // FIXME: <- is this comment valid.
|
|
||||||
d->m_detection = ManualDetection;
|
|
||||||
|
|
||||||
d->m_displayName = QCoreApplication::translate("ProjectExplorer::ToolChain", "Clone of %1")
|
|
||||||
.arg(other.displayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolChain::setLanguage(Core::Id language)
|
void ToolChain::setLanguage(Core::Id language)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!d->m_language.isValid() || isAutoDetected(), return);
|
QTC_ASSERT(!d->m_language.isValid() || isAutoDetected(), return);
|
||||||
@@ -209,6 +200,22 @@ bool ToolChain::operator == (const ToolChain &tc) const
|
|||||||
&& language() == tc.language();
|
&& language() == tc.language();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ToolChain *ToolChain::clone() const
|
||||||
|
{
|
||||||
|
for (ToolChainFactory *f : Internal::g_toolChainFactories) {
|
||||||
|
if (f->supportedToolChainType() == d->m_typeId) {
|
||||||
|
ToolChain *tc = f->create();
|
||||||
|
QTC_ASSERT(tc, return nullptr);
|
||||||
|
tc->fromMap(toMap());
|
||||||
|
// New ID for the clone. It's different.
|
||||||
|
tc->d->m_id = QUuid::createUuid().toByteArray();
|
||||||
|
return tc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QTC_CHECK(false);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Used by the tool chain manager to save user-generated tool chains.
|
Used by the tool chain manager to save user-generated tool chains.
|
||||||
|
|
||||||
@@ -408,21 +415,19 @@ QString ToolChain::sysRoot() const
|
|||||||
Used by the tool chain manager to restore user-generated tool chains.
|
Used by the tool chain manager to restore user-generated tool chains.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static QList<ToolChainFactory *> g_toolChainFactories;
|
|
||||||
|
|
||||||
ToolChainFactory::ToolChainFactory()
|
ToolChainFactory::ToolChainFactory()
|
||||||
{
|
{
|
||||||
g_toolChainFactories.append(this);
|
Internal::g_toolChainFactories.append(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChainFactory::~ToolChainFactory()
|
ToolChainFactory::~ToolChainFactory()
|
||||||
{
|
{
|
||||||
g_toolChainFactories.removeOne(this);
|
Internal::g_toolChainFactories.removeOne(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<ToolChainFactory *> ToolChainFactory::allToolChainFactories()
|
const QList<ToolChainFactory *> ToolChainFactory::allToolChainFactories()
|
||||||
{
|
{
|
||||||
return g_toolChainFactories;
|
return Internal::g_toolChainFactories;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ToolChain *> ToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
|
QList<ToolChain *> ToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public:
|
|||||||
virtual bool operator ==(const ToolChain &) const;
|
virtual bool operator ==(const ToolChain &) const;
|
||||||
|
|
||||||
virtual std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() = 0;
|
virtual std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() = 0;
|
||||||
virtual ToolChain *clone() const = 0;
|
ToolChain *clone() const;
|
||||||
|
|
||||||
// Used by the toolchainmanager to save user-generated tool chains.
|
// Used by the toolchainmanager to save user-generated tool chains.
|
||||||
// Make sure to call this function when deriving!
|
// Make sure to call this function when deriving!
|
||||||
@@ -163,7 +163,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit ToolChain(Core::Id typeId);
|
explicit ToolChain(Core::Id typeId);
|
||||||
explicit ToolChain(const ToolChain &);
|
|
||||||
|
|
||||||
const MacrosCache &predefinedMacrosCache() const;
|
const MacrosCache &predefinedMacrosCache() const;
|
||||||
const HeaderPathsCache &headerPathsCache() const;
|
const HeaderPathsCache &headerPathsCache() const;
|
||||||
@@ -174,6 +173,9 @@ protected:
|
|||||||
virtual bool fromMap(const QVariantMap &data);
|
virtual bool fromMap(const QVariantMap &data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ToolChain(const ToolChain &) = delete;
|
||||||
|
ToolChain &operator=(const ToolChain &) = delete;
|
||||||
|
|
||||||
const std::unique_ptr<Internal::ToolChainPrivate> d;
|
const std::unique_ptr<Internal::ToolChainPrivate> d;
|
||||||
|
|
||||||
friend class Internal::ToolChainSettingsAccessor;
|
friend class Internal::ToolChainSettingsAccessor;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
@@ -533,6 +534,8 @@ void ToolChainOptionsWidget::cloneToolChain()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
tc->setDetection(ToolChain::ManualDetection);
|
tc->setDetection(ToolChain::ManualDetection);
|
||||||
|
tc->setDisplayName(QCoreApplication::translate("ProjectExplorer::ToolChain", "Clone of %1")
|
||||||
|
.arg(current->toolChain->displayName()));
|
||||||
|
|
||||||
auto item = insertToolChain(tc, true);
|
auto item = insertToolChain(tc, true);
|
||||||
m_toAddList.append(item);
|
m_toAddList.append(item);
|
||||||
|
|||||||
@@ -292,11 +292,17 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
using TCList = QList<ToolChain *>;
|
using TCList = QList<ToolChain *>;
|
||||||
|
|
||||||
|
const char TestTokenKey[] = "TestTokenKey";
|
||||||
|
const char TestToolChainType[] = "TestToolChainType";
|
||||||
|
|
||||||
|
|
||||||
class TTC : public ToolChain
|
class TTC : public ToolChain
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TTC() : ToolChain(TestToolChainType) {}
|
||||||
|
|
||||||
TTC(const QByteArray &t, bool v = true) :
|
TTC(const QByteArray &t, bool v = true) :
|
||||||
ToolChain("TestToolChainType"),
|
ToolChain(TestToolChainType),
|
||||||
token(t),
|
token(t),
|
||||||
m_valid(v)
|
m_valid(v)
|
||||||
{
|
{
|
||||||
@@ -322,21 +328,29 @@ public:
|
|||||||
FileName compilerCommand() const override { return Utils::FileName::fromString("/tmp/test/gcc"); }
|
FileName compilerCommand() const override { return Utils::FileName::fromString("/tmp/test/gcc"); }
|
||||||
IOutputParser *outputParser() const override { return nullptr; }
|
IOutputParser *outputParser() const override { return nullptr; }
|
||||||
std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() override { return nullptr; }
|
std::unique_ptr<ToolChainConfigWidget> createConfigurationWidget() override { return nullptr; }
|
||||||
TTC *clone() const override { return new TTC(*this); }
|
|
||||||
bool operator ==(const ToolChain &other) const override {
|
bool operator ==(const ToolChain &other) const override {
|
||||||
if (!ToolChain::operator==(other))
|
if (!ToolChain::operator==(other))
|
||||||
return false;
|
return false;
|
||||||
return static_cast<const TTC *>(&other)->token == token;
|
return static_cast<const TTC *>(&other)->token == token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fromMap(const QVariantMap &data) final
|
||||||
|
{
|
||||||
|
ToolChain::fromMap(data);
|
||||||
|
token = data.value(TestTokenKey).toByteArray();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap toMap() const final
|
||||||
|
{
|
||||||
|
QVariantMap data = ToolChain::toMap();
|
||||||
|
data[TestTokenKey] = token;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray token;
|
QByteArray token;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TTC(const TTC &other) :
|
|
||||||
ToolChain(other.typeId()),
|
|
||||||
token(other.token)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool m_valid = false;
|
bool m_valid = false;
|
||||||
|
|
||||||
static QList<TTC *> m_toolChains;
|
static QList<TTC *> m_toolChains;
|
||||||
@@ -354,6 +368,17 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
void ProjectExplorerPlugin::testToolChainMerging_data()
|
void ProjectExplorerPlugin::testToolChainMerging_data()
|
||||||
{
|
{
|
||||||
|
class TestToolChainFactory : ToolChainFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TestToolChainFactory() {
|
||||||
|
setSupportedToolChainType(TestToolChainType);
|
||||||
|
setToolchainConstructor([] { return new TTC; });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TestToolChainFactory factory;
|
||||||
|
|
||||||
QTest::addColumn<TCList>("system");
|
QTest::addColumn<TCList>("system");
|
||||||
QTest::addColumn<TCList>("user");
|
QTest::addColumn<TCList>("user");
|
||||||
QTest::addColumn<TCList>("autodetect");
|
QTest::addColumn<TCList>("autodetect");
|
||||||
@@ -361,15 +386,15 @@ void ProjectExplorerPlugin::testToolChainMerging_data()
|
|||||||
QTest::addColumn<TCList>("toRegister");
|
QTest::addColumn<TCList>("toRegister");
|
||||||
|
|
||||||
TTC *system1 = nullptr;
|
TTC *system1 = nullptr;
|
||||||
TTC *system1c = nullptr;
|
ToolChain *system1c = nullptr;
|
||||||
TTC *system2 = nullptr;
|
TTC *system2 = nullptr;
|
||||||
TTC *system3i = nullptr;
|
TTC *system3i = nullptr;
|
||||||
TTC *user1 = nullptr;
|
TTC *user1 = nullptr;
|
||||||
TTC *user1c = nullptr;
|
ToolChain *user1c = nullptr;
|
||||||
TTC *user3i = nullptr;
|
TTC *user3i = nullptr;
|
||||||
TTC *user2 = nullptr;
|
TTC *user2 = nullptr;
|
||||||
TTC *auto1 = nullptr;
|
TTC *auto1 = nullptr;
|
||||||
TTC *auto1c = nullptr;
|
ToolChain *auto1c = nullptr;
|
||||||
TTC *auto1_2 = nullptr;
|
TTC *auto1_2 = nullptr;
|
||||||
TTC *auto2 = nullptr;
|
TTC *auto2 = nullptr;
|
||||||
TTC *auto3i = nullptr;
|
TTC *auto3i = nullptr;
|
||||||
@@ -377,21 +402,21 @@ void ProjectExplorerPlugin::testToolChainMerging_data()
|
|||||||
if (!TTC::hasToolChains()) {
|
if (!TTC::hasToolChains()) {
|
||||||
system1 = new TTC("system1");
|
system1 = new TTC("system1");
|
||||||
system1->setDetection(ToolChain::AutoDetection);
|
system1->setDetection(ToolChain::AutoDetection);
|
||||||
system1c = system1->clone(); Q_UNUSED(system1c);
|
system1c = system1->clone(); Q_UNUSED(system1c)
|
||||||
system2 = new TTC("system2");
|
system2 = new TTC("system2");
|
||||||
system2->setDetection(ToolChain::AutoDetection);
|
system2->setDetection(ToolChain::AutoDetection);
|
||||||
system3i = new TTC("system3", false);
|
system3i = new TTC("system3", false);
|
||||||
system3i->setDetection(ToolChain::AutoDetection);
|
system3i->setDetection(ToolChain::AutoDetection);
|
||||||
user1 = new TTC("user1");
|
user1 = new TTC("user1");
|
||||||
user1->setDetection(ToolChain::ManualDetection);
|
user1->setDetection(ToolChain::ManualDetection);
|
||||||
user1c = user1->clone(); Q_UNUSED(user1c);
|
user1c = user1->clone(); Q_UNUSED(user1c)
|
||||||
user2 = new TTC("user2");
|
user2 = new TTC("user2");
|
||||||
user2->setDetection(ToolChain::ManualDetection);
|
user2->setDetection(ToolChain::ManualDetection);
|
||||||
user3i = new TTC("user3", false);
|
user3i = new TTC("user3", false);
|
||||||
user3i->setDetection(ToolChain::ManualDetection);
|
user3i->setDetection(ToolChain::ManualDetection);
|
||||||
auto1 = new TTC("auto1");
|
auto1 = new TTC("auto1");
|
||||||
auto1->setDetection(ToolChain::AutoDetection);
|
auto1->setDetection(ToolChain::AutoDetection);
|
||||||
auto1c = auto1->clone(); Q_UNUSED(auto1c);
|
auto1c = auto1->clone();
|
||||||
auto1_2 = new TTC("auto1");
|
auto1_2 = new TTC("auto1");
|
||||||
auto1_2->setDetection(ToolChain::AutoDetection);
|
auto1_2->setDetection(ToolChain::AutoDetection);
|
||||||
auto2 = new TTC("auto2");
|
auto2 = new TTC("auto2");
|
||||||
|
|||||||
Reference in New Issue
Block a user