Commit d33e66c8 authored by David Schulz's avatar David Schulz

ProjectExplorer: Detect all msvc toolchains.

The host system will not be taken into account, so the cross build
toolchains are also detected.

Task-number: QTCREATORBUG-10998
Change-Id: I04a410bbf368898b70d9560d2c2a4a6c60ed0b61
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 52b7505b
...@@ -63,17 +63,44 @@ static QString platformName(MsvcToolChain::Platform t) ...@@ -63,17 +63,44 @@ static QString platformName(MsvcToolChain::Platform t)
{ {
switch (t) { switch (t) {
case MsvcToolChain::x86: case MsvcToolChain::x86:
return QLatin1String(" (x86)"); return QLatin1String("x86");
case MsvcToolChain::amd64: case MsvcToolChain::amd64:
return QLatin1String(" (amd64)"); return QLatin1String("amd64");
case MsvcToolChain::x86_amd64:
return QLatin1String("x86_amd64");
case MsvcToolChain::ia64: case MsvcToolChain::ia64:
return QLatin1String(" (ia64)"); return QLatin1String("ia64");
case MsvcToolChain::x86_ia64:
return QLatin1String("x86_ia64");
case MsvcToolChain::arm: case MsvcToolChain::arm:
return QLatin1String(" (arm)"); return QLatin1String("arm");
case MsvcToolChain::x86_arm:
return QLatin1String("x86_arm");
case MsvcToolChain::amd64_arm:
return QLatin1String("amd64_arm");
} }
return QString(); return QString();
} }
static bool hostSupportsPlatform(MsvcToolChain::Platform platform)
{
switch (Utils::HostOsInfo::hostArchitecture()) {
case Utils::HostOsInfo::HostArchitectureAMD64:
if (platform == MsvcToolChain::amd64 || platform == MsvcToolChain::amd64_arm)
return true;
// fall through (all x86 toolchains are also working on an amd64 host)
case Utils::HostOsInfo::HostArchitectureX86:
return platform == MsvcToolChain::x86 || platform == MsvcToolChain::x86_amd64
|| platform == MsvcToolChain::x86_ia64 || platform == MsvcToolChain::x86_arm;
case Utils::HostOsInfo::HostArchitectureArm:
return platform == MsvcToolChain::arm;
case Utils::HostOsInfo::HostArchitectureItanium:
return platform == MsvcToolChain::ia64;
default:
return false;
}
}
static Abi findAbiOfMsvc(MsvcToolChain::Type type, MsvcToolChain::Platform platform, const QString &version) static Abi findAbiOfMsvc(MsvcToolChain::Type type, MsvcToolChain::Platform platform, const QString &version)
{ {
Abi::Architecture arch = Abi::X86Architecture; Abi::Architecture arch = Abi::X86Architecture;
...@@ -86,11 +113,15 @@ static Abi findAbiOfMsvc(MsvcToolChain::Type type, MsvcToolChain::Platform platf ...@@ -86,11 +113,15 @@ static Abi findAbiOfMsvc(MsvcToolChain::Type type, MsvcToolChain::Platform platf
wordWidth = 32; wordWidth = 32;
break; break;
case ProjectExplorer::Internal::MsvcToolChain::ia64: case ProjectExplorer::Internal::MsvcToolChain::ia64:
case ProjectExplorer::Internal::MsvcToolChain::x86_ia64:
arch = Abi::ItaniumArchitecture; arch = Abi::ItaniumArchitecture;
break; break;
case ProjectExplorer::Internal::MsvcToolChain::amd64: case ProjectExplorer::Internal::MsvcToolChain::amd64:
case ProjectExplorer::Internal::MsvcToolChain::x86_amd64:
break; break;
case ProjectExplorer::Internal::MsvcToolChain::arm: case ProjectExplorer::Internal::MsvcToolChain::arm:
case ProjectExplorer::Internal::MsvcToolChain::x86_arm:
case ProjectExplorer::Internal::MsvcToolChain::amd64_arm:
arch = Abi::ArmArchitecture; arch = Abi::ArmArchitecture;
wordWidth = 32; wordWidth = 32;
break; break;
...@@ -126,13 +157,13 @@ static QString generateDisplayName(const QString &name, ...@@ -126,13 +157,13 @@ static QString generateDisplayName(const QString &name,
{ {
if (t == MsvcToolChain::WindowsSDK) { if (t == MsvcToolChain::WindowsSDK) {
QString sdkName = name; QString sdkName = name;
sdkName += platformName(p); sdkName += QString::fromLatin1(" (%1)").arg(platformName(p));
return sdkName; return sdkName;
} }
// Comes as "9.0" from the registry // Comes as "9.0" from the registry
QString vcName = QLatin1String("Microsoft Visual C++ Compiler "); QString vcName = QLatin1String("Microsoft Visual C++ Compiler ");
vcName += name; vcName += name;
vcName += platformName(p); vcName += QString::fromLatin1(" (%1)").arg(platformName(p));
return vcName; return vcName;
} }
...@@ -482,6 +513,11 @@ QString MsvcToolChainFactory::vcVarsBatFor(const QString &basePath, const QStrin ...@@ -482,6 +513,11 @@ QString MsvcToolChainFactory::vcVarsBatFor(const QString &basePath, const QStrin
return QString(); return QString();
} }
QString MsvcToolChainFactory::vcVarsBatFor(const QString &basePath, MsvcToolChain::Platform platform)
{
return vcVarsBatFor(basePath, platformName(platform));
}
QList<ToolChain *> MsvcToolChainFactory::autoDetect() QList<ToolChain *> MsvcToolChainFactory::autoDetect()
{ {
QList<ToolChain *> results; QList<ToolChain *> results;
...@@ -545,64 +581,22 @@ QList<ToolChain *> MsvcToolChainFactory::autoDetect() ...@@ -545,64 +581,22 @@ QList<ToolChain *> MsvcToolChainFactory::autoDetect()
const int version = vsName.left(dotPos).toInt(); const int version = vsName.left(dotPos).toInt();
const QString vcvarsAllbat = path + QLatin1String("/vcvarsall.bat"); const QString vcvarsAllbat = path + QLatin1String("/vcvarsall.bat");
if (QFileInfo(vcvarsAllbat).isFile()) { if (QFileInfo(vcvarsAllbat).isFile()) {
Utils::HostOsInfo::HostArchitecture arch = Utils::HostOsInfo::hostArchitecture(); QList<MsvcToolChain::Platform> platforms; // prioritized list
if (QFileInfo(vcVarsBatFor(path, QLatin1String("x86"))).isFile()) platforms << MsvcToolChain::x86
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::x86), << MsvcToolChain::amd64 << MsvcToolChain::x86_amd64
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::x86, vsName), << MsvcToolChain::arm << MsvcToolChain::amd64_arm << MsvcToolChain::x86_arm
vcvarsAllbat, QLatin1String("x86"), ToolChain::AutoDetection)); << MsvcToolChain::ia64 << MsvcToolChain::x86_ia64;
foreach (const MsvcToolChain::Platform &platform, platforms) {
if (arch == Utils::HostOsInfo::HostArchitectureX86) { if (hostSupportsPlatform(platform)
if (QFileInfo(vcVarsBatFor(path, QLatin1String("x86_amd64"))).isFile()) && QFileInfo(vcVarsBatFor(path, platform)).isFile()) {
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::amd64), results.append(new MsvcToolChain(
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::amd64, vsName), generateDisplayName(vsName, MsvcToolChain::VS, platform),
vcvarsAllbat, QLatin1String("x86_amd64"), ToolChain::AutoDetection)); findAbiOfMsvc(MsvcToolChain::VS, platform, vsName),
} else if (arch == Utils::HostOsInfo::HostArchitectureAMD64) { vcvarsAllbat,
if (QFileInfo(vcVarsBatFor(path, QLatin1String("amd64"))).isFile()) { platformName(platform),
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::amd64), ToolChain::AutoDetection));
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::amd64, vsName),
vcvarsAllbat, QLatin1String("amd64"), ToolChain::AutoDetection));
} else if (QFileInfo(vcVarsBatFor(path, QLatin1String("x86_amd64"))).isFile()) {
// Fall back to 32 bit to 4 bit
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::amd64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::amd64, vsName),
vcvarsAllbat, QLatin1String("x86_amd64"), ToolChain::AutoDetection));
} }
} }
if (arch == Utils::HostOsInfo::HostArchitectureX86) {
if (QFileInfo(vcVarsBatFor(path, QLatin1String("x86_arm"))).isFile())
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::arm),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::arm, vsName),
vcvarsAllbat, QLatin1String("x86_arm"), ToolChain::AutoDetection));
} else if (arch == Utils::HostOsInfo::HostArchitectureAMD64) {
if (QFileInfo(vcVarsBatFor(path, QLatin1String("amd64_arm"))).isFile()) {
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::arm),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::arm, vsName),
vcvarsAllbat, QLatin1String("amd64_arm"), ToolChain::AutoDetection));
} else if (QFileInfo(vcVarsBatFor(path, QLatin1String("x86_arm"))).isFile()) {
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::arm),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::arm, vsName),
vcvarsAllbat, QLatin1String("x86_arm"), ToolChain::AutoDetection));
}
} else if (arch == Utils::HostOsInfo::HostArchitectureArm) {
if (QFileInfo(vcVarsBatFor(path, QLatin1String("arm"))).isFile())
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::arm),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::arm, vsName),
vcvarsAllbat, QLatin1String("arm"), ToolChain::AutoDetection));
}
if (arch == Utils::HostOsInfo::HostArchitectureItanium) {
if (QFileInfo(vcVarsBatFor(path, QLatin1String("ia64"))).isFile())
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::ia64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::ia64, vsName),
vcvarsAllbat, QLatin1String("ia64"), ToolChain::AutoDetection));
} else if (arch == Utils::HostOsInfo::HostArchitectureX86
|| arch == Utils::HostOsInfo::HostArchitectureAMD64) {
if (QFileInfo(vcVarsBatFor(path, QLatin1String("x86_ia64"))).isFile())
results.append(new MsvcToolChain(generateDisplayName(vsName, MsvcToolChain::VS, MsvcToolChain::ia64),
findAbiOfMsvc(MsvcToolChain::VS, MsvcToolChain::ia64, vsName),
vcvarsAllbat, QLatin1String("x86_ia64"), ToolChain::AutoDetection));
}
} else { } else {
qWarning("Unable to find MSVC setup script %s in version %d", qPrintable(vcvarsAllbat), version); qWarning("Unable to find MSVC setup script %s in version %d", qPrintable(vcvarsAllbat), version);
} }
......
...@@ -49,8 +49,12 @@ public: ...@@ -49,8 +49,12 @@ public:
enum Type { WindowsSDK, VS }; enum Type { WindowsSDK, VS };
enum Platform { x86, enum Platform { x86,
amd64, amd64,
x86_amd64,
ia64, ia64,
arm x86_ia64,
arm,
x86_arm,
amd64_arm
}; };
MsvcToolChain(const QString &name, const Abi &abi, MsvcToolChain(const QString &name, const Abi &abi,
...@@ -104,6 +108,7 @@ public: ...@@ -104,6 +108,7 @@ public:
ToolChainConfigWidget *configurationWidget(ToolChain *); ToolChainConfigWidget *configurationWidget(ToolChain *);
static QString vcVarsBatFor(const QString &basePath, const QString &toolchainName); static QString vcVarsBatFor(const QString &basePath, const QString &toolchainName);
static QString vcVarsBatFor(const QString &basePath, MsvcToolChain::Platform platform);
private: private:
static bool checkForVisualStudioInstallation(const QString &vsName); static bool checkForVisualStudioInstallation(const QString &vsName);
}; };
......
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
QMap<QString, FileName> m_abiToDebugger; QMap<QString, FileName> m_abiToDebugger;
PersistentSettingsWriter *m_writer; PersistentSettingsWriter *m_writer;
QList<ToolChain *> m_toolChains; QList<ToolChain *> m_toolChains; // prioritized List
}; };
ToolChainManagerPrivate::~ToolChainManagerPrivate() ToolChainManagerPrivate::~ToolChainManagerPrivate()
......
...@@ -386,15 +386,21 @@ QtOptionsPageWidget::ValidityInfo QtOptionsPageWidget::validInformation(const Ba ...@@ -386,15 +386,21 @@ QtOptionsPageWidget::ValidityInfo QtOptionsPageWidget::validInformation(const Ba
QList<ToolChain*> QtOptionsPageWidget::toolChains(const BaseQtVersion *version) QList<ToolChain*> QtOptionsPageWidget::toolChains(const BaseQtVersion *version)
{ {
QHash<QString,ToolChain*> toolChains; QList<ToolChain*> toolChains;
if (!version) if (!version)
return toolChains.values(); return toolChains;
foreach (const Abi &a, version->qtAbis()) QSet<QString> ids;
foreach (ToolChain *tc, ToolChainManager::findToolChains(a)) foreach (const Abi &a, version->qtAbis()) {
toolChains.insert(tc->id(), tc); foreach (ToolChain *tc, ToolChainManager::findToolChains(a)) {
if (ids.contains(tc->id()))
continue;
ids.insert(tc->id());
toolChains.append(tc);
}
}
return toolChains.values(); return toolChains;
} }
QString QtOptionsPageWidget::defaultToolChainId(const BaseQtVersion *version) QString QtOptionsPageWidget::defaultToolChainId(const BaseQtVersion *version)
......
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