Commit 1304b250 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

ToolChain: Make sure all ToolChains have a language set



* Add code to toolchains
* Assert that this is the case in the toolchainmanager

Change-Id: I82452689e83279fd9d1afb3140b0070bef9b6cd8
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent dbf5f743
......@@ -63,10 +63,11 @@ static const char ANDROID_NDK_TC_VERION[] = "Qt4ProjectManager.Android.NDK_TC_VE
QHash<Abi, QList<int> > AndroidToolChainFactory::m_newestVersionForAbi;
FileName AndroidToolChainFactory::m_ndkLocation;
AndroidToolChain::AndroidToolChain(const Abi &abi, const QString &ndkToolChainVersion, Detection d)
AndroidToolChain::AndroidToolChain(const Abi &abi, const QString &ndkToolChainVersion, Language l, Detection d)
: GccToolChain(Constants::ANDROID_TOOLCHAIN_ID, d),
m_ndkToolChainVersion(ndkToolChainVersion), m_secondaryToolChain(false)
{
setLanguage(l);
setTargetAbi(abi);
setDisplayName(QString::fromLatin1("Android GCC (%1-%2)")
.arg(AndroidConfig::displayName(targetAbi()))
......@@ -392,7 +393,8 @@ AndroidToolChainFactory::autodetectToolChainsForNdk(const FileName &ndkPath,
AndroidToolChain *tc = findToolChain(compilerPath, alreadyKnown);
if (!tc) {
tc = new AndroidToolChain(abi, version, ToolChain::AutoDetection);
tc = new AndroidToolChain(abi, version, ToolChain::Language::Cxx,
ToolChain::AutoDetection);
tc->resetToolChain(compilerPath);
}
result.append(tc);
......
......@@ -62,7 +62,8 @@ protected:
DetectedAbisResult detectSupportedAbis() const override;
private:
explicit AndroidToolChain(const ProjectExplorer::Abi &abi, const QString &ndkToolChainVersion, Detection d);
explicit AndroidToolChain(const ProjectExplorer::Abi &abi, const QString &ndkToolChainVersion,
Language l, Detection d);
AndroidToolChain();
AndroidToolChain(const AndroidToolChain &);
......
......@@ -355,6 +355,7 @@ void IosConfigurations::setDeveloperPath(const FileName &devPath)
static ClangToolChain *createToolChain(const Platform &platform)
{
ClangToolChain *toolChain = new ClangToolChain(ToolChain::AutoDetection);
toolChain->setLanguage(ToolChain::Language::Cxx);
toolChain->setDisplayName(platform.name);
toolChain->setPlatformCodeGenFlags(platform.backendFlags);
toolChain->setPlatformLinkerFlags(platform.backendFlags);
......
......@@ -42,6 +42,7 @@ namespace ProjectExplorer {
namespace Internal {
AbstractMsvcToolChain::AbstractMsvcToolChain(Core::Id typeId,
const Language &l,
Detection d,
const Abi &abi,
const QString& vcvarsBat) : ToolChain(typeId, d),
......@@ -53,6 +54,7 @@ AbstractMsvcToolChain::AbstractMsvcToolChain(Core::Id typeId,
Q_ASSERT(abi.binaryFormat() == Abi::PEFormat);
Q_ASSERT(abi.osFlavor() != Abi::WindowsMSysFlavor);
Q_ASSERT(!m_vcvarsBat.isEmpty());
setLanguage(l);
}
AbstractMsvcToolChain::AbstractMsvcToolChain(Core::Id typeId, Detection d) :
......
......@@ -38,7 +38,8 @@ namespace Internal {
class PROJECTEXPLORER_EXPORT AbstractMsvcToolChain : public ToolChain
{
public:
explicit AbstractMsvcToolChain(Core::Id typeId, Detection d, const Abi &abi, const QString& vcvarsBat);
explicit AbstractMsvcToolChain(Core::Id typeId, const Language &l, Detection d,
const Abi &abi, const QString& vcvarsBat);
explicit AbstractMsvcToolChain(Core::Id typeId, Detection d);
Abi targetAbi() const override;
......
......@@ -88,7 +88,9 @@ static const char messageCapKeyC[] = "ProjectExplorer.CustomToolChain.MessageCap
CustomToolChain::CustomToolChain(Detection d) :
ToolChain(Constants::CUSTOM_TOOLCHAIN_TYPEID, d),
m_outputParser(Gcc)
{ }
{
setLanguage(Language::Cxx);
}
QString CustomToolChain::typeDisplayName() const
{
......
......@@ -776,7 +776,9 @@ bool GccToolChainFactory::canCreate()
ToolChain *GccToolChainFactory::create()
{
return createToolChain(false);
ToolChain *tc = createToolChain(false);
tc->setLanguage({ ToolChain::Language::Cxx });
return tc;
}
QList<ToolChain *> GccToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
......@@ -860,6 +862,7 @@ QList<ToolChain *> GccToolChainFactory::autoDetectToolchains(const QString &comp
tc->setTargetAbi(abi);
tc->setOriginalTargetTriple(detectedAbis.originalTargetTriple);
tc->setDisplayName(tc->defaultDisplayName()); // reset displayname
tc->setLanguage(ToolChain::Language::Cxx);
result.append(tc.take());
}
......
......@@ -328,13 +328,14 @@ Utils::Environment MsvcToolChain::readEnvironmentSetting(Utils::Environment& env
// --------------------------------------------------------------------------
MsvcToolChain::MsvcToolChain(const QString &name, const Abi &abi,
const QString &varsBat, const QString &varsBatArg, Detection d) :
MsvcToolChain(Constants::MSVC_TOOLCHAIN_TYPEID, name, abi, varsBat, varsBatArg, d)
const QString &varsBat, const QString &varsBatArg, const Language &l,
Detection d) :
MsvcToolChain(Constants::MSVC_TOOLCHAIN_TYPEID, name, abi, varsBat, varsBatArg, l, d)
{ }
MsvcToolChain::MsvcToolChain(Core::Id typeId, const QString &name, const Abi &abi,
const QString &varsBat, const QString &varsBatArg,
Detection d) : AbstractMsvcToolChain(typeId, d, abi, varsBat),
const QString &varsBat, const QString &varsBatArg, const Language &l,
Detection d) : AbstractMsvcToolChain(typeId, l, d, abi, varsBat),
m_varsBatArg(varsBatArg)
{
Q_ASSERT(!name.isEmpty());
......@@ -342,8 +343,7 @@ MsvcToolChain::MsvcToolChain(Core::Id typeId, const QString &name, const Abi &ab
setDisplayName(name);
}
MsvcToolChain::MsvcToolChain(Core::Id typeId)
: AbstractMsvcToolChain(typeId, ManualDetection)
MsvcToolChain::MsvcToolChain(Core::Id typeId) : AbstractMsvcToolChain(typeId, ManualDetection)
{ }
MsvcToolChain::MsvcToolChain() : MsvcToolChain(Constants::MSVC_TOOLCHAIN_TYPEID)
......@@ -496,18 +496,15 @@ static const char clangClBinary[] = "clang-cl.exe";
ClangClToolChain::ClangClToolChain(const QString &name, const QString &llvmDir,
const Abi &abi,
const QString &varsBat, const QString &varsBatArg,
const QString &varsBat, const QString &varsBatArg, const Language &l,
Detection d)
: MsvcToolChain(Constants::CLANG_CL_TOOLCHAIN_TYPEID, name, abi, varsBat, varsBatArg, d)
: MsvcToolChain(Constants::CLANG_CL_TOOLCHAIN_TYPEID, name, abi, varsBat, varsBatArg, l, d)
, m_llvmDir(llvmDir)
, m_compiler(Utils::FileName::fromString(m_llvmDir + QStringLiteral("/bin/") + QLatin1String(clangClBinary)))
{
}
{ }
ClangClToolChain::ClangClToolChain()
: MsvcToolChain(Constants::CLANG_CL_TOOLCHAIN_TYPEID)
{
}
ClangClToolChain::ClangClToolChain() : MsvcToolChain(Constants::CLANG_CL_TOOLCHAIN_TYPEID)
{ }
bool ClangClToolChain::isValid() const
{
......@@ -632,7 +629,7 @@ static ToolChain *findOrCreateToolChain(const QList<ToolChain *> &alreadyKnown,
&& mtc->varsBatArg() == varsBatArg;
});
if (!tc)
tc = new MsvcToolChain(name, abi, varsBat, varsBatArg, d);
tc = new MsvcToolChain(name, abi, varsBat, varsBatArg, ToolChain::Language::Cxx, d);
return tc;
}
......@@ -671,6 +668,7 @@ static void detectCppBuildTools(QList<ToolChain *> *list)
e.format, e.wordSize);
list->append(new MsvcToolChain(name + QLatin1String(e.postFix), abi,
vcVarsBat, QLatin1String(e.varsBatArg),
ToolChain::Language::Cxx,
ToolChain::AutoDetection));
}
}
......@@ -715,7 +713,7 @@ static void detectClangClToolChain(QList<ToolChain *> *list)
+ Abi::toString(targetAbi.osFlavor()).toUpper();
list->append(new ClangClToolChain(name, path, targetAbi,
msvcToolChain->varsBat(), msvcToolChain->varsBatArg(),
ToolChain::AutoDetection));
ToolChain::Language::Cxx, ToolChain::AutoDetection));
}
QList<ToolChain *> MsvcToolChainFactory::autoDetect(const QList<ToolChain *> &alreadyKnown)
......
......@@ -55,7 +55,7 @@ public:
explicit MsvcToolChain(const QString &name, const Abi &abi,
const QString &varsBat, const QString &varsBatArg,
Detection d = ManualDetection);
const Language &l, Detection d = ManualDetection);
MsvcToolChain();
Utils::FileNameList suggestedMkspecList() const override;
......@@ -76,7 +76,7 @@ public:
protected:
explicit MsvcToolChain(Core::Id typeId, const QString &name, const Abi &abi,
const QString &varsBat, const QString &varsBatArg,
Detection d);
const Language &l, Detection d);
explicit MsvcToolChain(Core::Id typeId);
Utils::Environment readEnvironmentSetting(Utils::Environment& env) const override;
......@@ -93,6 +93,7 @@ public:
explicit ClangClToolChain(const QString &name, const QString &llvmDir,
const Abi &abi,
const QString &varsBat, const QString &varsBatArg,
const Language &l,
Detection d = ManualDetection);
ClangClToolChain();
......
......@@ -388,6 +388,7 @@ void ToolChainManager::notifyAboutUpdate(ToolChain *tc)
bool ToolChainManager::registerToolChain(ToolChain *tc)
{
QTC_ASSERT(tc->language() != ToolChain::Language::None, return false);
QTC_ASSERT(d->m_writer, return false);
if (!tc || d->m_toolChains.contains(tc))
......@@ -433,7 +434,10 @@ public:
ToolChain("TestToolChainType", d),
token(t),
m_valid(v)
{ m_toolChains.append(this); }
{
m_toolChains.append(this);
setLanguage(ToolChain::Language::Cxx);
}
static QList<TTC *> toolChains();
static bool hasToolChains() { return !m_toolChains.isEmpty(); }
......
......@@ -236,8 +236,9 @@ WinCEToolChain::WinCEToolChain(const QString &name,
const QString &binPath,
const QString &includePath,
const QString &libPath,
const Language &l,
Detection d) :
AbstractMsvcToolChain(Constants::WINCE_TOOLCHAIN_TYPEID, d, abi, vcvarsBat),
AbstractMsvcToolChain(Constants::WINCE_TOOLCHAIN_TYPEID, l, d, abi, vcvarsBat),
m_msvcVer(msvcVer),
m_ceVer(ceVer),
m_binPath(binPath),
......@@ -368,7 +369,8 @@ static ToolChain *findOrCreateToolChain(const QList<ToolChain *> &alreadyKnown,
&& cetc->libPath() == libPath;
});
if (!tc)
tc = new WinCEToolChain(name, abi, vcvarsBat, msvcVer, ceVer, binPath, includePath, libPath, d);
tc = new WinCEToolChain(name, abi, vcvarsBat, msvcVer, ceVer, binPath, includePath, libPath,
ProjectExplorer::ToolChain::Language::Cxx, d);
return tc;
}
......
......@@ -43,6 +43,7 @@ public:
const QString &binPath,
const QString &includePath,
const QString &libPath,
const Language &l,
Detection d = ManualDetection);
Utils::FileNameList suggestedMkspecList() const override;
......
......@@ -62,6 +62,13 @@ QnxToolChain::QnxToolChain(ToolChain::Detection d)
: GccToolChain(Constants::QNX_TOOLCHAIN_ID, d)
{ }
QnxToolChain::QnxToolChain(Language l, ToolChain::Detection d)
: QnxToolChain(d)
{
setLanguage(l);
}
QString QnxToolChain::typeDisplayName() const
{
return QnxToolChainFactory::tr("QCC");
......
......@@ -35,6 +35,7 @@ class QnxToolChain : public ProjectExplorer::GccToolChain
{
public:
explicit QnxToolChain(Detection d);
explicit QnxToolChain(Language l, Detection d);
QString typeDisplayName() const override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment