forked from qt-creator/qt-creator
ProjectExplorer: Consolidate *ToolChain::target() implementations
All ToolChains had an Abi member one way or the other, so have one in the base class and drop all others. Change-Id: Ic4ed47b77f51c2c53d5692c66e6103c6bb23277e Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -60,7 +60,6 @@ namespace Internal {
|
||||
|
||||
static const char compilerCommandKeyC[] = "CompilerPath";
|
||||
static const char compilerPlatformCodeGenFlagsKeyC[] = "PlatformCodeGenFlags";
|
||||
static const char targetAbiKeyC[] = "TargetAbi";
|
||||
|
||||
static bool compilerExists(const FilePath &compilerPath)
|
||||
{
|
||||
@@ -294,19 +293,7 @@ IarToolChain::IarToolChain() :
|
||||
ToolChain(Constants::IAREW_TOOLCHAIN_TYPEID)
|
||||
{
|
||||
setTypeDisplayName(Internal::IarToolChain::tr("IAREW"));
|
||||
}
|
||||
|
||||
void IarToolChain::setTargetAbi(const Abi &abi)
|
||||
{
|
||||
if (abi == m_targetAbi)
|
||||
return;
|
||||
m_targetAbi = abi;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
Abi IarToolChain::targetAbi() const
|
||||
{
|
||||
return m_targetAbi;
|
||||
setTargetAbiKey("TargetAbi");
|
||||
}
|
||||
|
||||
bool IarToolChain::isValid() const
|
||||
@@ -409,7 +396,6 @@ QVariantMap IarToolChain::toMap() const
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data.insert(compilerCommandKeyC, m_compilerCommand.toString());
|
||||
data.insert(compilerPlatformCodeGenFlagsKeyC, m_extraCodeModelFlags);
|
||||
data.insert(targetAbiKeyC, m_targetAbi.toString());
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -419,7 +405,6 @@ bool IarToolChain::fromMap(const QVariantMap &data)
|
||||
return false;
|
||||
m_compilerCommand = FilePath::fromString(data.value(compilerCommandKeyC).toString());
|
||||
m_extraCodeModelFlags = data.value(compilerPlatformCodeGenFlagsKeyC).toStringList();
|
||||
m_targetAbi = Abi::fromString(data.value(targetAbiKeyC).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -435,9 +420,7 @@ bool IarToolChain::operator==(const ToolChain &other) const
|
||||
|
||||
const auto customTc = static_cast<const IarToolChain *>(&other);
|
||||
return m_compilerCommand == customTc->m_compilerCommand
|
||||
&& m_targetAbi == customTc->m_targetAbi
|
||||
&& m_extraCodeModelFlags == customTc->m_extraCodeModelFlags
|
||||
;
|
||||
&& m_extraCodeModelFlags == customTc->m_extraCodeModelFlags;
|
||||
}
|
||||
|
||||
void IarToolChain::setCompilerCommand(const FilePath &file)
|
||||
|
@@ -53,9 +53,6 @@ class IarToolChain final : public ProjectExplorer::ToolChain
|
||||
Q_DECLARE_TR_FUNCTIONS(IarToolChain)
|
||||
|
||||
public:
|
||||
void setTargetAbi(const ProjectExplorer::Abi &abi);
|
||||
ProjectExplorer::Abi targetAbi() const final;
|
||||
|
||||
bool isValid() const final;
|
||||
|
||||
MacroInspectionRunner createMacroInspectionRunner() const final;
|
||||
@@ -89,7 +86,6 @@ public:
|
||||
private:
|
||||
IarToolChain();
|
||||
|
||||
ProjectExplorer::Abi m_targetAbi;
|
||||
Utils::FilePath m_compilerCommand;
|
||||
QStringList m_extraCodeModelFlags;
|
||||
|
||||
|
@@ -62,7 +62,6 @@ namespace Internal {
|
||||
|
||||
static const char compilerCommandKeyC[] = "CompilerPath";
|
||||
static const char compilerPlatformCodeGenFlagsKeyC[] = "PlatformCodeGenFlags";
|
||||
static const char targetAbiKeyC[] = "TargetAbi";
|
||||
|
||||
static bool compilerExists(const FilePath &compilerPath)
|
||||
{
|
||||
@@ -433,19 +432,7 @@ KeilToolChain::KeilToolChain() :
|
||||
ToolChain(Constants::KEIL_TOOLCHAIN_TYPEID)
|
||||
{
|
||||
setTypeDisplayName(tr("KEIL"));
|
||||
}
|
||||
|
||||
void KeilToolChain::setTargetAbi(const Abi &abi)
|
||||
{
|
||||
if (abi == m_targetAbi)
|
||||
return;
|
||||
m_targetAbi = abi;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
Abi KeilToolChain::targetAbi() const
|
||||
{
|
||||
return m_targetAbi;
|
||||
setTargetAbiKey("TargetAbi");
|
||||
}
|
||||
|
||||
bool KeilToolChain::isValid() const
|
||||
@@ -536,7 +523,6 @@ QVariantMap KeilToolChain::toMap() const
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data.insert(compilerCommandKeyC, m_compilerCommand.toString());
|
||||
data.insert(compilerPlatformCodeGenFlagsKeyC, m_extraCodeModelFlags);
|
||||
data.insert(targetAbiKeyC, m_targetAbi.toString());
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -546,7 +532,6 @@ bool KeilToolChain::fromMap(const QVariantMap &data)
|
||||
return false;
|
||||
m_compilerCommand = FilePath::fromString(data.value(compilerCommandKeyC).toString());
|
||||
m_extraCodeModelFlags = data.value(compilerPlatformCodeGenFlagsKeyC).toStringList();
|
||||
m_targetAbi = Abi::fromString(data.value(targetAbiKeyC).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -562,9 +547,8 @@ bool KeilToolChain::operator ==(const ToolChain &other) const
|
||||
|
||||
const auto customTc = static_cast<const KeilToolChain *>(&other);
|
||||
return m_compilerCommand == customTc->m_compilerCommand
|
||||
&& m_targetAbi == customTc->m_targetAbi
|
||||
&& m_extraCodeModelFlags == customTc->m_extraCodeModelFlags
|
||||
;
|
||||
&& targetAbi() == customTc->targetAbi()
|
||||
&& m_extraCodeModelFlags == customTc->m_extraCodeModelFlags;
|
||||
}
|
||||
|
||||
void KeilToolChain::setCompilerCommand(const FilePath &file)
|
||||
|
@@ -53,9 +53,6 @@ class KeilToolChain final : public ProjectExplorer::ToolChain
|
||||
Q_DECLARE_TR_FUNCTIONS(KeilToolChain)
|
||||
|
||||
public:
|
||||
void setTargetAbi(const ProjectExplorer::Abi &abi);
|
||||
ProjectExplorer::Abi targetAbi() const final;
|
||||
|
||||
bool isValid() const final;
|
||||
|
||||
MacroInspectionRunner createMacroInspectionRunner() const final;
|
||||
@@ -90,7 +87,6 @@ public:
|
||||
private:
|
||||
KeilToolChain();
|
||||
|
||||
ProjectExplorer::Abi m_targetAbi;
|
||||
Utils::FilePath m_compilerCommand;
|
||||
QStringList m_extraCodeModelFlags;
|
||||
|
||||
|
@@ -59,7 +59,6 @@ namespace Internal {
|
||||
// Helpers:
|
||||
|
||||
static const char compilerCommandKeyC[] = "CompilerPath";
|
||||
static const char targetAbiKeyC[] = "TargetAbi";
|
||||
|
||||
static bool compilerExists(const FilePath &compilerPath)
|
||||
{
|
||||
@@ -218,19 +217,7 @@ SdccToolChain::SdccToolChain() :
|
||||
ToolChain(Constants::SDCC_TOOLCHAIN_TYPEID)
|
||||
{
|
||||
setTypeDisplayName(Internal::SdccToolChain::tr("SDCC"));
|
||||
}
|
||||
|
||||
void SdccToolChain::setTargetAbi(const Abi &abi)
|
||||
{
|
||||
if (abi == m_targetAbi)
|
||||
return;
|
||||
m_targetAbi = abi;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
Abi SdccToolChain::targetAbi() const
|
||||
{
|
||||
return m_targetAbi;
|
||||
setTargetAbiKey("TargetAbi");
|
||||
}
|
||||
|
||||
bool SdccToolChain::isValid() const
|
||||
@@ -245,7 +232,7 @@ ToolChain::MacroInspectionRunner SdccToolChain::createMacroInspectionRunner() co
|
||||
|
||||
const Utils::FilePath compilerCommand = m_compilerCommand;
|
||||
const Utils::Id lang = language();
|
||||
const Abi abi = m_targetAbi;
|
||||
const Abi abi = targetAbi();
|
||||
|
||||
MacrosCache macrosCache = predefinedMacrosCache();
|
||||
|
||||
@@ -285,7 +272,7 @@ ToolChain::BuiltInHeaderPathsRunner SdccToolChain::createBuiltInHeaderPathsRunne
|
||||
addToEnvironment(env);
|
||||
|
||||
const Utils::FilePath compilerCommand = m_compilerCommand;
|
||||
const Abi abi = m_targetAbi;
|
||||
const Abi abi = targetAbi();
|
||||
|
||||
return [env, compilerCommand, abi](const QStringList &, const QString &, const QString &) {
|
||||
return dumpHeaderPaths(compilerCommand, env.toStringList(), abi);
|
||||
@@ -316,7 +303,6 @@ QVariantMap SdccToolChain::toMap() const
|
||||
{
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data.insert(compilerCommandKeyC, m_compilerCommand.toString());
|
||||
data.insert(targetAbiKeyC, m_targetAbi.toString());
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -325,7 +311,6 @@ bool SdccToolChain::fromMap(const QVariantMap &data)
|
||||
if (!ToolChain::fromMap(data))
|
||||
return false;
|
||||
m_compilerCommand = FilePath::fromString(data.value(compilerCommandKeyC).toString());
|
||||
m_targetAbi = Abi::fromString(data.value(targetAbiKeyC).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -341,8 +326,7 @@ bool SdccToolChain::operator==(const ToolChain &other) const
|
||||
|
||||
const auto customTc = static_cast<const SdccToolChain *>(&other);
|
||||
return m_compilerCommand == customTc->m_compilerCommand
|
||||
&& m_targetAbi == customTc->m_targetAbi
|
||||
;
|
||||
&& targetAbi() == customTc->targetAbi();
|
||||
}
|
||||
|
||||
void SdccToolChain::setCompilerCommand(const FilePath &file)
|
||||
|
@@ -52,9 +52,6 @@ class SdccToolChain final : public ProjectExplorer::ToolChain
|
||||
Q_DECLARE_TR_FUNCTIONS(SdccToolChain)
|
||||
|
||||
public:
|
||||
void setTargetAbi(const ProjectExplorer::Abi &abi);
|
||||
ProjectExplorer::Abi targetAbi() const final;
|
||||
|
||||
bool isValid() const final;
|
||||
|
||||
MacroInspectionRunner createMacroInspectionRunner() const final;
|
||||
@@ -86,7 +83,6 @@ public:
|
||||
private:
|
||||
SdccToolChain();
|
||||
|
||||
ProjectExplorer::Abi m_targetAbi;
|
||||
Utils::FilePath m_compilerCommand;
|
||||
|
||||
friend class SdccToolChainFactory;
|
||||
|
@@ -50,11 +50,7 @@ NimToolChain::NimToolChain(Utils::Id typeId)
|
||||
{
|
||||
setLanguage(Constants::C_NIMLANGUAGE_ID);
|
||||
setTypeDisplayName(tr("Nim"));
|
||||
}
|
||||
|
||||
Abi NimToolChain::targetAbi() const
|
||||
{
|
||||
return Abi::hostAbi();
|
||||
setTargetAbiNoSignal(Abi::hostAbi());
|
||||
}
|
||||
|
||||
bool NimToolChain::isValid() const
|
||||
|
@@ -38,7 +38,6 @@ public:
|
||||
NimToolChain();
|
||||
explicit NimToolChain(Utils::Id typeId);
|
||||
|
||||
ProjectExplorer::Abi targetAbi() const override;
|
||||
bool isValid() const override;
|
||||
|
||||
MacroInspectionRunner createMacroInspectionRunner() const override;
|
||||
|
@@ -59,7 +59,6 @@ namespace ProjectExplorer {
|
||||
|
||||
static const char compilerCommandKeyC[] = "ProjectExplorer.CustomToolChain.CompilerPath";
|
||||
static const char makeCommandKeyC[] = "ProjectExplorer.CustomToolChain.MakePath";
|
||||
static const char targetAbiKeyC[] = "ProjectExplorer.CustomToolChain.TargetAbi";
|
||||
static const char predefinedMacrosKeyC[] = "ProjectExplorer.CustomToolChain.PredefinedMacros";
|
||||
static const char headerPathsKeyC[] = "ProjectExplorer.CustomToolChain.HeaderPaths";
|
||||
static const char cxx11FlagsKeyC[] = "ProjectExplorer.CustomToolChain.Cxx11Flags";
|
||||
@@ -75,6 +74,7 @@ CustomToolChain::CustomToolChain() :
|
||||
m_outputParserId(GccParser::id())
|
||||
{
|
||||
setTypeDisplayName(tr("Custom"));
|
||||
setTargetAbiKey("ProjectExplorer.CustomToolChain.TargetAbi");
|
||||
}
|
||||
|
||||
CustomParserSettings CustomToolChain::customParserSettings() const
|
||||
@@ -85,20 +85,6 @@ CustomParserSettings CustomToolChain::customParserSettings() const
|
||||
});
|
||||
}
|
||||
|
||||
Abi CustomToolChain::targetAbi() const
|
||||
{
|
||||
return m_targetAbi;
|
||||
}
|
||||
|
||||
void CustomToolChain::setTargetAbi(const Abi &abi)
|
||||
{
|
||||
if (abi == m_targetAbi)
|
||||
return;
|
||||
|
||||
m_targetAbi = abi;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
bool CustomToolChain::isValid() const
|
||||
{
|
||||
return true;
|
||||
@@ -282,7 +268,6 @@ QVariantMap CustomToolChain::toMap() const
|
||||
QVariantMap data = ToolChain::toMap();
|
||||
data.insert(QLatin1String(compilerCommandKeyC), m_compilerCommand.toString());
|
||||
data.insert(QLatin1String(makeCommandKeyC), m_makeCommand.toString());
|
||||
data.insert(QLatin1String(targetAbiKeyC), m_targetAbi.toString());
|
||||
QStringList macros = Utils::transform<QList>(m_predefinedMacros, [](const Macro &m) { return QString::fromUtf8(m.toByteArray()); });
|
||||
data.insert(QLatin1String(predefinedMacrosKeyC), macros);
|
||||
data.insert(QLatin1String(headerPathsKeyC), headerPathsList());
|
||||
@@ -300,7 +285,6 @@ bool CustomToolChain::fromMap(const QVariantMap &data)
|
||||
|
||||
m_compilerCommand = FilePath::fromString(data.value(QLatin1String(compilerCommandKeyC)).toString());
|
||||
m_makeCommand = FilePath::fromString(data.value(QLatin1String(makeCommandKeyC)).toString());
|
||||
m_targetAbi = Abi::fromString(data.value(QLatin1String(targetAbiKeyC)).toString());
|
||||
const QStringList macros = data.value(QLatin1String(predefinedMacrosKeyC)).toStringList();
|
||||
m_predefinedMacros = Macro::toMacros(macros.join('\n').toUtf8());
|
||||
setHeaderPaths(data.value(QLatin1String(headerPathsKeyC)).toStringList());
|
||||
@@ -360,7 +344,7 @@ bool CustomToolChain::operator ==(const ToolChain &other) const
|
||||
auto customTc = static_cast<const CustomToolChain *>(&other);
|
||||
return m_compilerCommand == customTc->m_compilerCommand
|
||||
&& m_makeCommand == customTc->m_makeCommand
|
||||
&& m_targetAbi == customTc->m_targetAbi
|
||||
&& targetAbi() == customTc->targetAbi()
|
||||
&& m_predefinedMacros == customTc->m_predefinedMacros
|
||||
&& m_builtInHeaderPaths == customTc->m_builtInHeaderPaths;
|
||||
}
|
||||
|
@@ -64,9 +64,6 @@ public:
|
||||
QString displayName; ///< A translateable name to show in the user interface
|
||||
};
|
||||
|
||||
Abi targetAbi() const override;
|
||||
void setTargetAbi(const Abi &);
|
||||
|
||||
bool isValid() const override;
|
||||
|
||||
MacroInspectionRunner createMacroInspectionRunner() const override;
|
||||
@@ -117,7 +114,6 @@ private:
|
||||
Utils::FilePath m_compilerCommand;
|
||||
Utils::FilePath m_makeCommand;
|
||||
|
||||
Abi m_targetAbi;
|
||||
Macros m_predefinedMacros;
|
||||
HeaderPaths m_builtInHeaderPaths;
|
||||
QStringList m_cxx11Flags;
|
||||
|
@@ -266,6 +266,7 @@ GccToolChain::GccToolChain(Utils::Id typeId) :
|
||||
ToolChain(typeId)
|
||||
{
|
||||
setTypeDisplayName(tr("GCC"));
|
||||
setTargetAbiKey(targetAbiKeyC);
|
||||
}
|
||||
|
||||
void GccToolChain::setCompilerCommand(const FilePath &path)
|
||||
@@ -311,14 +312,14 @@ QString GccToolChain::defaultDisplayName() const
|
||||
const QRegularExpressionMatch match = regexp.match(m_compilerCommand.fileName());
|
||||
if (match.lastCapturedIndex() >= 1)
|
||||
type += ' ' + match.captured(1);
|
||||
if (m_targetAbi.architecture() == Abi::UnknownArchitecture || m_targetAbi.wordWidth() == 0)
|
||||
const Abi abi = targetAbi();
|
||||
if (abi.architecture() == Abi::UnknownArchitecture || abi.wordWidth() == 0)
|
||||
return type;
|
||||
return QCoreApplication::translate("ProjectExplorer::GccToolChain",
|
||||
"%1 (%2, %3 %4 in %5)").arg(type,
|
||||
ToolChainManager::displayNameOfLanguageId(language()),
|
||||
Abi::toString(m_targetAbi.architecture()),
|
||||
Abi::toString(m_targetAbi.wordWidth()),
|
||||
compilerCommand().parentDir().toUserOutput());
|
||||
return tr("%1 (%2, %3 %4 in %5)").arg(type,
|
||||
ToolChainManager::displayNameOfLanguageId(language()),
|
||||
Abi::toString(abi.architecture()),
|
||||
Abi::toString(abi.wordWidth()),
|
||||
compilerCommand().parentDir().toUserOutput());
|
||||
}
|
||||
|
||||
LanguageExtensions GccToolChain::defaultLanguageExtensions() const
|
||||
@@ -326,11 +327,6 @@ LanguageExtensions GccToolChain::defaultLanguageExtensions() const
|
||||
return LanguageExtension::Gnu;
|
||||
}
|
||||
|
||||
Abi GccToolChain::targetAbi() const
|
||||
{
|
||||
return m_targetAbi;
|
||||
}
|
||||
|
||||
QString GccToolChain::originalTargetTriple() const
|
||||
{
|
||||
if (m_originalTargetTriple.isEmpty())
|
||||
@@ -352,15 +348,6 @@ FilePath GccToolChain::installDir() const
|
||||
return m_installDir;
|
||||
}
|
||||
|
||||
void GccToolChain::setTargetAbi(const Abi &abi)
|
||||
{
|
||||
if (abi == m_targetAbi)
|
||||
return;
|
||||
|
||||
m_targetAbi = abi;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
Abis GccToolChain::supportedAbis() const
|
||||
{
|
||||
return m_supportedAbis;
|
||||
@@ -719,9 +706,9 @@ QStringList GccToolChain::suggestedMkspecList() const
|
||||
if (abi.wordWidth() == host.wordWidth()) {
|
||||
// no need to explicitly set the word width, but provide that mkspec anyway to make sure
|
||||
// that the correct compiler is picked if a mkspec with a wordwidth is given.
|
||||
return {"linux-g++", "linux-g++-" + QString::number(m_targetAbi.wordWidth())};
|
||||
return {"linux-g++", "linux-g++-" + QString::number(targetAbi().wordWidth())};
|
||||
}
|
||||
return {"linux-g++-" + QString::number(m_targetAbi.wordWidth())};
|
||||
return {"linux-g++-" + QString::number(targetAbi().wordWidth())};
|
||||
}
|
||||
|
||||
if (abi.os() == Abi::BsdOS && abi.osFlavor() == Abi::FreeBsdFlavor)
|
||||
@@ -747,19 +734,16 @@ void GccToolChain::resetToolChain(const FilePath &path)
|
||||
|
||||
setCompilerCommand(path);
|
||||
|
||||
Abi currentAbi = m_targetAbi;
|
||||
const Abi currentAbi = targetAbi();
|
||||
const DetectedAbisResult detectedAbis = detectSupportedAbis();
|
||||
m_supportedAbis = detectedAbis.supportedAbis;
|
||||
m_originalTargetTriple = detectedAbis.originalTargetTriple;
|
||||
m_installDir = installDir();
|
||||
|
||||
m_targetAbi = Abi();
|
||||
if (!m_supportedAbis.isEmpty()) {
|
||||
if (m_supportedAbis.contains(currentAbi))
|
||||
m_targetAbi = currentAbi;
|
||||
else
|
||||
m_targetAbi = m_supportedAbis.at(0);
|
||||
}
|
||||
if (m_supportedAbis.isEmpty())
|
||||
setTargetAbiNoSignal(Abi());
|
||||
else if (!m_supportedAbis.contains(currentAbi))
|
||||
setTargetAbiNoSignal(m_supportedAbis.at(0));
|
||||
|
||||
if (resetDisplayName)
|
||||
setDisplayName(defaultDisplayName()); // calls toolChainUpdated()!
|
||||
@@ -817,7 +801,6 @@ QVariantMap GccToolChain::toMap() const
|
||||
data.insert(compilerCommandKeyC, m_compilerCommand.toString());
|
||||
data.insert(compilerPlatformCodeGenFlagsKeyC, m_platformCodeGenFlags);
|
||||
data.insert(compilerPlatformLinkerFlagsKeyC, m_platformLinkerFlags);
|
||||
data.insert(targetAbiKeyC, m_targetAbi.toString());
|
||||
data.insert(originalTargetTripleKeyC, m_originalTargetTriple);
|
||||
data.insert(supportedAbisKeyC, Utils::transform<QStringList>(m_supportedAbis, &Abi::toString));
|
||||
return data;
|
||||
@@ -831,14 +814,13 @@ bool GccToolChain::fromMap(const QVariantMap &data)
|
||||
m_compilerCommand = FilePath::fromString(data.value(compilerCommandKeyC).toString());
|
||||
m_platformCodeGenFlags = data.value(compilerPlatformCodeGenFlagsKeyC).toStringList();
|
||||
m_platformLinkerFlags = data.value(compilerPlatformLinkerFlagsKeyC).toStringList();
|
||||
const QString targetAbiString = data.value(targetAbiKeyC).toString();
|
||||
m_targetAbi = Abi::fromString(targetAbiString);
|
||||
m_originalTargetTriple = data.value(originalTargetTripleKeyC).toString();
|
||||
const QStringList abiList = data.value(supportedAbisKeyC).toStringList();
|
||||
m_supportedAbis.clear();
|
||||
for (const QString &a : abiList)
|
||||
m_supportedAbis.append(Abi::fromString(a));
|
||||
|
||||
const QString targetAbiString = data.value(targetAbiKeyC).toString();
|
||||
if (targetAbiString.isEmpty())
|
||||
resetToolChain(m_compilerCommand);
|
||||
|
||||
@@ -851,7 +833,7 @@ bool GccToolChain::operator ==(const ToolChain &other) const
|
||||
return false;
|
||||
|
||||
auto gccTc = static_cast<const GccToolChain *>(&other);
|
||||
return m_compilerCommand == gccTc->m_compilerCommand && m_targetAbi == gccTc->m_targetAbi
|
||||
return m_compilerCommand == gccTc->m_compilerCommand && targetAbi() == gccTc->targetAbi()
|
||||
&& m_platformCodeGenFlags == gccTc->m_platformCodeGenFlags
|
||||
&& m_platformLinkerFlags == gccTc->m_platformLinkerFlags;
|
||||
}
|
||||
|
@@ -71,13 +71,10 @@ class PROJECTEXPLORER_EXPORT GccToolChain : public ToolChain
|
||||
public:
|
||||
GccToolChain(Utils::Id typeId);
|
||||
|
||||
Abi targetAbi() const override;
|
||||
QString originalTargetTriple() const override;
|
||||
Utils::FilePath installDir() const override;
|
||||
QString version() const;
|
||||
Abis supportedAbis() const override;
|
||||
void setTargetAbi(const Abi &);
|
||||
|
||||
bool isValid() const override;
|
||||
|
||||
Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const override;
|
||||
@@ -198,7 +195,6 @@ protected:
|
||||
mutable ExtraHeaderPathsFunction m_extraHeaderPathsFunction = [](HeaderPaths &) {};
|
||||
|
||||
private:
|
||||
Abi m_targetAbi;
|
||||
mutable Abis m_supportedAbis;
|
||||
mutable QString m_originalTargetTriple;
|
||||
mutable HeaderPaths m_headerPaths;
|
||||
|
@@ -66,7 +66,6 @@ using namespace Utils;
|
||||
#define KEY_ROOT "ProjectExplorer.MsvcToolChain."
|
||||
static const char varsBatKeyC[] = KEY_ROOT "VarsBat";
|
||||
static const char varsBatArgKeyC[] = KEY_ROOT "VarsBatArg";
|
||||
static const char supportedAbiKeyC[] = KEY_ROOT "SupportedAbi";
|
||||
static const char environModsKeyC[] = KEY_ROOT "environmentModifications";
|
||||
|
||||
enum { debug = 0 };
|
||||
@@ -815,6 +814,7 @@ MsvcToolChain::MsvcToolChain(Utils::Id typeId)
|
||||
setDisplayName("Microsoft Visual C++ Compiler");
|
||||
setTypeDisplayName(tr("MSVC"));
|
||||
addToAvailableMsvcToolchains(this);
|
||||
setTargetAbiKey(KEY_ROOT "SupportedAbi");
|
||||
}
|
||||
|
||||
void MsvcToolChain::inferWarningsForLevel(int warningLevel, WarningFlags &flags)
|
||||
@@ -841,11 +841,6 @@ MsvcToolChain::~MsvcToolChain()
|
||||
g_availableMsvcToolchains.removeOne(this);
|
||||
}
|
||||
|
||||
Abi MsvcToolChain::targetAbi() const
|
||||
{
|
||||
return m_abi;
|
||||
}
|
||||
|
||||
bool MsvcToolChain::isValid() const
|
||||
{
|
||||
if (m_vcvarsBat.isEmpty())
|
||||
@@ -856,14 +851,14 @@ bool MsvcToolChain::isValid() const
|
||||
|
||||
QString MsvcToolChain::originalTargetTriple() const
|
||||
{
|
||||
return m_abi.wordWidth() == 64 ? QLatin1String("x86_64-pc-windows-msvc")
|
||||
: QLatin1String("i686-pc-windows-msvc");
|
||||
return targetAbi().wordWidth() == 64 ? QLatin1String("x86_64-pc-windows-msvc")
|
||||
: QLatin1String("i686-pc-windows-msvc");
|
||||
}
|
||||
|
||||
QStringList MsvcToolChain::suggestedMkspecList() const
|
||||
{
|
||||
// "win32-msvc" is the common MSVC mkspec introduced in Qt 5.8.1
|
||||
switch (m_abi.osFlavor()) {
|
||||
switch (targetAbi().osFlavor()) {
|
||||
case Abi::WindowsMsvc2005Flavor:
|
||||
return {"win32-msvc",
|
||||
"win32-msvc2005"};
|
||||
@@ -919,7 +914,6 @@ QVariantMap MsvcToolChain::toMap() const
|
||||
data.insert(QLatin1String(varsBatKeyC), m_vcvarsBat);
|
||||
if (!m_varsBatArg.isEmpty())
|
||||
data.insert(QLatin1String(varsBatArgKeyC), m_varsBatArg);
|
||||
data.insert(QLatin1String(supportedAbiKeyC), m_abi.toString());
|
||||
Utils::EnvironmentItem::sort(&m_environmentModifications);
|
||||
data.insert(QLatin1String(environModsKeyC),
|
||||
Utils::EnvironmentItem::toVariantList(m_environmentModifications));
|
||||
@@ -935,8 +929,6 @@ bool MsvcToolChain::fromMap(const QVariantMap &data)
|
||||
m_vcvarsBat = QDir::fromNativeSeparators(data.value(QLatin1String(varsBatKeyC)).toString());
|
||||
m_varsBatArg = data.value(QLatin1String(varsBatArgKeyC)).toString();
|
||||
|
||||
const QString abiString = data.value(QLatin1String(supportedAbiKeyC)).toString();
|
||||
m_abi = Abi::fromString(abiString);
|
||||
m_environmentModifications = Utils::EnvironmentItem::itemsFromVariantList(
|
||||
data.value(QLatin1String(environModsKeyC)).toList());
|
||||
rescanForCompiler();
|
||||
@@ -946,7 +938,7 @@ bool MsvcToolChain::fromMap(const QVariantMap &data)
|
||||
m_vcvarsBat,
|
||||
m_varsBatArg));
|
||||
|
||||
const bool valid = !m_vcvarsBat.isEmpty() && m_abi.isValid();
|
||||
const bool valid = !m_vcvarsBat.isEmpty() && targetAbi().isValid();
|
||||
if (!valid)
|
||||
g_availableMsvcToolchains.removeOne(this);
|
||||
|
||||
@@ -1182,7 +1174,7 @@ QList<OutputLineParser *> MsvcToolChain::createOutputParsers() const
|
||||
void MsvcToolChain::setupVarsBat(const Abi &abi, const QString &varsBat, const QString &varsBatArg)
|
||||
{
|
||||
m_lastEnvironment = Utils::Environment::systemEnvironment();
|
||||
m_abi = abi;
|
||||
setTargetAbiNoSignal(abi);
|
||||
m_vcvarsBat = varsBat;
|
||||
m_varsBatArg = varsBatArg;
|
||||
|
||||
@@ -1197,7 +1189,7 @@ void MsvcToolChain::setupVarsBat(const Abi &abi, const QString &varsBat, const Q
|
||||
void MsvcToolChain::resetVarsBat()
|
||||
{
|
||||
m_lastEnvironment = Utils::Environment::systemEnvironment();
|
||||
m_abi = Abi();
|
||||
setTargetAbiNoSignal(Abi());
|
||||
m_vcvarsBat.clear();
|
||||
m_varsBatArg.clear();
|
||||
}
|
||||
|
@@ -62,7 +62,6 @@ public:
|
||||
explicit MsvcToolChain(Utils::Id typeId);
|
||||
~MsvcToolChain() override;
|
||||
|
||||
Abi targetAbi() const override;
|
||||
bool isValid() const override;
|
||||
|
||||
QString originalTargetTriple() const override;
|
||||
@@ -157,8 +156,6 @@ private:
|
||||
Utils::FilePath m_compilerCommand;
|
||||
|
||||
protected:
|
||||
Abi m_abi;
|
||||
|
||||
QString m_vcvarsBat;
|
||||
QString m_varsBatArg; // Argument
|
||||
};
|
||||
|
@@ -69,6 +69,8 @@ public:
|
||||
}
|
||||
|
||||
QByteArray m_id;
|
||||
Abi m_targetAbi;
|
||||
QString m_targetAbiKey;
|
||||
QSet<Utils::Id> m_supportedLanguages;
|
||||
mutable QString m_displayName;
|
||||
QString m_typeDisplayName;
|
||||
@@ -206,6 +208,8 @@ QVariantMap ToolChain::toMap() const
|
||||
result.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
|
||||
result.insert(QLatin1String(AUTODETECT_KEY), isAutoDetected());
|
||||
result.insert(QLatin1String(LANGUAGE_KEY_V2), language().toSetting());
|
||||
if (!d->m_targetAbiKey.isEmpty())
|
||||
result.insert(d->m_targetAbiKey, d->m_targetAbi.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -234,6 +238,30 @@ QString ToolChain::typeDisplayName() const
|
||||
return d->m_typeDisplayName;
|
||||
}
|
||||
|
||||
Abi ToolChain::targetAbi() const
|
||||
{
|
||||
return d->m_targetAbi;
|
||||
}
|
||||
|
||||
void ToolChain::setTargetAbi(const Abi &abi)
|
||||
{
|
||||
if (abi == d->m_targetAbi)
|
||||
return;
|
||||
|
||||
d->m_targetAbi = abi;
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
void ToolChain::setTargetAbiNoSignal(const Abi &abi)
|
||||
{
|
||||
d->m_targetAbi = abi;
|
||||
}
|
||||
|
||||
void ToolChain::setTargetAbiKey(const QString &abiKey)
|
||||
{
|
||||
d->m_targetAbiKey = abiKey;
|
||||
}
|
||||
|
||||
void ToolChain::setTypeDisplayName(const QString &typeName)
|
||||
{
|
||||
d->m_typeDisplayName = typeName;
|
||||
@@ -273,6 +301,9 @@ bool ToolChain::fromMap(const QVariantMap &data)
|
||||
if (!d->m_language.isValid())
|
||||
d->m_language = Utils::Id(Constants::CXX_LANGUAGE_ID);
|
||||
|
||||
if (!d->m_targetAbiKey.isEmpty())
|
||||
d->m_targetAbi = Abi::fromString(data.value(d->m_targetAbiKey).toString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,6 @@ namespace ProjectExplorer {
|
||||
|
||||
namespace Internal { class ToolChainPrivate; }
|
||||
|
||||
class Abi;
|
||||
class ToolChainConfigWidget;
|
||||
class ToolChainFactory;
|
||||
class Kit;
|
||||
@@ -96,7 +95,8 @@ public:
|
||||
Utils::Id typeId() const;
|
||||
QString typeDisplayName() const;
|
||||
|
||||
virtual Abi targetAbi() const = 0;
|
||||
Abi targetAbi() const;
|
||||
void setTargetAbi(const Abi &abi);
|
||||
|
||||
virtual ProjectExplorer::Abis supportedAbis() const;
|
||||
virtual QString originalTargetTriple() const { return QString(); }
|
||||
@@ -163,6 +163,9 @@ protected:
|
||||
|
||||
void setTypeDisplayName(const QString &typeName);
|
||||
|
||||
void setTargetAbiNoSignal(const Abi &abi);
|
||||
void setTargetAbiKey(const QString &abiKey);
|
||||
|
||||
const MacrosCache &predefinedMacrosCache() const;
|
||||
const HeaderPathsCache &headerPathsCache() const;
|
||||
|
||||
|
@@ -307,12 +307,12 @@ public:
|
||||
m_toolChains.append(this);
|
||||
setLanguage(Constants::CXX_LANGUAGE_ID);
|
||||
setTypeDisplayName("Test Tool Chain");
|
||||
setTargetAbiNoSignal(Abi::hostAbi());
|
||||
}
|
||||
|
||||
static QList<TTC *> toolChains() { return m_toolChains; }
|
||||
static bool hasToolChains() { return !m_toolChains.isEmpty(); }
|
||||
|
||||
Abi targetAbi() const override { return Abi::hostAbi(); }
|
||||
bool isValid() const override { return m_valid; }
|
||||
MacroInspectionRunner createMacroInspectionRunner() const override { return MacroInspectionRunner(); }
|
||||
Macros predefinedMacros(const QStringList &cxxflags) const override { Q_UNUSED(cxxflags) return Macros(); }
|
||||
|
Reference in New Issue
Block a user