Skip to content

Commit

Permalink
MSVC: Fix Microsoft Visual Cpp Build Tools
Browse files Browse the repository at this point in the history
Change-Id: I5db3d0dda0b92c1ed26655f39df05d9667bfbd04
Reviewed-by: Friedemann Kleint <[email protected]>
  • Loading branch information
hunger committed Apr 26, 2016
1 parent 600e1cd commit bc4a24d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
5 changes: 4 additions & 1 deletion src/plugins/projectexplorer/abstractmsvctoolchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ Abi AbstractMsvcToolChain::targetAbi() const

bool AbstractMsvcToolChain::isValid() const
{
return !m_vcvarsBat.isEmpty();
if (m_vcvarsBat.isEmpty())
return false;
QFileInfo fi(m_vcvarsBat);
return fi.isFile() && fi.isExecutable();
}

QByteArray AbstractMsvcToolChain::predefinedMacros(const QStringList &cxxflags) const
Expand Down
23 changes: 6 additions & 17 deletions src/plugins/projectexplorer/msvctoolchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,6 @@ MsvcToolChain::MsvcToolChain(Core::Id typeId, const QString &name, const Abi &ab
setDisplayName(name);
}

bool MsvcToolChain::isValid() const
{
if (!AbstractMsvcToolChain::isValid())
return false;
QString vcVarsBat = MsvcToolChainFactory::vcVarsBatFor(QFileInfo(m_vcvarsBat).absolutePath(), m_varsBatArg);
return QFileInfo::exists(vcVarsBat);
}

MsvcToolChain::MsvcToolChain(Core::Id typeId)
: AbstractMsvcToolChain(typeId, ManualDetection)
{ }
Expand Down Expand Up @@ -610,8 +602,10 @@ bool MsvcToolChainFactory::checkForVisualStudioInstallation(const QString &vsNam
return vsRegistry.contains(vsName);
}

QString MsvcToolChainFactory::vcVarsBatFor(const QString &basePath, const QString &toolchainName)
QString MsvcToolChainFactory::vcVarsBatFor(const QString &basePath, MsvcToolChain::Platform platform)
{
const QString toolchainName = platformName(platform);

if (toolchainName.startsWith(QLatin1Char('/'))) // windows sdk case, all use SetEnv.cmd
return basePath + QLatin1String("/SetEnv.cmd");
if (toolchainName == QLatin1String("x86"))
Expand All @@ -636,11 +630,6 @@ QString MsvcToolChainFactory::vcVarsBatFor(const QString &basePath, const QStrin
return QString();
}

QString MsvcToolChainFactory::vcVarsBatFor(const QString &basePath, MsvcToolChain::Platform platform)
{
return vcVarsBatFor(basePath, platformName(platform));
}

static ToolChain *findOrCreateToolChain(const QList<ToolChain *> &alreadyKnown,
const QString &name, const Abi &abi,
const QString &varsBat, const QString &varsBatArg,
Expand Down Expand Up @@ -816,13 +805,13 @@ QList<ToolChain *> MsvcToolChainFactory::autoDetect(const QList<ToolChain *> &al
<< MsvcToolChain::arm << MsvcToolChain::x86_arm << MsvcToolChain::amd64_arm
<< MsvcToolChain::ia64 << MsvcToolChain::x86_ia64;
foreach (const MsvcToolChain::Platform &platform, platforms) {
if (hostSupportsPlatform(platform)
&& QFileInfo(vcVarsBatFor(path, platform)).isFile()) {
QString vcvarsBat = vcVarsBatFor(path, platform);
if (hostSupportsPlatform(platform) && QFileInfo(vcvarsBat).isFile()) {
results.append(findOrCreateToolChain(
alreadyKnown,
generateDisplayName(vsName, MsvcToolChain::VS, platform),
findAbiOfMsvc(MsvcToolChain::VS, platform, vsName),
vcvarsAllbat, platformName(platform),
vcvarsBat, platformName(platform),
ToolChain::AutoDetection));
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/projectexplorer/msvctoolchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class MsvcToolChain : public AbstractMsvcToolChain
Detection d = ManualDetection);
MsvcToolChain();

bool isValid() const override;
Utils::FileNameList suggestedMkspecList() const override;

QString typeDisplayName() const override;
Expand Down Expand Up @@ -132,7 +131,6 @@ class MsvcToolChainFactory : public ToolChainFactory
ToolChain *restore(const QVariantMap &data) override;

ToolChainConfigWidget *configurationWidget(ToolChain *);
static QString vcVarsBatFor(const QString &basePath, const QString &toolchainName);
static QString vcVarsBatFor(const QString &basePath, MsvcToolChain::Platform platform);
private:
static bool checkForVisualStudioInstallation(const QString &vsName);
Expand Down

0 comments on commit bc4a24d

Please sign in to comment.